1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Improve formatting, update other config information about includes.

This commit is contained in:
FeniksFire 2017-06-26 18:50:35 +02:00
parent 4113bdab01
commit 8ccdda6d2d
22 changed files with 226 additions and 204 deletions

View File

@ -125,16 +125,28 @@
<Unit filename="../Version.h" /> <Unit filename="../Version.h" />
<Unit filename="../include/vstd/CLoggerBase.h" /> <Unit filename="../include/vstd/CLoggerBase.h" />
<Unit filename="AI_Base.h" /> <Unit filename="AI_Base.h" />
<Unit filename="BattleAction.cpp" /> <Unit filename="battle/BattleAction.cpp" />
<Unit filename="BattleAction.h" /> <Unit filename="battle/BattleAction.h" />
<Unit filename="BattleHex.cpp" /> <Unit filename="battle/BattleHex.cpp" />
<Unit filename="BattleHex.h" /> <Unit filename="battle/BattleHex.h" />
<Unit filename="BattleInfo.cpp" /> <Unit filename="battle/BattleInfo.cpp" />
<Unit filename="BattleInfo.h" /> <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.cpp" />
<Unit filename="CArtHandler.h" /> <Unit filename="CArtHandler.h" />
<Unit filename="CBattleCallback.cpp" />
<Unit filename="CBattleCallback.h" />
<Unit filename="CBonusTypeHandler.cpp" /> <Unit filename="CBonusTypeHandler.cpp" />
<Unit filename="CBonusTypeHandler.h" /> <Unit filename="CBonusTypeHandler.h" />
<Unit filename="CBuildingHandler.cpp" /> <Unit filename="CBuildingHandler.cpp" />
@ -161,8 +173,8 @@
<Unit filename="CMakeLists.txt" /> <Unit filename="CMakeLists.txt" />
<Unit filename="CModHandler.cpp" /> <Unit filename="CModHandler.cpp" />
<Unit filename="CModHandler.h" /> <Unit filename="CModHandler.h" />
<Unit filename="CObstacleInstance.cpp" /> <Unit filename="battle/CObstacleInstance.cpp" />
<Unit filename="CObstacleInstance.h" /> <Unit filename="battle/CObstacleInstance.h" />
<Unit filename="CPathfinder.cpp" /> <Unit filename="CPathfinder.cpp" />
<Unit filename="CPathfinder.h" /> <Unit filename="CPathfinder.h" />
<Unit filename="CPlayerState.h" /> <Unit filename="CPlayerState.h" />

View File

