diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 29fb18520..28ceb437a 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -24,6 +24,15 @@ #include "CRandomGenerator.h" #include "mapObjects/CGTownInstance.h" +SiegeInfo::SiegeInfo() +{ + for (int i = 0; i < wallState.size(); ++i) + { + wallState[i] = EWallState::NONE; + } + gateState = EGateState::NONE; +} + const CStack * BattleInfo::getNextStack() const { std::vector hlp; @@ -280,7 +289,7 @@ struct RangeGenerator 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; + auto curB = new BattleInfo(); for(auto i = 0u; i < curB->sides.size(); i++) curB->sides[i].init(heroes[i], armies[i]); @@ -722,6 +731,9 @@ CStack * BattleInfo::getStack(int stackID, bool onlyAlive /*= true*/) } BattleInfo::BattleInfo() + : round(-1), activeStack(-1), selectedStack(-1), town(nullptr), tile(-1,-1,-1), + battlefieldType(BFieldType::NONE), terrainType(ETerrainType::WRONG), + tacticsSide(0), tacticDistance(0) { setBattle(this); setNodeType(BATTLE); @@ -739,7 +751,8 @@ CGHeroInstance * BattleInfo::battleGetFightingHero(ui8 side) const CStack::CStack(const CStackInstance *Base, PlayerColor O, int I, bool AO, SlotID S) : base(Base), ID(I), owner(O), slot(S), attackerOwned(AO), - counterAttacksPerformed(0),counterAttacksTotalCache(0), cloneID(-1) + counterAttacksPerformed(0),counterAttacksTotalCache(0), cloneID(-1), + firstHPleft(-1), position(), shots(0), casts(0), resurrected(0) { assert(base); type = base->type; @@ -752,8 +765,9 @@ CStack::CStack() setNodeType(STACK_BATTLE); } CStack::CStack(const CStackBasicDescriptor *stack, PlayerColor O, int I, bool AO, SlotID S) - : base(nullptr), ID(I), owner(O), slot(S), attackerOwned(AO), counterAttacksPerformed(0), - cloneID(-1) + : base(nullptr), ID(I), owner(O), slot(S), attackerOwned(AO), + counterAttacksPerformed(0), counterAttacksTotalCache(0), cloneID(-1), + firstHPleft(-1), position(), shots(0), casts(0), resurrected(0) { type = stack->type; count = baseAmount = stack->count; @@ -774,6 +788,10 @@ void CStack::init() counterAttacksPerformed = 0; counterAttacksTotalCache = 0; cloneID = -1; + + shots = 0; + casts = 0; + resurrected = 0; } void CStack::postInit() @@ -1267,6 +1285,7 @@ CMP_stack::CMP_stack( int Phase /*= 1*/, int Turn ) SideInBattle::SideInBattle() { + color = PlayerColor::CANNOT_DETERMINE; hero = nullptr; armyObject = nullptr; castSpellsCount = 0; diff --git a/lib/BattleState.h b/lib/BattleState.h index 50791764f..31db8f997 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -35,6 +35,8 @@ struct DLL_LINKAGE SiegeInfo std::array wallState; EGateState gateState; + SiegeInfo(); + // return EWallState decreased by value of damage points static EWallState::EWallState applyDamage(EWallState::EWallState state, unsigned int value) { diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index aa25131fa..8012b12c5 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -177,6 +177,7 @@ static void AddAbility(CCreature *cre, const JsonVector &ability_vec) } CCreatureHandler::CCreatureHandler() + : expAfterUpgrade(0) { VLC->creh = this;