Răsfoiți Sursa

Improve formatting, update other config information about includes.

FeniksFire 8 ani în urmă
părinte
comite
8ccdda6d2d

+ 1 - 1
client/battle/CBattleAnimations.cpp

@@ -944,7 +944,7 @@ bool CSpellEffectAnimation::init()
 	{
 
 			const CStack* destStack = owner->getCurrentPlayerInterface()->cb->battleGetStackByPos(destTile, false);
-			Rect &tilePos = owner->bfield[destTile]->pos;
+			Rect & tilePos = owner->bfield[destTile]->pos;
 			BattleEffect be;
 			be.effectID = ID;
 			be.anim = CDefHandler::giveDef(customAnim);

+ 22 - 10
lib/VCMI_lib.cbp

@@ -125,16 +125,28 @@
 		<Unit filename="../Version.h" />
 		<Unit filename="../include/vstd/CLoggerBase.h" />
 		<Unit filename="AI_Base.h" />
-		<Unit filename="BattleAction.cpp" />
-		<Unit filename="BattleAction.h" />
-		<Unit filename="BattleHex.cpp" />
-		<Unit filename="BattleHex.h" />
-		<Unit filename="BattleInfo.cpp" />
-		<Unit filename="BattleInfo.h" />
+		<Unit filename="battle/BattleAction.cpp" />
+		<Unit filename="battle/BattleAction.h" />
+		<Unit filename="battle/BattleHex.cpp" />
+		<Unit filename="battle/BattleHex.h" />
+		<Unit filename="battle/BattleInfo.cpp" />
+		<Unit filename="battle/BattleInfo.h" />
+		<Unit filename="battle/AccessibilityInfo.cpp" />
+		<Unit filename="battle/AccessibilityInfo.h" />
+		<Unit filename="battle/BattleAttackInfo.cpp" />
+		<Unit filename="battle/BattleAttackInfo.h" />
+		<Unit filename="battle/CBattleInfoCallback.cpp" />
+		<Unit filename="battle/CBattleInfoCallback.h" />
+		<Unit filename="battle/CBattleInfoEssentials.cpp" />
+		<Unit filename="battle/CBattleInfoEssentials.h" />
+		<Unit filename="battle/CCallbackBase.cpp" />
+		<Unit filename="battle/CCallbackBase.h" />
+		<Unit filename="battle/CPlayerBattleCallback.cpp" />
+		<Unit filename="battle/CPlayerBattleCallback.h" />
+		<Unit filename="battle/ReachabilityInfo.cpp" />
+		<Unit filename="battle/ReachabilityInfo.h" />
 		<Unit filename="CArtHandler.cpp" />
 		<Unit filename="CArtHandler.h" />
-		<Unit filename="CBattleCallback.cpp" />
-		<Unit filename="CBattleCallback.h" />
 		<Unit filename="CBonusTypeHandler.cpp" />
 		<Unit filename="CBonusTypeHandler.h" />
 		<Unit filename="CBuildingHandler.cpp" />
@@ -161,8 +173,8 @@
 		<Unit filename="CMakeLists.txt" />
 		<Unit filename="CModHandler.cpp" />
 		<Unit filename="CModHandler.h" />
-		<Unit filename="CObstacleInstance.cpp" />
-		<Unit filename="CObstacleInstance.h" />
+		<Unit filename="battle/CObstacleInstance.cpp" />
+		<Unit filename="battle/CObstacleInstance.h" />
 		<Unit filename="CPathfinder.cpp" />
 		<Unit filename="CPathfinder.h" />
 		<Unit filename="CPlayerState.h" />

+ 23 - 11
lib/VCMI_lib.vcxproj

@@ -168,9 +168,16 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="BattleAction.cpp" />
-    <ClCompile Include="BattleHex.cpp" />
-    <ClCompile Include="BattleInfo.cpp" />
+    <ClCompile Include="battle\BattleAction.cpp" />
+    <ClCompile Include="battle\BattleHex.cpp" />
+    <ClCompile Include="battle\BattleInfo.cpp" />
+    <ClCompile Include="battle\AccessibilityInfo.cpp" />
+    <ClCompile Include="battle\BattleAttackInfo.cpp" />
+    <ClCompile Include="battle\CBattleInfoCallback.cpp" />
+    <ClCompile Include="battle\CBattleInfoEssentials.cpp" />
+    <ClCompile Include="battle\CCallbackBase.cpp" />
+    <ClCompile Include="battle\CPlayerBattleCallback.cpp" />
+    <ClCompile Include="battle\ReachabilityInfo.cpp" />
     <ClCompile Include="CArtHandler.cpp" />
     <ClCompile Include="CBonusTypeHandler.cpp" />
     <ClCompile Include="CBuildingHandler.cpp" />
@@ -183,7 +190,7 @@
     <ClCompile Include="CGeneralTextHandler.cpp" />
     <ClCompile Include="CHeroHandler.cpp" />
     <ClCompile Include="CModHandler.cpp" />
-    <ClCompile Include="CObstacleInstance.cpp" />
+    <ClCompile Include="battle\CObstacleInstance.cpp" />
     <ClCompile Include="CPathfinder.cpp" />
     <ClCompile Include="CStack.cpp" />
     <ClCompile Include="CThreadHelper.cpp" />
@@ -262,7 +269,6 @@
     <ClCompile Include="logging\CLogger.cpp" />
     <ClCompile Include="logging\CBasicLogConfigurator.cpp" />
     <ClCompile Include="HeroBonus.cpp" />
-    <ClCompile Include="CBattleCallback.cpp" />
     <ClCompile Include="IGameCallback.cpp" />
     <ClCompile Include="CGameInfoCallback.cpp" />
     <ClCompile Include="JsonNode.cpp" />
@@ -290,9 +296,16 @@
     <ClInclude Include="..\Global.h" />
     <ClInclude Include="..\Version.h" />
     <ClInclude Include="AI_Base.h" />
-    <ClInclude Include="BattleAction.h" />
-    <ClInclude Include="BattleHex.h" />
-    <ClInclude Include="BattleInfo.h" />
+    <ClInclude Include="battle\BattleAction.h" />
+    <ClInclude Include="battle\BattleHex.h" />
+    <ClInclude Include="battle\BattleInfo.h" />
+    <ClInclude Include="battle\AccessibilityInfo.h" />
+    <ClInclude Include="battle\BattleAttackInfo.h" />
+    <ClInclude Include="battle\CBattleInfoCallback.h" />
+    <ClInclude Include="battle\CBattleInfoEssentials.h" />
+    <ClInclude Include="battle\CCallbackBase.h" />
+    <ClInclude Include="battle\CPlayerBattleCallback.h" />
+    <ClInclude Include="battle\ReachabilityInfo.h" />
     <ClInclude Include="CArtHandler.h" />
     <ClInclude Include="CBonusTypeHandler.h" />
     <ClInclude Include="CBuildingHandler.h" />
@@ -306,7 +319,7 @@
     <ClInclude Include="CGeneralTextHandler.h" />
     <ClInclude Include="CHeroHandler.h" />
     <ClInclude Include="CModHandler.h" />
-    <ClInclude Include="CObstacleInstance.h" />
+    <ClInclude Include="battle\CObstacleInstance.h" />
     <ClInclude Include="CondSh.h" />
     <ClInclude Include="ConstTransitivePtr.h" />
     <ClInclude Include="CPathfinder.h" />
@@ -376,7 +389,6 @@
     <ClInclude Include="logging\CBasicLogConfigurator.h" />
     <ClInclude Include="GameConstants.h" />
     <ClInclude Include="HeroBonus.h" />
-    <ClInclude Include="CBattleCallback.h" />
     <ClInclude Include="IGameCallback.h" />
     <ClInclude Include="CGameInfoCallback.h" />
     <ClInclude Include="IGameEventsReceiver.h" />
@@ -425,4 +437,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>

+ 34 - 10
lib/VCMI_lib.vcxproj.filters

@@ -31,7 +31,7 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="BattleAction.cpp" />
+    <ClCompile Include="battle\BattleAction.cpp" />
     <ClCompile Include="CArtHandler.cpp" />
     <ClCompile Include="CBuildingHandler.cpp" />
     <ClCompile Include="CCreatureHandler.cpp" />
@@ -49,14 +49,20 @@
     <ClCompile Include="ResourceSet.cpp" />
     <ClCompile Include="CGameInterface.cpp" />
     <ClCompile Include="JsonNode.cpp" />
-    <ClCompile Include="BattleHex.cpp" />
+    <ClCompile Include="battle\BattleHex.cpp" />
     <ClCompile Include="CConsoleHandler.cpp" />
     <ClCompile Include="CThreadHelper.cpp" />
     <ClCompile Include="StdInc.cpp" />
-    <ClCompile Include="CObstacleInstance.cpp" />
+    <ClCompile Include="battle\CObstacleInstance.cpp" />
     <ClCompile Include="CModHandler.cpp" />
     <ClCompile Include="CConfigHandler.cpp" />
-    <ClCompile Include="CBattleCallback.cpp" />
+    <ClCompile Include="battle\AccessibilityInfo.cpp" />
+    <ClCompile Include="battle\BattleAttackInfo.cpp" />
+    <ClCompile Include="battle\CBattleInfoCallback.cpp" />
+    <ClCompile Include="battle\CBattleInfoEssentials.cpp" />
+    <ClCompile Include="battle\CCallbackBase.cpp" />
+    <ClCompile Include="battle\CPlayerBattleCallback.cpp" />
+    <ClCompile Include="battle\ReachabilityInfo.cpp" />
     <ClCompile Include="Mapping\CCampaignHandler.cpp" />
     <ClCompile Include="GameConstants.cpp" />
     <ClCompile Include="VCMIDirs.cpp" />
@@ -263,7 +269,7 @@
     <ClCompile Include="CStack.cpp" />
     <ClCompile Include="SideInBattle.cpp" />
     <ClCompile Include="SiegeInfo.cpp" />
-    <ClCompile Include="BattleInfo.cpp" />
+    <ClCompile Include="battle\BattleInfo.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="CCreatureSet.h">
@@ -317,10 +323,10 @@
     <ClInclude Include="CTownHandler.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="BattleAction.h">
+    <ClInclude Include="battle\BattleAction.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="CObstacleInstance.h">
+    <ClInclude Include="battle\CObstacleInstance.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="IGameEventsReceiver.h">
@@ -344,7 +350,7 @@
     <ClInclude Include="AI_Base.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="BattleHex.h">
+    <ClInclude Include="battle\BattleHex.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="CConsoleHandler.h">
@@ -380,7 +386,25 @@
     <ClInclude Include="CConfigHandler.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="CBattleCallback.h">
+    <ClInclude Include="AccessibilityInfo.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="BattleAttackInfo.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="CBattleInfoCallback.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="CBattleInfoEssentials.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="CCallbackBase.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="CPlayerBattleCallback.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="ReachabilityInfo.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="Mapping\CCampaignHandler.h">
@@ -656,7 +680,7 @@
     <ClInclude Include="serializer\Connection.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="BattleInfo.h">
+    <ClInclude Include="battle\BattleInfo.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="CStack.h">

+ 2 - 4
lib/battle/AccessibilityInfo.cpp

@@ -11,7 +11,7 @@
 #include "AccessibilityInfo.h"
 #include "CStack.h"
 
-bool AccessibilityInfo::accessible(BattleHex tile, const CStack *stack) const
+bool AccessibilityInfo::accessible(BattleHex tile, const CStack * stack) const
 {
 	return accessible(tile, stack->doubleWide(), stack->attackerOwned);
 }
@@ -35,12 +35,11 @@ bool AccessibilityInfo::accessible(BattleHex tile, bool doubleWide, bool attacke
 	return true;
 }
 
-bool AccessibilityInfo::occupiable(const CStack *stack, BattleHex tile) const
+bool AccessibilityInfo::occupiable(const CStack * stack, BattleHex tile) const
 {
 	//obviously, we can occupy tile by standing on it
 	if(accessible(tile, stack))
 		return true;
-
 	if(stack->doubleWide())
 	{
 		//Check the tile next to -> if stack stands there, it'll also occupy considered hex
@@ -48,6 +47,5 @@ bool AccessibilityInfo::occupiable(const CStack *stack, BattleHex tile) const
 		if(accessible(anotherTile, stack))
 			return true;
 	}
-
 	return false;
 }

+ 5 - 7
lib/battle/AccessibilityInfo.h

@@ -13,9 +13,7 @@
 class CStack;
 
 //Accessibility is property of hex in battle. It doesn't depend on stack, side's perspective and so on.
-namespace EAccessibility
-{
-enum EAccessibility
+enum class EAccessibility
 {
 	ACCESSIBLE,
 	ALIVE_STACK,
@@ -25,13 +23,13 @@ enum EAccessibility
 	UNAVAILABLE, //indestructible wall parts, special battlefields (like boat-to-boat)
 	SIDE_COLUMN //used for first and last columns of hexes that are unavailable but wat machines can stand there
 };
-}
 
-typedef std::array<EAccessibility::EAccessibility, GameConstants::BFIELD_SIZE> TAccessibilityArray;
+
+typedef std::array<EAccessibility, GameConstants::BFIELD_SIZE> TAccessibilityArray;
 
 struct DLL_LINKAGE AccessibilityInfo : TAccessibilityArray
 {
-	bool occupiable(const CStack *stack, BattleHex tile) const;
-	bool accessible(BattleHex tile, const CStack *stack) const; //checks for both tiles if stack is double wide
+	bool occupiable(const CStack * stack, BattleHex tile) const;
+	bool accessible(BattleHex tile, const CStack * stack) const; //checks for both tiles if stack is double wide
 	bool accessible(BattleHex tile, bool doubleWide, bool attackerOwned) const; //checks for both tiles if stack is double wide
 };

+ 6 - 6
lib/battle/BattleAction.cpp

@@ -24,7 +24,7 @@ BattleAction::BattleAction():
 {
 }
 
-BattleAction BattleAction::makeHeal(const CStack *healer, const CStack *healed)
+BattleAction BattleAction::makeHeal(const CStack * healer, const CStack * healed)
 {
 	BattleAction ba;
 	ba.side = !healer->attackerOwned;
@@ -34,7 +34,7 @@ BattleAction BattleAction::makeHeal(const CStack *healer, const CStack *healed)
 	return ba;
 }
 
-BattleAction BattleAction::makeDefend(const CStack *stack)
+BattleAction BattleAction::makeDefend(const CStack * stack)
 {
 	BattleAction ba;
 	ba.side = !stack->attackerOwned;
@@ -44,7 +44,7 @@ BattleAction BattleAction::makeDefend(const CStack *stack)
 }
 
 
-BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * attacked, BattleHex attackFrom /*= BattleHex::INVALID*/)
+BattleAction BattleAction::makeMeleeAttack(const CStack * stack, const CStack * attacked, BattleHex attackFrom /*= BattleHex::INVALID*/)
 {
 	BattleAction ba;
 	ba.side = !stack->attackerOwned;
@@ -55,7 +55,7 @@ BattleAction BattleAction::makeMeleeAttack(const CStack *stack, const CStack * a
 	return ba;
 
 }
-BattleAction BattleAction::makeWait(const CStack *stack)
+BattleAction BattleAction::makeWait(const CStack * stack)
 {
 	BattleAction ba;
 	ba.side = !stack->attackerOwned;
@@ -64,7 +64,7 @@ BattleAction BattleAction::makeWait(const CStack *stack)
 	return ba;
 }
 
-BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *target)
+BattleAction BattleAction::makeShotAttack(const CStack * shooter, const CStack * target)
 {
 	BattleAction ba;
 	ba.side = !shooter->attackerOwned;
@@ -74,7 +74,7 @@ BattleAction BattleAction::makeShotAttack(const CStack *shooter, const CStack *t
 	return ba;
 }
 
-BattleAction BattleAction::makeMove(const CStack *stack, BattleHex dest)
+BattleAction BattleAction::makeMove(const CStack * stack, BattleHex dest)
 {
 	BattleAction ba;
 	ba.side = !stack->attackerOwned;

+ 7 - 7
lib/battle/BattleAction.h

@@ -16,7 +16,7 @@ class CStack;
 struct DLL_LINKAGE BattleAction
 {
 	ui8 side; //who made this action: false - left, true - right player
-	ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
+	ui32 stackNumber; //stack ID, -1 left hero, -2 right hero,
 	Battle::ActionType actionType; //use ActionType enum for values
 	BattleHex destinationTile;
 	si32 additionalInfo; // e.g. spell number if type is 1 || 10; tile to attack if type is 6
@@ -29,12 +29,12 @@ struct DLL_LINKAGE BattleAction
 
 	BattleAction();
 
-	static BattleAction makeHeal(const CStack *healer, const CStack *healed);
-	static BattleAction makeDefend(const CStack *stack);
-	static BattleAction makeWait(const CStack *stack);
-	static BattleAction makeMeleeAttack(const CStack *stack, const CStack * attacked, BattleHex attackFrom = BattleHex::INVALID);
-	static BattleAction makeShotAttack(const CStack *shooter, const CStack *target);
-	static BattleAction makeMove(const CStack *stack, BattleHex dest);
+	static BattleAction makeHeal(const CStack * healer, const CStack * healed);
+	static BattleAction makeDefend(const CStack * stack);
+	static BattleAction makeWait(const CStack * stack);
+	static BattleAction makeMeleeAttack(const CStack * stack, const CStack * attacked, BattleHex attackFrom = BattleHex::INVALID);
+	static BattleAction makeShotAttack(const CStack * shooter, const CStack * target);
+	static BattleAction makeMove(const CStack * stack, BattleHex dest);
 	static BattleAction makeEndOFTacticPhase(ui8 side);
 };
 

+ 1 - 1
lib/battle/BattleAttackInfo.cpp

@@ -12,7 +12,7 @@
 #include "CStack.h"
 
 
-BattleAttackInfo::BattleAttackInfo(const CStack *Attacker, const CStack *Defender, bool Shooting)
+BattleAttackInfo::BattleAttackInfo(const CStack * Attacker, const CStack * Defender, bool Shooting)
 {
 	attacker = Attacker;
 	defender = Defender;

+ 1 - 1
lib/battle/BattleAttackInfo.h

@@ -28,6 +28,6 @@ struct DLL_LINKAGE BattleAttackInfo
 	bool deathBlow;
 	bool ballistaDoubleDamage;
 
-	BattleAttackInfo(const CStack *Attacker, const CStack *Defender, bool Shooting = false);
+	BattleAttackInfo(const CStack * Attacker, const CStack * Defender, bool Shooting = false);
 	BattleAttackInfo reverse() const;
 };

+ 14 - 14
lib/battle/BattleInfo.cpp

@@ -57,7 +57,7 @@ int BattleInfo::getAvaliableHex(CreatureID creID, bool attackerOwned, int initia
 	return BattleHex::getClosestTile(attackerOwned, pos, occupyable);
 }
 
-std::pair< std::vector<BattleHex>, int > BattleInfo::getPath(BattleHex start, BattleHex dest, const CStack *stack)
+std::pair< std::vector<BattleHex>, int > BattleInfo::getPath(BattleHex start, BattleHex dest, const CStack * stack)
 {
 	auto reachability = getReachability(stack);
 
@@ -78,8 +78,8 @@ std::pair< std::vector<BattleHex>, int > BattleInfo::getPath(BattleHex start, Ba
 	return std::make_pair(path, reachability.distances[dest]);
 }
 
-ui32 BattleInfo::calculateDmg( const CStack* attacker, const CStack* defender,
-	bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg, CRandomGenerator & rand )
+ui32 BattleInfo::calculateDmg(const CStack* attacker, const CStack* defender,
+	bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg, CRandomGenerator & rand)
 {
 	TDmgRange range = calculateDmgRange(attacker, defender, shooting, charge, lucky, unlucky, deathBlow, ballistaDoubleDmg);
 
@@ -96,7 +96,7 @@ ui32 BattleInfo::calculateDmg( const CStack* attacker, const CStack* defender,
 		return range.first;
 }
 
-void BattleInfo::calculateCasualties( std::map<ui32,si32> *casualties ) const
+void BattleInfo::calculateCasualties(std::map<ui32,si32> * casualties) const
 {
 	for(auto & elem : stacks)//setting casualties
 	{
@@ -112,12 +112,12 @@ CStack * BattleInfo::generateNewStack(const CStackInstance &base, bool attackerO
 {
 	int stackID = getIdForNewStack();
 	PlayerColor owner = sides[attackerOwned ? 0 : 1].color;
-	assert((owner >= PlayerColor::PLAYER_LIMIT)  ||
-		   (base.armyObj && base.armyObj->tempOwner == owner));
+	assert((owner >= PlayerColor::PLAYER_LIMIT) ||
+		(base.armyObj && base.armyObj->tempOwner == owner));
 
-	auto  ret = new CStack(&base, owner, stackID, attackerOwned, slot);
+	auto ret = new CStack(&base, owner, stackID, attackerOwned, slot);
 	ret->position = getAvaliableHex (base.getCreatureID(), attackerOwned, position); //TODO: what if no free tile on battlefield was found?
-	ret->state.insert(EBattleStackState::ALIVE);  //alive state indication
+	ret->state.insert(EBattleStackState::ALIVE); //alive state indication
 	return ret;
 }
 
@@ -125,9 +125,9 @@ CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, bool at
 {
 	int stackID = getIdForNewStack();
 	PlayerColor owner = sides[attackerOwned ? 0 : 1].color;
-	auto  ret = new CStack(&base, owner, stackID, attackerOwned, slot);
+	auto ret = new CStack(&base, owner, stackID, attackerOwned, slot);
 	ret->position = position;
-	ret->state.insert(EBattleStackState::ALIVE);  //alive state indication
+	ret->state.insert(EBattleStackState::ALIVE); //alive state indication
 	return ret;
 }
 
@@ -261,7 +261,7 @@ struct RangeGenerator
 	std::function<int()> myRand;
 };
 
-BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town )
+BattleInfo * BattleInfo::setupBattle(int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town)
 {
 	CMP_stack cmpst;
 	auto curB = new BattleInfo();
@@ -644,7 +644,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 	return curB;
 }
 
-const CGHeroInstance * BattleInfo::getHero( PlayerColor player ) const
+const CGHeroInstance * BattleInfo::getHero(PlayerColor player) const
 {
 	for(int i = 0; i < sides.size(); i++)
 		if(sides[i].color == player)
@@ -741,7 +741,7 @@ CGHeroInstance * BattleInfo::battleGetFightingHero(ui8 side) const
 }
 
 
-bool CMP_stack::operator()( const CStack* a, const CStack* b )
+bool CMP_stack::operator()(const CStack* a, const CStack* b)
 {
 	switch(phase)
 	{
@@ -772,7 +772,7 @@ bool CMP_stack::operator()( const CStack* a, const CStack* b )
 
 }
 
-CMP_stack::CMP_stack( int Phase /*= 1*/, int Turn )
+CMP_stack::CMP_stack(int Phase /*= 1*/, int Turn)
 {
 	phase = Phase;
 	turn = Turn;

+ 3 - 3
lib/battle/BattleInfo.h

@@ -61,7 +61,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	//static bool isAccessible(BattleHex hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS
 	int getAvaliableHex(CreatureID creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects
 	//void makeBFS(BattleHex start, bool*accessibility, BattleHex *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result
-	std::pair< std::vector<BattleHex>, int > getPath(BattleHex start, BattleHex dest, const CStack *stack); //returned value: pair<path, length>; length may be different than number of elements in path since flying vreatures jump between distant hexes
+	std::pair< std::vector<BattleHex>, int > getPath(BattleHex start, BattleHex dest, const CStack * stack); //returned value: pair<path, length>; length may be different than number of elements in path since flying vreatures jump between distant hexes
 	//std::vector<BattleHex> getAccessibility(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = nullptr, bool forPassingBy = false) const; //returns vector of accessible tiles (taking into account the creature range)
 
 	//bool isObstacleVisibleForSide(const CObstacleInstance &obstacle, ui8 side) const;
@@ -69,7 +69,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	std::set<BattleHex> getStoppers(bool whichSidePerspective) const;
 
 	ui32 calculateDmg(const CStack * attacker, const CStack * defender, bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg, CRandomGenerator & rand); //charge - number of hexes travelled before attack (for champion's jousting)
-	void calculateCasualties(std::map<ui32,si32> *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount)
+	void calculateCasualties(std::map<ui32,si32> * casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount)
 
 	//void getPotentiallyAttackableHexes(AttackableTiles &at, const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos); //hexes around target that could be attacked in melee
 	//std::set<CStack*> getAttackedCreatures(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos = BattleHex::INVALID); //calculates range of multi-hex attacks
@@ -84,7 +84,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	void localInit();
 
 	void localInitStack(CStack * s);
-	static BattleInfo * setupBattle( int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town );
+	static BattleInfo * setupBattle(int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance * armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance * town);
 	//bool hasNativeStack(ui8 side) const;
 
 	PlayerColor theOtherPlayer(PlayerColor player) const;

+ 61 - 70
lib/battle/CBattleInfoCallback.cpp

@@ -15,11 +15,9 @@
 #include "spells/CSpellHandler.h"
 #include "mapObjects/CGTownInstance.h"
 
-#define RETURN_IF_NOT_BATTLE(X) if(!duringBattle()) {logGlobal->errorStream() << __FUNCTION__ << " called when no battle!"; return X; }
-
-namespace SiegeStuffThatShouldBeMovedToHandlers //  <=== TODO
+namespace SiegeStuffThatShouldBeMovedToHandlers // <=== TODO
 {
-static void retreiveTurretDamageRange(const CGTownInstance * town, const CStack *turret, double &outMinDmg, double &outMaxDmg)
+static void retreiveTurretDamageRange(const CGTownInstance * town, const CStack * turret, double & outMinDmg, double & outMaxDmg)
 {
 	assert(turret->getCreature()->idNumber == CreatureID::ARROW_TOWERS);
 	assert(town);
@@ -55,17 +53,17 @@ static bool sameSideOfWall(BattleHex pos1, BattleHex pos2)
 // parts of wall
 static const std::pair<int, EWallPart::EWallPart> wallParts[] =
 {
-	std::make_pair(50,  EWallPart::KEEP),
+	std::make_pair(50, EWallPart::KEEP),
 	std::make_pair(183, EWallPart::BOTTOM_TOWER),
 	std::make_pair(182, EWallPart::BOTTOM_WALL),
 	std::make_pair(130, EWallPart::BELOW_GATE),
-	std::make_pair(78,  EWallPart::OVER_GATE),
-	std::make_pair(29,  EWallPart::UPPER_WALL),
-	std::make_pair(12,  EWallPart::UPPER_TOWER),
-	std::make_pair(95,  EWallPart::INDESTRUCTIBLE_PART_OF_GATE),
-	std::make_pair(96,  EWallPart::GATE),
-	std::make_pair(45,  EWallPart::INDESTRUCTIBLE_PART),
-	std::make_pair(62,  EWallPart::INDESTRUCTIBLE_PART),
+	std::make_pair(78, EWallPart::OVER_GATE),
+	std::make_pair(29, EWallPart::UPPER_WALL),
+	std::make_pair(12, EWallPart::UPPER_TOWER),
+	std::make_pair(95, EWallPart::INDESTRUCTIBLE_PART_OF_GATE),
+	std::make_pair(96, EWallPart::GATE),
+	std::make_pair(45, EWallPart::INDESTRUCTIBLE_PART),
+	std::make_pair(62, EWallPart::INDESTRUCTIBLE_PART),
 	std::make_pair(112, EWallPart::INDESTRUCTIBLE_PART),
 	std::make_pair(147, EWallPart::INDESTRUCTIBLE_PART),
 	std::make_pair(165, EWallPart::INDESTRUCTIBLE_PART)
@@ -101,7 +99,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
 	RETURN_IF_NOT_BATTLE(ESpellCastProblem::INVALID);
 	if(caster == nullptr)
 	{
-		logGlobal->errorStream() << "CBattleInfoCallback::battleCanCastSpell: no spellcaster.";
+		logGlobal->error("CBattleInfoCallback::battleCanCastSpell: no spellcaster.");
 		return ESpellCastProblem::INVALID;
 	}
 	const PlayerColor player = caster->getOwner();
@@ -139,12 +137,12 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
 	return ESpellCastProblem::OK;
 }
 
-si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, BattleHex destHex ) const
+si8 CBattleInfoCallback::battleHasWallPenalty(const CStack * stack, BattleHex destHex) const
 {
 	return battleHasWallPenalty(stack, stack->position, destHex);
 }
 
-si8 CBattleInfoCallback::battleHasWallPenalty(const IBonusBearer *bonusBearer, BattleHex shooterPosition, BattleHex destHex) const
+si8 CBattleInfoCallback::battleHasWallPenalty(const IBonusBearer * bonusBearer, BattleHex shooterPosition, BattleHex destHex) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 	if (!battleGetSiegeLevel() || bonusBearer->hasBonusOfType(Bonus::NO_WALL_PENALTY))
@@ -184,7 +182,7 @@ si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, BattleHex des
 	return true;
 }
 
-std::set<BattleHex> CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos  /*= BattleHex::INVALID*/) const
+std::set<BattleHex> CBattleInfoCallback::battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos /*= BattleHex::INVALID*/) const
 {
 	std::set<BattleHex> attackedHexes;
 	RETURN_IF_NOT_BATTLE(attackedHexes);
@@ -242,7 +240,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 	//let's define a huge lambda
 	auto takeStack = [&](std::vector<const CStack *> &st) -> const CStack*
 	{
-		const CStack *ret = nullptr;
+		const CStack * ret = nullptr;
 		unsigned i, //fastest stack
 				j=0; //fastest stack of the other side
 		for(i = 0; i < st.size(); i++)
@@ -253,7 +251,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 		if(i == st.size())
 			return nullptr;
 
-		const CStack *fastest = st[i], *other = nullptr;
+		const CStack * fastest = st[i], *other = nullptr;
 		int bestSpeed = fastest->Speed(turn);
 
 		//FIXME: comparison between bool and integer. Logic does not makes sense either
@@ -301,7 +299,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 	// [3] - rest of waited cres
 	std::vector<const CStack *> phase[4];
 	int toMove = 0; //how many stacks still has move
-	const CStack *active = battleActiveStack();
+	const CStack * active = battleActiveStack();
 
 	//active stack hasn't taken any action yet - must be placed at the beginning of queue, no matter what
 	if(!turn && active && active->willMove() && !active->waited())
@@ -322,8 +320,8 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 	for(auto s : battleGetAllStacks(true))
 	{
 		if((turn <= 0 && !s->willMove()) //we are considering current round and stack won't move
-		   || (turn > 0 && !s->canMove(turn)) //stack won't be able to move in later rounds
-		   || (turn <= 0 && s == active && out.size() && s == out.front())) //it's active stack already added at the beginning of queue
+		|| (turn > 0 && !s->canMove(turn)) //stack won't be able to move in later rounds
+		|| (turn <= 0 && s == active && out.size() && s == out.front())) //it's active stack already added at the beginning of queue
 		{
 			continue;
 		}
@@ -336,7 +334,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 			else
 				p = 3;
 		}
-		else if(s->getCreature()->idNumber == CreatureID::CATAPULT  ||  s->getCreature()->idNumber == CreatureID::ARROW_TOWERS) //catapult and turrets are first
+		else if(s->getCreature()->idNumber == CreatureID::CATAPULT || s->getCreature()->idNumber == CreatureID::ARROW_TOWERS) //catapult and turrets are first
 		{
 			p = 0;
 		}
@@ -377,7 +375,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 	int pi = 1;
 	while(out.size() < howMany)
 	{
-		const CStack *hlp = takeStack(phase[pi]);
+		const CStack * hlp = takeStack(phase[pi]);
 		if(!hlp)
 		{
 			pi++;
@@ -450,11 +448,11 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetAvailableHexes(const CStack
 			// Return true if given hex has at least one available neighbour.
 			// Available hexes are already present in ret vector.
 			auto availableNeighbor = boost::find_if(ret, [=] (BattleHex availableHex)
-			{  return BattleHex::mutualPosition(hex, availableHex) >= 0;  });
-
+			{
+				return BattleHex::mutualPosition(hex, availableHex) >= 0;
+			});
 			return availableNeighbor != ret.end();
 		};
-
 		for(const CStack * otherSt : battleAliveStacks(stack->attackerOwned))
 		{
 			if(!otherSt->isValidTarget(false))
@@ -512,7 +510,7 @@ bool CBattleInfoCallback::battleCanShoot(const CStack * stack, BattleHex dest) c
 	if(battleTacticDist()) //no shooting during tactics
 		return false;
 
-	const CStack *dst = battleGetStackByPos(dest);
+	const CStack * dst = battleGetStackByPos(dest);
 
 	if(!stack || !dst)
 		return false;
@@ -532,11 +530,11 @@ bool CBattleInfoCallback::battleCanShoot(const CStack * stack, BattleHex dest) c
 		return false;
 
 	if(stack->hasBonusOfType(Bonus::SHOOTER)//it's shooter
-	   && battleMatchOwner(stack, dst)
-	   && dst->alive()
-	   && (!battleIsStackBlocked(stack)  ||  stack->hasBonusOfType(Bonus::FREE_SHOOTING))
-	   && stack->shots
-	   )
+	&& battleMatchOwner(stack, dst)
+	&& dst->alive()
+	&& (!battleIsStackBlocked(stack) || stack->hasBonusOfType(Bonus::FREE_SHOOTING))
+	&& stack->shots
+	)
 		return true;
 	return false;
 }
@@ -547,7 +545,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const CStack* attacker, const C
 	return calculateDmgRange(attacker, defender, attacker->count, shooting, charge, lucky, unlucky, deathBlow, ballistaDoubleDmg);
 }
 
-TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) const
+TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo & info) const
 {
 	auto battleBonusValue = [&](const IBonusBearer * bearer, CSelector selector) -> int
 	{
@@ -603,9 +601,9 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 		{
 			for(const std::shared_ptr<Bonus> b : VLC->creh->creatures[g]->getBonusList())
 			{
-				if ( (b->type == Bonus::KING3 && spLevel >= 3) || //expert
+				if ((b->type == Bonus::KING3 && spLevel >= 3) || //expert
 					 (b->type == Bonus::KING2 && spLevel >= 2) || //adv +
-					 (b->type == Bonus::KING1 && spLevel >= 0) ) //none or basic +
+					 (b->type == Bonus::KING1 && spLevel >= 0)) //none or basic +
 				{
 					affectedIds.push_back(g);
 					break;
@@ -635,12 +633,10 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 		additiveBonus += inc;
 	}
 
-
 	//applying jousting bonus
-	if( info.attackerBonuses->hasBonusOfType(Bonus::JOUSTING) && !info.defenderBonuses->hasBonusOfType(Bonus::CHARGE_IMMUNITY) )
+	if(info.attackerBonuses->hasBonusOfType(Bonus::JOUSTING) && !info.defenderBonuses->hasBonusOfType(Bonus::CHARGE_IMMUNITY))
 		additiveBonus += info.chargedFields * 0.05;
 
-
 	//handling secondary abilities and artifacts giving premies to them
 	if(info.shooting)
 		additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARCHERY) / 100.0;
@@ -743,7 +739,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 
 	// psychic elementals versus mind immune units 50%
 	if(attackerType->idNumber == CreatureID::PSYCHIC_ELEMENTAL
-	   && info.defenderBonuses->hasBonusOfType(Bonus::MIND_IMMUNITY))
+	&& info.defenderBonuses->hasBonusOfType(Bonus::MIND_IMMUNITY))
 	{
 		multBonus *= 0.5;
 	}
@@ -764,11 +760,11 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 	else if(blessEffects->size()) //bless handling
 	{
 		maxDmg += curseBlessAdditiveModifier;
-		returnedVal =  std::make_pair(int(maxDmg), int(maxDmg));
+		returnedVal = std::make_pair(int(maxDmg), int(maxDmg));
 	}
 	else
 	{
-		returnedVal =  std::make_pair(int(minDmg), int(maxDmg));
+		returnedVal = std::make_pair(int(minDmg), int(maxDmg));
 	}
 
 	//damage cannot be less than 1
@@ -778,8 +774,8 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 	return returnedVal;
 }
 
-TDmgRange CBattleInfoCallback::calculateDmgRange( const CStack* attacker, const CStack* defender, TQuantity attackerCount,
-												  bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg ) const
+TDmgRange CBattleInfoCallback::calculateDmgRange(const CStack* attacker, const CStack* defender, TQuantity attackerCount,
+												bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg) const
 {
 	BattleAttackInfo bai(attacker, defender, shooting);
 	bai.attackerCount = attackerCount;
@@ -799,7 +795,7 @@ TDmgRange CBattleInfoCallback::battleEstimateDamage(CRandomGenerator & rand, con
 	return battleEstimateDamage(rand, bai, retaliationDmg);
 }
 
-std::pair<ui32, ui32> CBattleInfoCallback::battleEstimateDamage(CRandomGenerator & rand, const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg /*= nullptr*/) const
+std::pair<ui32, ui32> CBattleInfoCallback::battleEstimateDamage(CRandomGenerator & rand, const BattleAttackInfo & bai, std::pair<ui32, ui32> * retaliationDmg /*= nullptr*/) const
 {
 	RETURN_IF_NOT_BATTLE(std::make_pair(0, 0));
 
@@ -840,7 +836,7 @@ std::shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleO
 	for(auto &obs : battleGetAllObstacles())
 	{
 		if(vstd::contains(obs->getBlockedTiles(), tile)
-		   || (!onlyBlocking  &&  vstd::contains(obs->getAffectedTiles(), tile)))
+		|| (!onlyBlocking && vstd::contains(obs->getAffectedTiles(), tile)))
 		{
 			return obs;
 		}
@@ -864,7 +860,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 	//gate -> should be before stacks
 	if(battleGetSiegeLevel() > 0)
 	{
-		EAccessibility::EAccessibility accessability = EAccessibility::ACCESSIBLE;
+		EAccessibility accessability = EAccessibility::ACCESSIBLE;
 		switch(battleGetGateState())
 		{
 		case EGateState::CLOSED:
@@ -920,12 +916,12 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 	return ret;
 }
 
-AccessibilityInfo CBattleInfoCallback::getAccesibility(const CStack *stack) const
+AccessibilityInfo CBattleInfoCallback::getAccesibility(const CStack * stack) const
 {
 	return getAccesibility(stack->getHexes());
 }
 
-AccessibilityInfo CBattleInfoCallback::getAccesibility(const std::vector<BattleHex> &accessibleHexes) const
+AccessibilityInfo CBattleInfoCallback::getAccesibility(const std::vector<BattleHex> & accessibleHexes) const
 {
 	auto ret = getAccesibility();
 	for(auto hex : accessibleHexes)
@@ -935,7 +931,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility(const std::vector<BattleH
 	return ret;
 }
 
-ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibility, const ReachabilityInfo::Parameters &params) const
+ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibility, const ReachabilityInfo::Parameters & params) const
 {
 	ReachabilityInfo ret;
 	ret.accessibility = accessibility;
@@ -950,7 +946,6 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
 	const std::set<BattleHex> quicksands = getStoppers(params.perspective);
 	//const bool twoHexCreature = params.doubleWide;
 
-
 	std::queue<BattleHex> hexq; //bfs queue
 
 	//first element
@@ -973,7 +968,7 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
 			const bool accessible = accessibility.accessible(neighbour, params.doubleWide, params.attackerOwned);
 			const int costFoundSoFar = ret.distances[neighbour];
 
-			if(accessible  &&  costToNeighbour < costFoundSoFar)
+			if(accessible && costToNeighbour < costFoundSoFar)
 			{
 				hexq.push(neighbour);
 				ret.distances[neighbour] = costToNeighbour;
@@ -985,7 +980,7 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
 	return ret;
 }
 
-ReachabilityInfo CBattleInfoCallback::makeBFS(const CStack *stack) const
+ReachabilityInfo CBattleInfoCallback::makeBFS(const CStack * stack) const
 {
 	return makeBFS(getAccesibility(stack), ReachabilityInfo::Parameters(stack));
 }
@@ -1016,7 +1011,7 @@ std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const
 	{
 		int distanceToPred;
 		BattleHex destination;
-		const CStack *stack;
+		const CStack * stack;
 	};
 
 	std::vector<DistStack> stackPairs;
@@ -1155,7 +1150,7 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
 		case -WN: //-17 //left-up or right-up
 		case WN + 1: //18 //right-down
 		case -WN + 1: //-16 //right-up
-			BattleHex::checkAndPush (destinationTile.hex + pseudoVector + (((hex/WN)%2) ? 1 : -1 ), hexes);
+			BattleHex::checkAndPush (destinationTile.hex + pseudoVector + (((hex/WN)%2) ? 1 : -1), hexes);
 			break;
 		case WN-1: //16 //left-down
 		case -WN-1: //-18 //left-up
@@ -1234,7 +1229,7 @@ bool CBattleInfoCallback::isToReverseHlp (BattleHex hexFrom, BattleHex hexTo, bo
 //TODO: this should apply also to mechanics and cursor interface
 bool CBattleInfoCallback::isToReverse (BattleHex hexFrom, BattleHex hexTo, bool curDir, bool toDoubleWide, bool toDir) const
 {
-	if (hexTo < 0  ||  hexFrom < 0) //turret
+	if (hexTo < 0 || hexFrom < 0) //turret
 		return false;
 
 	if (toDoubleWide)
@@ -1291,7 +1286,6 @@ si8 CBattleInfoCallback::battleHasDistancePenalty(const IBonusBearer *bonusBeare
 		for(auto hex : dstStack->getHexes())
 			if(BattleHex::getDistance(shooterPosition, hex) <= GameConstants::BATTLE_PENALTY_DISTANCE)
 				return false;
-
 		//TODO what about two-hex shooters?
 	}
 	else
@@ -1319,7 +1313,7 @@ bool CBattleInfoCallback::isWallPartPotentiallyAttackable(EWallPart::EWallPart w
 {
 	RETURN_IF_NOT_BATTLE(false);
 	return wallPart != EWallPart::INDESTRUCTIBLE_PART && wallPart != EWallPart::INDESTRUCTIBLE_PART_OF_GATE &&
-																	 wallPart != EWallPart::INVALID;
+																	wallPart != EWallPart::INVALID;
 }
 
 std::vector<BattleHex> CBattleInfoCallback::getAttackableBattleHexes() const
@@ -1354,14 +1348,13 @@ ui32 CBattleInfoCallback::battleGetSpellCost(const CSpell * sp, const CGHeroInst
 	si32 manaReduction = 0;
 	si32 manaIncrease = 0;
 
-
 	for(auto stack : battleAliveStacks())
 	{
-		if(stack->owner == caster->tempOwner  &&  stack->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ALLY) )
+		if(stack->owner == caster->tempOwner && stack->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ALLY))
 		{
 			vstd::amax(manaReduction, stack->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ALLY));
 		}
-		if( stack->owner != caster->tempOwner  &&  stack->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ENEMY) )
+		if(stack->owner != caster->tempOwner && stack->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ENEMY))
 		{
 			vstd::amax(manaIncrease, stack->valOfBonuses(Bonus::CHANGES_SPELL_COST_FOR_ENEMY));
 		}
@@ -1375,9 +1368,7 @@ const CStack * CBattleInfoCallback::getStackIf(std::function<bool(const CStack*)
 	RETURN_IF_NOT_BATTLE(nullptr);
 	auto stacks = battleGetAllStacks();
 	auto stackItr = range::find_if(stacks, pred);
-	return stackItr == stacks.end()
-			? nullptr
-			: *stackItr;
+	return stackItr == stacks.end() ? nullptr : *stackItr;
 }
 
 si8 CBattleInfoCallback::battleHasShootingPenalty(const CStack * stack, BattleHex destHex)
@@ -1392,7 +1383,7 @@ bool CBattleInfoCallback::battleIsStackBlocked(const CStack * stack) const
 	if(stack->hasBonusOfType(Bonus::SIEGE_WEAPON)) //siege weapons cannot be blocked
 		return false;
 
-	for(const CStack * s :  batteAdjacentCreatures(stack))
+	for(const CStack * s : batteAdjacentCreatures(stack))
 	{
 		if (s->owner != stack->owner) //blocked by enemy stack
 			return true;
@@ -1406,7 +1397,7 @@ std::set<const CStack*> CBattleInfoCallback:: batteAdjacentCreatures(const CStac
 	RETURN_IF_NOT_BATTLE(stacks);
 
 	for (BattleHex hex : stack->getSurroundingHexes())
-		if(const CStack *neighbour = battleGetStackByPos(hex, true))
+		if(const CStack * neighbour = battleGetStackByPos(hex, true))
 			stacks.insert(neighbour);
 
 	return stacks;
@@ -1442,7 +1433,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
 	};
 	std::vector<SpellID> beneficialSpells;
 
-	auto getAliveEnemy = [=](const std::function<bool(const CStack * )> & pred)
+	auto getAliveEnemy = [=](const std::function<bool(const CStack *)> & pred)
 	{
 		return getStackIf([=](const CStack * stack)
 		{
@@ -1456,8 +1447,8 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
 		cachingStr << "source_" << Bonus::SPELL_EFFECT << "id_" << spellID.num;
 
 		if(subject->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellID), Selector::all, cachingStr.str())
-		   //TODO: this ability has special limitations
-		   || spellID.toSpell()->canBeCastAt(this, subject, ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK)
+		 //TODO: this ability has special limitations
+		|| spellID.toSpell()->canBeCastAt(this, subject, ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK)
 			continue;
 
 		switch (spellID)
@@ -1518,7 +1509,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
 			break;
 		case SpellID::SLAYER://only if monsters are present
 		{
-			auto kingMonster = getAliveEnemy([&](const CStack *stack) -> bool //look for enemy, non-shooting stack
+			auto kingMonster = getAliveEnemy([&](const CStack * stack) -> bool //look for enemy, non-shooting stack
 			{
 				const auto isKing = Selector::type(Bonus::KING1)
 									.Or(Selector::type(Bonus::KING2))
@@ -1586,7 +1577,7 @@ int CBattleInfoCallback::battleGetSurrenderCost(PlayerColor Player) const
 		if(s->base) //we pay for our stack that comes from our army slots - condition eliminates summoned cres and war machines
 			ret += s->getCreature()->cost[Res::GOLD] * s->count;
 
-	if(const CGHeroInstance *h = battleGetFightingHero(playerSide))
+	if(const CGHeroInstance * h = battleGetFightingHero(playerSide))
 		discount += h->valOfBonuses(Bonus::SURRENDER_DISCOUNT);
 
 	ret *= (100.0 - discount) / 100.0;

+ 13 - 17
lib/battle/CBattleInfoCallback.h

@@ -30,7 +30,6 @@ struct DLL_LINKAGE AttackableTiles
 	}
 };
 
-
 class DLL_LINKAGE CBattleInfoCallback : public virtual CBattleInfoEssentials
 {
 public:
@@ -38,7 +37,6 @@ public:
 	{
 		RANDOM_GENIE, RANDOM_AIMED
 	};
-
 	//battle
 	boost::optional<int> battleIsFinished() const; //return none if battle is ongoing; otherwise the victorious side (0/1) or 2 if it is a draw
 
@@ -47,7 +45,6 @@ public:
 	void battleGetStackQueue(std::vector<const CStack *> &out, const int howMany, const int turn = 0, int lastMoved = -1) const;
 	void battleGetStackCountOutsideHexes(bool *ac) const; // returns hexes which when in front of a stack cause us to move the amount box back
 
-
 	std::vector<BattleHex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = nullptr) const; //returns hexes reachable by creature with id ID (valid movement destinations), DOES contain stack current position
 
 	int battleGetSurrenderCost(PlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible
@@ -57,19 +54,19 @@ public:
 	bool battleCanAttack(const CStack * stack, const CStack * target, BattleHex dest) const; //determines if stack with given ID can attack target at the selected destination
 	bool battleCanShoot(const CStack * stack, BattleHex dest) const; //determines if stack with given ID shoot at the selected destination
 	bool battleIsStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack
-	std::set<const CStack*>  batteAdjacentCreatures (const CStack * stack) const;
+	std::set<const CStack*> batteAdjacentCreatures (const CStack * stack) const;
 
-	TDmgRange calculateDmgRange(const BattleAttackInfo &info) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
+	TDmgRange calculateDmgRange(const BattleAttackInfo & info) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
 	TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, TQuantity attackerCount, bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
 	TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
 
-	//hextowallpart  //int battleGetWallUnderHex(BattleHex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
-	std::pair<ui32, ui32> battleEstimateDamage(CRandomGenerator & rand, const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg = nullptr) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
+	//hextowallpart //int battleGetWallUnderHex(BattleHex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
+	std::pair<ui32, ui32> battleEstimateDamage(CRandomGenerator & rand, const BattleAttackInfo & bai, std::pair<ui32, ui32> * retaliationDmg = nullptr) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
 	std::pair<ui32, ui32> battleEstimateDamage(CRandomGenerator & rand, const CStack * attacker, const CStack * defender, std::pair<ui32, ui32> * retaliationDmg = nullptr) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
-	si8 battleHasDistancePenalty( const CStack * stack, BattleHex destHex ) const;
-	si8 battleHasDistancePenalty(const IBonusBearer *bonusBearer, BattleHex shooterPosition, BattleHex destHex ) const;
+	si8 battleHasDistancePenalty(const CStack * stack, BattleHex destHex) const;
+	si8 battleHasDistancePenalty(const IBonusBearer * bonusBearer, BattleHex shooterPosition, BattleHex destHex) const;
 	si8 battleHasWallPenalty(const CStack * stack, BattleHex destHex) const; //checks if given stack has wall penalty
-	si8 battleHasWallPenalty(const IBonusBearer *bonusBearer, BattleHex shooterPosition, BattleHex destHex) const; //checks if given stack has wall penalty
+	si8 battleHasWallPenalty(const IBonusBearer * bonusBearer, BattleHex shooterPosition, BattleHex destHex) const; //checks if given stack has wall penalty
 
 	BattleHex wallPartToBattleHex(EWallPart::EWallPart part) const;
 	EWallPart::EWallPart battleHexToWallPart(BattleHex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
@@ -90,9 +87,8 @@ public:
 	si8 battleHasShootingPenalty(const CStack * stack, BattleHex destHex);
 	si8 battleCanTeleportTo(const CStack * stack, BattleHex destHex, int telportLevel) const; //checks if teleportation of given stack to given position can take place
 
-
 	//convenience methods using the ones above
-	bool isInTacticRange( BattleHex dest ) const;
+	bool isInTacticRange(BattleHex dest) const;
 	si8 battleGetTacticDist() const; //returns tactic distance for calling player or 0 if this player is not in tactic phase (for ALL_KNOWING actual distance for tactic side)
 
 	AttackableTiles getPotentiallyAttackableHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos) const; //TODO: apply rotation to two-hex attacker
@@ -101,14 +97,14 @@ public:
 	bool isToReverseHlp(BattleHex hexFrom, BattleHex hexTo, bool curDir) const; //helper for isToReverse
 
 	ReachabilityInfo getReachability(const CStack *stack) const;
-	ReachabilityInfo getReachability(const ReachabilityInfo::Parameters &params) const;
+	ReachabilityInfo getReachability(const ReachabilityInfo::Parameters & params) const;
 	AccessibilityInfo getAccesibility() const;
 	AccessibilityInfo getAccesibility(const CStack *stack) const; //Hexes ocupied by stack will be marked as accessible.
-	AccessibilityInfo getAccesibility(const std::vector<BattleHex> &accessibleHexes) const; //given hexes will be marked as accessible
+	AccessibilityInfo getAccesibility(const std::vector<BattleHex> & accessibleHexes) const; //given hexes will be marked as accessible
 	std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const;
 protected:
-	ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters &params) const;
-	ReachabilityInfo makeBFS(const AccessibilityInfo &accessibility, const ReachabilityInfo::Parameters &params) const;
-	ReachabilityInfo makeBFS(const CStack *stack) const; //uses default parameters -> stack position and owner's perspective
+	ReachabilityInfo getFlyingReachability(const ReachabilityInfo::Parameters & params) const;
+	ReachabilityInfo makeBFS(const AccessibilityInfo & accessibility, const ReachabilityInfo::Parameters & params) const;
+	ReachabilityInfo makeBFS(const CStack * stack) const; //uses default parameters -> stack position and owner's perspective
 	std::set<BattleHex> getStoppers(BattlePerspective::BattlePerspective whichSidePerspective) const; //get hexes with stopping obstacles (quicksands)
 };

+ 8 - 18
lib/battle/CBattleInfoEssentials.cpp

@@ -14,8 +14,6 @@
 #include "NetPacks.h"
 #include "mapObjects/CGTownInstance.h"
 
-#define RETURN_IF_NOT_BATTLE(X) if(!duringBattle()) {logGlobal->errorStream() << __FUNCTION__ << " called when no battle!"; return X; }
-
 ETerrainType CBattleInfoEssentials::battleTerrainType() const
 {
 	RETURN_IF_NOT_BATTLE(ETerrainType::WRONG);
@@ -42,7 +40,7 @@ std::vector<std::shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::ba
 	{
 		if(!!player && *perspective != battleGetMySide())
 		{
-			logGlobal->errorStream() << "Unauthorized access attempt!";
+			logGlobal->error("Unauthorized access attempt!");
 			assert(0); //I want to notice if that happens
 			//perspective = battleGetMySide();
 		}
@@ -67,9 +65,9 @@ bool CBattleInfoEssentials::battleHasNativeStack(ui8 side) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 
-	for(const CStack *s : battleGetAllStacks())
+	for(const CStack * s : battleGetAllStacks())
 	{
-		if(s->attackerOwned == !side  &&  s->getCreature()->isItNativeTerrain(getBattle()->terrainType))
+		if(s->attackerOwned == !side && s->getCreature()->isItNativeTerrain(getBattle()->terrainType))
 			return true;
 	}
 
@@ -111,22 +109,17 @@ TStacks CBattleInfoEssentials::battleAliveStacks(ui8 side) const
 int CBattleInfoEssentials::battleGetMoatDmg() const
 {
 	RETURN_IF_NOT_BATTLE(0);
-
 	auto town = getBattle()->town;
 	if(!town)
 		return 0;
-
 	return town->town->moatDamage;
 }
 
 const CGTownInstance * CBattleInfoEssentials::battleGetDefendedTown() const
 {
 	RETURN_IF_NOT_BATTLE(nullptr);
-
-
 	if(!getBattle() || getBattle()->town == nullptr)
 		return nullptr;
-
 	return getBattle()->town;
 }
 
@@ -169,7 +162,7 @@ bool CBattleInfoEssentials::battleDoWeKnowAbout(ui8 side) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 	auto p = battleGetMySide();
-	return p == BattlePerspective::ALL_KNOWING  ||  p == side;
+	return p == BattlePerspective::ALL_KNOWING || p == side;
 }
 
 si8 CBattleInfoEssentials::battleTacticDist() const
@@ -210,17 +203,15 @@ const CArmedInstance * CBattleInfoEssentials::battleGetArmyObject(ui8 side) cons
 		logGlobal->errorStream() << "FIXME: " <<  __FUNCTION__ << " wrong argument!";
 		return nullptr;
 	}
-
 	if(!battleDoWeKnowAbout(side))
 	{
 		logGlobal->errorStream() << "FIXME: " <<  __FUNCTION__ << " access check ";
 		return nullptr;
 	}
-
 	return getBattle()->sides[side].armyObject;
 }
 
-InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo( ui8 side ) const
+InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo(ui8 side) const
 {
 	auto hero = getBattle()->sides[side].hero;
 	if(!hero)
@@ -228,7 +219,6 @@ InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo( ui8 side ) const
 		logGlobal->warnStream() << __FUNCTION__ << ": side " << (int)side << " does not have hero!";
 		return InfoAboutHero();
 	}
-
 	InfoAboutHero::EInfoLevel infoLevel = battleDoWeKnowAbout(side) ? InfoAboutHero::EInfoLevel::DETAILED : InfoAboutHero::EInfoLevel::BASIC;
 	return InfoAboutHero(hero, infoLevel);
 }
@@ -259,7 +249,7 @@ bool CBattleInfoEssentials::battleCanFlee(PlayerColor player) const
 		return false;
 
 	//we are besieged defender
-	if(mySide == BattleSide::DEFENDER  &&  battleGetSiegeLevel())
+	if(mySide == BattleSide::DEFENDER && battleGetSiegeLevel())
 	{
 		auto town = battleGetDefendedTown();
 		if(!town->hasBuilt(BuildingID::ESCAPE_TUNNEL, ETownType::STRONGHOLD))
@@ -301,7 +291,7 @@ bool CBattleInfoEssentials::battleCanSurrender(PlayerColor player) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 	ui8 mySide = playerToSide(player);
-	bool iAmSiegeDefender = ( mySide == BattleSide::DEFENDER  &&  battleGetSiegeLevel() );
+	bool iAmSiegeDefender = (mySide == BattleSide::DEFENDER && battleGetSiegeLevel());
 	//conditions like for fleeing (except escape tunnel presence) + enemy must have a hero
 	return battleCanFlee(player) && !iAmSiegeDefender && battleHasHero(!mySide);
 }
@@ -353,7 +343,7 @@ bool CBattleInfoEssentials::battleMatchOwner(const CStack * attacker, const CSta
 	if(boost::logic::indeterminate(positivness))
 		return true;
 	else if(defender->owner != battleGetOwner(defender))
-		return true;//mind controlled unit is attackable for both sides
+		return true; //mind controlled unit is attackable for both sides
 	else
 		return (battleGetOwner(attacker) == battleGetOwner(defender)) == positivness;
 }

+ 8 - 8
lib/battle/CBattleInfoEssentials.h

@@ -23,18 +23,18 @@ typedef std::function<bool(const CStack *)> TStackFilter;
 
 namespace BattlePerspective
 {
-enum BattlePerspective
-{
-	INVALID = -2,
-	ALL_KNOWING = -1,
-	LEFT_SIDE,
-	RIGHT_SIDE
-};
+	enum BattlePerspective
+	{
+		INVALID = -2,
+		ALL_KNOWING = -1,
+		LEFT_SIDE,
+		RIGHT_SIDE
+	};
 }
 
 namespace BattleSide
 {
-enum {ATTACKER = 0, DEFENDER = 1};
+	enum {ATTACKER = 0, DEFENDER = 1};
 }
 
 

+ 1 - 1
lib/battle/CCallbackBase.cpp

@@ -30,7 +30,7 @@ CCallbackBase::CCallbackBase()
 	: battle(nullptr), gs(nullptr)
 {}
 
-void CCallbackBase::setBattle(const BattleInfo *B)
+void CCallbackBase::setBattle(const BattleInfo * B)
 {
 	battle = B;
 }

+ 6 - 4
lib/battle/CCallbackBase.h

@@ -10,6 +10,8 @@
 #pragma once
 #include "GameConstants.h"
 
+#define RETURN_IF_NOT_BATTLE(X) if(!duringBattle()) {logGlobal->errorStream() << __FUNCTION__ << " called when no battle!"; return X; }
+
 class CGameState;
 struct BattleInfo;
 
@@ -18,18 +20,18 @@ class CBattleInfoEssentials;
 //Basic class for various callbacks (interfaces called by players to get info about game and so forth)
 class DLL_LINKAGE CCallbackBase
 {
-	const BattleInfo *battle; //battle to which the player is engaged, nullptr if none or not applicable
+	const BattleInfo * battle; //battle to which the player is engaged, nullptr if none or not applicable
 
 	const BattleInfo * getBattle() const;
 
 protected:
-	CGameState *gs;
+	CGameState * gs;
 	boost::optional<PlayerColor> player; // not set gives access to all information, otherwise callback provides only information "visible" for player
 
-	CCallbackBase(CGameState *GS, boost::optional<PlayerColor> Player);
+	CCallbackBase(CGameState * GS, boost::optional<PlayerColor> Player);
 	CCallbackBase();
 
-	void setBattle(const BattleInfo *B);
+	void setBattle(const BattleInfo * B);
 	bool duringBattle() const;
 
 public:

+ 4 - 4
lib/battle/CObstacleInstance.cpp

@@ -69,7 +69,7 @@ std::vector<BattleHex> CObstacleInstance::getAffectedTiles() const
 
 // bool CObstacleInstance::spellGenerated() const
 // {
-// 	if(obstacleType == USUAL  ||  obstacleType == ABSOLUTE_OBSTACLE)
+// 	if(obstacleType == USUAL || obstacleType == ABSOLUTE_OBSTACLE)
 // 		return false;
 //
 // 	return true;
@@ -83,12 +83,12 @@ bool CObstacleInstance::visibleForSide(ui8 side, bool hasNativeStack) const
 
 bool CObstacleInstance::stopsMovement() const
 {
-	return obstacleType == QUICKSAND  ||  obstacleType == MOAT;
+	return obstacleType == QUICKSAND || obstacleType == MOAT;
 }
 
 bool CObstacleInstance::blocksTiles() const
 {
-	return obstacleType == USUAL  ||  obstacleType == ABSOLUTE_OBSTACLE  ||  obstacleType == FORCE_FIELD;
+	return obstacleType == USUAL || obstacleType == ABSOLUTE_OBSTACLE || obstacleType == FORCE_FIELD;
 }
 
 SpellCreatedObstacle::SpellCreatedObstacle()
@@ -113,7 +113,7 @@ bool SpellCreatedObstacle::visibleForSide(ui8 side, bool hasNativeStack) const
 		//we hide mines and not discovered quicksands
 		//quicksands are visible to the caster or if owned unit stepped into that particular patch
 		//additionally if side has a native unit, mines/quicksands will be visible
-		return casterSide == side  ||  visibleForAnotherSide  ||  hasNativeStack;
+		return casterSide == side || visibleForAnotherSide || hasNativeStack;
 	default:
 		assert(0);
 		return false;

+ 2 - 3
lib/battle/CPlayerBattleCallback.cpp

@@ -11,7 +11,6 @@
 #include "CPlayerBattleCallback.h"
 #include "CStack.h"
 #include "CGameState.h"
-#define RETURN_IF_NOT_BATTLE(X) if(!duringBattle()) {logGlobal->errorStream() << __FUNCTION__ << " called when no battle!"; return X; }
 
 bool CPlayerBattleCallback::battleCanFlee() const
 {
@@ -29,8 +28,8 @@ TStacks CPlayerBattleCallback::battleGetStacks(EStackOwnership whose /*= MINE_AN
 
 	return battleGetStacksIf([=](const CStack * s){
 		const bool ownerMatches = (whose == MINE_AND_ENEMY)
-								  || (whose == ONLY_MINE && s->owner == player)
-								  || (whose == ONLY_ENEMY && s->owner != player);
+								|| (whose == ONLY_MINE && s->owner == player)
+								|| (whose == ONLY_ENEMY && s->owner != player);
 
 		return ownerMatches && s->isValidTarget(!onlyAlive);
 	});

+ 1 - 1
lib/battle/ReachabilityInfo.cpp

@@ -20,7 +20,7 @@ ReachabilityInfo::Parameters::Parameters()
 	attackerOwned = doubleWide = flying = false;
 }
 
-ReachabilityInfo::Parameters::Parameters(const CStack *Stack)
+ReachabilityInfo::Parameters::Parameters(const CStack * Stack)
 {
 	stack = Stack;
 	perspective = (BattlePerspective::BattlePerspective)(!Stack->attackerOwned);

+ 3 - 3
lib/battle/ReachabilityInfo.h

@@ -21,11 +21,11 @@ struct DLL_LINKAGE ReachabilityInfo
 	typedef std::array<int, GameConstants::BFIELD_SIZE> TDistances;
 	typedef std::array<BattleHex, GameConstants::BFIELD_SIZE> TPredecessors;
 
-	enum { 	INFINITE_DIST = 1000000 };
+	enum { INFINITE_DIST = 1000000 };
 
 	struct DLL_LINKAGE Parameters
 	{
-		const CStack *stack; //stack for which calculation is mage => not required (kept for debugging mostly), following variables are enough
+		const CStack * stack; //stack for which calculation is mage => not required (kept for debugging mostly), following variables are enough
 
 		bool attackerOwned;
 		bool doubleWide;
@@ -36,7 +36,7 @@ struct DLL_LINKAGE ReachabilityInfo
 		BattlePerspective::BattlePerspective perspective; //some obstacles (eg. quicksands) may be invisible for some side
 
 		Parameters();
-		Parameters(const CStack *Stack);
+		Parameters(const CStack * Stack);
 	};
 
 	Parameters params;