1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-03 14:52:11 +02:00

More fixes for uninitialized fields part 2

This commit is contained in:
Arseniy Shestakov 2016-08-19 00:13:12 +03:00
parent ab06cfd586
commit bf6ad4e783
3 changed files with 26 additions and 4 deletions

View File

@ -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<const CStack *> 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;

View File

@ -35,6 +35,8 @@ struct DLL_LINKAGE SiegeInfo
std::array<si8, EWallPart::PARTS_COUNT> wallState;
EGateState gateState;
SiegeInfo();
// return EWallState decreased by value of damage points
static EWallState::EWallState applyDamage(EWallState::EWallState state, unsigned int value)
{

View File

@ -177,6 +177,7 @@ static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
}
CCreatureHandler::CCreatureHandler()
: expAfterUpgrade(0)
{
VLC->creh = this;