@ -168,9 +168,16 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="BattleAction.cpp" /> <ClCompile Include="battle\BattleAction.cpp" />
<ClCompile Include="BattleHex.cpp" /> <ClCompile Include="battle\BattleHex.cpp" />
<ClCompile Include="BattleInfo.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="CArtHandler.cpp" />
<ClCompile Include="CBonusTypeHandler.cpp" /> <ClCompile Include="CBonusTypeHandler.cpp" />
<ClCompile Include="CBuildingHandler.cpp" /> <ClCompile Include="CBuildingHandler.cpp" />
@ -183,7 +190,7 @@
<ClCompile Include="CGeneralTextHandler.cpp" /> <ClCompile Include="CGeneralTextHandler.cpp" />
<ClCompile Include="CHeroHandler.cpp" /> <ClCompile Include="CHeroHandler.cpp" />
<ClCompile Include="CModHandler.cpp" /> <ClCompile Include="CModHandler.cpp" />
<ClCompile Include="CObstacleInstance.cpp" /> <ClCompile Include="battle\CObstacleInstance.cpp" />
<ClCompile Include="CPathfinder.cpp" /> <ClCompile Include="CPathfinder.cpp" />
<ClCompile Include="CStack.cpp" /> <ClCompile Include="CStack.cpp" />
<ClCompile Include="CThreadHelper.cpp" /> <ClCompile Include="CThreadHelper.cpp" />
@ -262,7 +269,6 @@
<ClCompile Include="logging\CLogger.cpp" /> <ClCompile Include="logging\CLogger.cpp" />
<ClCompile Include="logging\CBasicLogConfigurator.cpp" /> <ClCompile Include="logging\CBasicLogConfigurator.cpp" />
<ClCompile Include="HeroBonus.cpp" /> <ClCompile Include="HeroBonus.cpp" />
<ClCompile Include="CBattleCallback.cpp" />
<ClCompile Include="IGameCallback.cpp" /> <ClCompile Include="IGameCallback.cpp" />
<ClCompile Include="CGameInfoCallback.cpp" /> <ClCompile Include="CGameInfoCallback.cpp" />
<ClCompile Include="JsonNode.cpp" /> <ClCompile Include="JsonNode.cpp" />
@ -290,9 +296,16 @@
<ClInclude Include="..\Global.h" /> <ClInclude Include="..\Global.h" />
<ClInclude Include="..\Version.h" /> <ClInclude Include="..\Version.h" />
<ClInclude Include="AI_Base.h" /> <ClInclude Include="AI_Base.h" />
<ClInclude Include="BattleAction.h" /> <ClInclude Include="battle\BattleAction.h" />
<ClInclude Include="BattleHex.h" /> <ClInclude Include="battle\BattleHex.h" />
<ClInclude Include="BattleInfo.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="CArtHandler.h" />
<ClInclude Include="CBonusTypeHandler.h" /> <ClInclude Include="CBonusTypeHandler.h" />
<ClInclude Include="CBuildingHandler.h" /> <ClInclude Include="CBuildingHandler.h" />
@ -306,7 +319,7 @@
<ClInclude Include="CGeneralTextHandler.h" /> <ClInclude Include="CGeneralTextHandler.h" />
<ClInclude Include="CHeroHandler.h" /> <ClInclude Include="CHeroHandler.h" />
<ClInclude Include="CModHandler.h" /> <ClInclude Include="CModHandler.h" />
<ClInclude Include="CObstacleInstance.h" /> <ClInclude Include="battle\CObstacleInstance.h" />
<ClInclude Include="CondSh.h" /> <ClInclude Include="CondSh.h" />
<ClInclude Include="ConstTransitivePtr.h" /> <ClInclude Include="ConstTransitivePtr.h" />
<ClInclude Include="CPathfinder.h" /> <ClInclude Include="CPathfinder.h" />
@ -376,7 +389,6 @@
<ClInclude Include="logging\CBasicLogConfigurator.h" /> <ClInclude Include="logging\CBasicLogConfigurator.h" />
<ClInclude Include="GameConstants.h" /> <ClInclude Include="GameConstants.h" />
<ClInclude Include="HeroBonus.h" /> <ClInclude Include="HeroBonus.h" />
<ClInclude Include="CBattleCallback.h" />
<ClInclude Include="IGameCallback.h" /> <ClInclude Include="IGameCallback.h" />
<ClInclude Include="CGameInfoCallback.h" /> <ClInclude Include="CGameInfoCallback.h" />
<ClInclude Include="IGameEventsReceiver.h" /> <ClInclude Include="IGameEventsReceiver.h" />

View File

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

View File

@ -40,7 +40,6 @@ bool AccessibilityInfo::occupiable(const CStack *stack, BattleHex tile) const
//obviously, we can occupy tile by standing on it //obviously, we can occupy tile by standing on it
if(accessible(tile, stack)) if(accessible(tile, stack))
return true; return true;
if(stack->doubleWide()) if(stack->doubleWide())
{ {
//Check the tile next to -> if stack stands there, it'll also occupy considered hex //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)) if(accessible(anotherTile, stack))
return true; return true;
} }
return false; return false;
} }

View File

