Browse Source

Add some diagnostics for inablilty to place all stacks on battlefield

Ivan Savenko 4 months ago
parent
commit
afb22e52eb
2 changed files with 8 additions and 0 deletions
  1. 2 0
      lib/battle/BattleInfo.cpp
  2. 6 0
      lib/mapObjects/CRewardableObject.cpp

+ 2 - 0
lib/battle/BattleInfo.cpp

@@ -342,6 +342,8 @@ std::unique_ptr<BattleInfo> BattleInfo::setupBattle(IGameInfoCallback *cb, const
 
 			if (pos.isValid())
 				currentBattle->generateNewStack(currentBattle->nextUnitId(), *i->second, side, i->first, pos);
+			else
+				logMod->warn("Invalid battlefield layout! Failed to find position for unit %d for %s", k, side == BattleSide::ATTACKER ? "attacker" : "defender");
 		}
 	}
 

+ 6 - 0
lib/mapObjects/CRewardableObject.cpp

@@ -85,6 +85,12 @@ void CRewardableObject::battleFinished(IGameEventCallback & gameEvents, const CG
 {
 	if (result.winner == BattleSide::ATTACKER)
 	{
+		while(!stacks.empty())
+		{
+			logMod->warn("Attacker won, but defender still has remaining units in configurable map objects! Make sure that guards configuration is valid!");
+			gameEvents.eraseStack(StackLocation(id, stacks.begin()->first));
+		}
+
 		doHeroVisit(gameEvents, hero);
 	}
 }