diff --git a/lib/battle/SideInBattle.cpp b/lib/battle/SideInBattle.cpp index 1fd2c63d0..aeafb243c 100644 --- a/lib/battle/SideInBattle.cpp +++ b/lib/battle/SideInBattle.cpp @@ -17,7 +17,18 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army { hero = Hero; armyObject = Army; - color = armyObject->getOwner(); + + switch(armyObject->ID) + { + case Obj::CREATURE_GENERATOR1: + case Obj::CREATURE_GENERATOR2: + case Obj::CREATURE_GENERATOR3: + case Obj::CREATURE_GENERATOR4: + color = PlayerColor::NEUTRAL; + break; + default: + color = armyObject->getOwner(); + } if(color == PlayerColor::UNFLAGGABLE) color = PlayerColor::NEUTRAL; diff --git a/lib/mapObjects/IObjectInterface.cpp b/lib/mapObjects/IObjectInterface.cpp index 967470804..b76106232 100644 --- a/lib/mapObjects/IObjectInterface.cpp +++ b/lib/mapObjects/IObjectInterface.cpp @@ -107,6 +107,10 @@ int3 IBoatGenerator::bestLocation() const IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const { int3 tile = bestLocation(); + + if(!tile.valid()) + return TILE_BLOCKED; //no available water + const TerrainTile *t = IObjectInterface::cb->getTile(tile); if(!t) return TILE_BLOCKED; //no available water diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 41ed3caa1..93685c12b 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -635,11 +635,9 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo) return; } - const CArmedInstance *bEndArmy1 = battleInfo->sides.at(0).armyObject; - const CArmedInstance *bEndArmy2 = battleInfo->sides.at(1).armyObject; const BattleResult::EResult result = battleResult.get()->result; - CasualtiesAfterBattle cab1(bEndArmy1, battleInfo), cab2(bEndArmy2, battleInfo); //calculate casualties before deleting battle + CasualtiesAfterBattle cab1(battleInfo->sides.at(0), battleInfo), cab2(battleInfo->sides.at(1), battleInfo); //calculate casualties before deleting battle ChangeSpells cs; //for Eagle Eye if(!finishingBattle->isDraw() && finishingBattle->winnerHero) @@ -816,8 +814,8 @@ void CGameHandler::endBattleConfirm(const BattleInfo * battleInfo) changePrimSkill(finishingBattle->winnerHero, PrimarySkill::EXPERIENCE, battleResult.data->exp[finishingBattle->winnerSide]); BattleResultAccepted raccepted; - raccepted.heroResult[0].army = const_cast(bEndArmy1); - raccepted.heroResult[1].army = const_cast(bEndArmy2); + raccepted.heroResult[0].army = const_cast(battleInfo->sides.at(0).armyObject); + raccepted.heroResult[1].army = const_cast(battleInfo->sides.at(1).armyObject); raccepted.heroResult[0].hero = const_cast(battleInfo->sides.at(0).hero); raccepted.heroResult[1].hero = const_cast(battleInfo->sides.at(1).hero); raccepted.heroResult[0].exp = battleResult.data->exp[0]; @@ -6684,14 +6682,12 @@ void CGameHandler::showInfoDialog(const std::string & msg, PlayerColor player) showInfoDialog(&iw); } -CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat): - army(_army) +CasualtiesAfterBattle::CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat): + army(battleSide.armyObject) { heroWithDeadCommander = ObjectInstanceID(); - PlayerColor color = army->tempOwner; - if(color == PlayerColor::UNFLAGGABLE) - color = PlayerColor::NEUTRAL; + PlayerColor color = battleSide.color; for(CStack * st : bat->stacks) { diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 771ba90f1..a3f906408 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -23,6 +23,7 @@ VCMI_LIB_NAMESPACE_BEGIN class CGameState; struct StartInfo; struct BattleResult; +struct SideInBattle; struct BattleAttack; struct BattleStackAttacked; struct CPack; @@ -90,7 +91,7 @@ struct CasualtiesAfterBattle TSummoned summoned; ObjectInstanceID heroWithDeadCommander; //TODO: unify stack locations - CasualtiesAfterBattle(const CArmedInstance * _army, const BattleInfo * bat); + CasualtiesAfterBattle(const SideInBattle & battleSide, const BattleInfo * bat); void updateArmy(CGameHandler *gh); };