فهرست منبع

#1965 - treat dwelling defenders as neutrals

Andrii Danylchenko 2 سال پیش
والد
کامیت
ec8898a0e7
4فایلهای تغییر یافته به همراه20 افزوده شده و 11 حذف شده
  1. 8 0
      lib/battle/SideInBattle.cpp
  2. 4 0
      lib/mapObjects/IObjectInterface.cpp
  3. 6 10
      server/CGameHandler.cpp
  4. 2 1
      server/CGameHandler.h

+ 8 - 0
lib/battle/SideInBattle.cpp

@@ -19,6 +19,14 @@ void SideInBattle::init(const CGHeroInstance * Hero, const CArmedInstance * Army
 	armyObject = Army;
 	color = armyObject->getOwner();
 
+	if(armyObject->ID == Obj::CREATURE_GENERATOR1
+		|| armyObject->ID == Obj::CREATURE_GENERATOR2
+		|| armyObject->ID == Obj::CREATURE_GENERATOR3
+		|| armyObject->ID == Obj::CREATURE_GENERATOR4)
+	{
+		color = PlayerColor::NEUTRAL;
+	}
+
 	if(color == PlayerColor::UNFLAGGABLE)
 		color = PlayerColor::NEUTRAL;
 }

+ 4 - 0
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

+ 6 - 10
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<CArmedInstance*>(bEndArmy1);
-	raccepted.heroResult[1].army = const_cast<CArmedInstance*>(bEndArmy2);
+	raccepted.heroResult[0].army = const_cast<CArmedInstance*>(battleInfo->sides.at(0).armyObject);
+	raccepted.heroResult[1].army = const_cast<CArmedInstance*>(battleInfo->sides.at(1).armyObject);
 	raccepted.heroResult[0].hero = const_cast<CGHeroInstance*>(battleInfo->sides.at(0).hero);
 	raccepted.heroResult[1].hero = const_cast<CGHeroInstance*>(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)
 	{

+ 2 - 1
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);
 };