@ -13,9 +13,7 @@
class CStack; class CStack;
//Accessibility is property of hex in battle. It doesn't depend on stack, side's perspective and so on. //Accessibility is property of hex in battle. It doesn't depend on stack, side's perspective and so on.
namespace EAccessibility enum class EAccessibility
{
enum EAccessibility
{ {
ACCESSIBLE, ACCESSIBLE,
ALIVE_STACK, ALIVE_STACK,
@ -25,9 +23,9 @@ enum EAccessibility
UNAVAILABLE, //indestructible wall parts, special battlefields (like boat-to-boat) 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 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 struct DLL_LINKAGE AccessibilityInfo : TAccessibilityArray
{ {

View File

@ -15,8 +15,6 @@
#include "spells/CSpellHandler.h" #include "spells/CSpellHandler.h"
#include "mapObjects/CGTownInstance.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)
@ -101,7 +99,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
RETURN_IF_NOT_BATTLE(ESpellCastProblem::INVALID); RETURN_IF_NOT_BATTLE(ESpellCastProblem::INVALID);
if(caster == nullptr) if(caster == nullptr)
{ {
logGlobal->errorStream() << "CBattleInfoCallback::battleCanCastSpell: no spellcaster."; logGlobal->error("CBattleInfoCallback::battleCanCastSpell: no spellcaster.");
return ESpellCastProblem::INVALID; return ESpellCastProblem::INVALID;
} }
const PlayerColor player = caster->getOwner(); const PlayerColor player = caster->getOwner();
@ -450,11 +448,11 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetAvailableHexes(const CStack
// Return true if given hex has at least one available neighbour. // Return true if given hex has at least one available neighbour.
// Available hexes are already present in ret vector. // Available hexes are already present in ret vector.
auto availableNeighbor = boost::find_if(ret, [=] (BattleHex availableHex) auto availableNeighbor = boost::find_if(ret, [=] (BattleHex availableHex)
{ return BattleHex::mutualPosition(hex, availableHex) >= 0; }); {
return BattleHex::mutualPosition(hex, availableHex) >= 0;
});
return availableNeighbor != ret.end(); return availableNeighbor != ret.end();
}; };
for(const CStack * otherSt : battleAliveStacks(stack->attackerOwned)) for(const CStack * otherSt : battleAliveStacks(stack->attackerOwned))
{ {
if(!otherSt->isValidTarget(false)) if(!otherSt->isValidTarget(false))
@ -635,12 +633,10 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
additiveBonus += inc; additiveBonus += inc;
} }
//applying jousting bonus //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; additiveBonus += info.chargedFields * 0.05;
//handling secondary abilities and artifacts giving premies to them //handling secondary abilities and artifacts giving premies to them
if(info.shooting) if(info.shooting)
additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARCHERY) / 100.0; additiveBonus += info.attackerBonuses->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ARCHERY) / 100.0;
@ -864,7 +860,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
//gate -> should be before stacks //gate -> should be before stacks
if(battleGetSiegeLevel() > 0) if(battleGetSiegeLevel() > 0)
{ {
EAccessibility::EAccessibility accessability = EAccessibility::ACCESSIBLE; EAccessibility accessability = EAccessibility::ACCESSIBLE;
switch(battleGetGateState()) switch(battleGetGateState())
{ {
case EGateState::CLOSED: case EGateState::CLOSED:
@ -950,7 +946,6 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
const std::set<BattleHex> quicksands = getStoppers(params.perspective); const std::set<BattleHex> quicksands = getStoppers(params.perspective);
//const bool twoHexCreature = params.doubleWide; //const bool twoHexCreature = params.doubleWide;
std::queue<BattleHex> hexq; //bfs queue std::queue<BattleHex> hexq; //bfs queue
//first element //first element
@ -1291,7 +1286,6 @@ si8 CBattleInfoCallback::battleHasDistancePenalty(const IBonusBearer *bonusBeare
for(auto hex : dstStack->getHexes()) for(auto hex : dstStack->getHexes())
if(BattleHex::getDistance(shooterPosition, hex) <= GameConstants::BATTLE_PENALTY_DISTANCE) if(BattleHex::getDistance(shooterPosition, hex) <= GameConstants::BATTLE_PENALTY_DISTANCE)
return false; return false;
//TODO what about two-hex shooters? //TODO what about two-hex shooters?
} }
else else
@ -1354,7 +1348,6 @@ ui32 CBattleInfoCallback::battleGetSpellCost(const CSpell * sp, const CGHeroInst
si32 manaReduction = 0; si32 manaReduction = 0;
si32 manaIncrease = 0; si32 manaIncrease = 0;
for(auto stack : battleAliveStacks()) 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))
@ -1375,9 +1368,7 @@ const CStack * CBattleInfoCallback::getStackIf(std::function<bool(const CStack*)
RETURN_IF_NOT_BATTLE(nullptr); RETURN_IF_NOT_BATTLE(nullptr);
auto stacks = battleGetAllStacks(); auto stacks = battleGetAllStacks();
auto stackItr = range::find_if(stacks, pred); auto stackItr = range::find_if(stacks, pred);
return stackItr == stacks.end() return stackItr == stacks.end() ? nullptr : *stackItr;
? nullptr
: *stackItr;
} }
si8 CBattleInfoCallback::battleHasShootingPenalty(const CStack * stack, BattleHex destHex) si8 CBattleInfoCallback::battleHasShootingPenalty(const CStack * stack, BattleHex destHex)

View File

@ -30,7 +30,6 @@ struct DLL_LINKAGE AttackableTiles
} }
}; };
class DLL_LINKAGE CBattleInfoCallback : public virtual CBattleInfoEssentials class DLL_LINKAGE CBattleInfoCallback : public virtual CBattleInfoEssentials
{ {
public: public:
@ -38,7 +37,6 @@ public:
{ {
RANDOM_GENIE, RANDOM_AIMED RANDOM_GENIE, RANDOM_AIMED
}; };
//battle //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 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 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 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 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 int battleGetSurrenderCost(PlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible
@ -90,7 +87,6 @@ public:
si8 battleHasShootingPenalty(const CStack * stack, BattleHex destHex); 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 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 //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) 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)

View File

@ -14,8 +14,6 @@
#include "NetPacks.h" #include "NetPacks.h"
#include "mapObjects/CGTownInstance.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 ETerrainType CBattleInfoEssentials::battleTerrainType() const
{ {
RETURN_IF_NOT_BATTLE(ETerrainType::WRONG); RETURN_IF_NOT_BATTLE(ETerrainType::WRONG);
@ -42,7 +40,7 @@ std::vector<std::shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::ba
{ {
if(!!player && *perspective != battleGetMySide()) if(!!player && *perspective != battleGetMySide())
{ {
logGlobal->errorStream() << "Unauthorized access attempt!"; logGlobal->error("Unauthorized access attempt!");
assert(0); //I want to notice if that happens assert(0); //I want to notice if that happens
//perspective = battleGetMySide(); //perspective = battleGetMySide();
} }
@ -111,22 +109,17 @@ TStacks CBattleInfoEssentials::battleAliveStacks(ui8 side) const
int CBattleInfoEssentials::battleGetMoatDmg() const int CBattleInfoEssentials::battleGetMoatDmg() const
{ {
RETURN_IF_NOT_BATTLE(0); RETURN_IF_NOT_BATTLE(0);
auto town = getBattle()->town; auto town = getBattle()->town;
if(!town) if(!town)
return 0; return 0;
return town->town->moatDamage; return town->town->moatDamage;
} }
const CGTownInstance * CBattleInfoEssentials::battleGetDefendedTown() const const CGTownInstance * CBattleInfoEssentials::battleGetDefendedTown() const
{ {
RETURN_IF_NOT_BATTLE(nullptr); RETURN_IF_NOT_BATTLE(nullptr);
if(!getBattle() || getBattle()->town == nullptr) if(!getBattle() || getBattle()->town == nullptr)
return nullptr; return nullptr;
return getBattle()->town; return getBattle()->town;
} }
@ -210,13 +203,11 @@ const CArmedInstance * CBattleInfoEssentials::battleGetArmyObject(ui8 side) cons
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!"; logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " wrong argument!";
return nullptr; return nullptr;
} }
if(!battleDoWeKnowAbout(side)) if(!battleDoWeKnowAbout(side))
{ {
logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check "; logGlobal->errorStream() << "FIXME: " << __FUNCTION__ << " access check ";
return nullptr; return nullptr;
} }
return getBattle()->sides[side].armyObject; return getBattle()->sides[side].armyObject;
} }
@ -228,7 +219,6 @@ InfoAboutHero CBattleInfoEssentials::battleGetHeroInfo( ui8 side ) const
logGlobal->warnStream() << __FUNCTION__ << ": side " << (int)side << " does not have hero!"; logGlobal->warnStream() << __FUNCTION__ << ": side " << (int)side << " does not have hero!";
return InfoAboutHero(); return InfoAboutHero();
} }
InfoAboutHero::EInfoLevel infoLevel = battleDoWeKnowAbout(side) ? InfoAboutHero::EInfoLevel::DETAILED : InfoAboutHero::EInfoLevel::BASIC; InfoAboutHero::EInfoLevel infoLevel = battleDoWeKnowAbout(side) ? InfoAboutHero::EInfoLevel::DETAILED : InfoAboutHero::EInfoLevel::BASIC;
return InfoAboutHero(hero, infoLevel); return InfoAboutHero(hero, infoLevel);
} }

View File

@ -10,6 +10,8 @@
#pragma once #pragma once
#include "GameConstants.h" #include "GameConstants.h"
#define RETURN_IF_NOT_BATTLE(X) if(!duringBattle()) {logGlobal->errorStream() << __FUNCTION__ << " called when no battle!"; return X; }
class CGameState; class CGameState;
struct BattleInfo; struct BattleInfo;

View File

@ -11,7 +11,6 @@
#include "CPlayerBattleCallback.h" #include "CPlayerBattleCallback.h"
#include "CStack.h" #include "CStack.h"
#include "CGameState.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 bool CPlayerBattleCallback::battleCanFlee() const
{ {