1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Fix crash with objects belonging players without state

This commit is contained in:
nordsoft
2022-11-06 03:26:13 +04:00
parent ae1d2c50e2
commit 0f35082024
15 changed files with 92 additions and 88 deletions

View File

@ -82,13 +82,14 @@ void CStack::localInit(BattleInfo * battleInfo)
exportBonuses();
if(base) //stack originating from "real" stack in garrison -> attach to it
{
attachTo(const_cast<CStackInstance *>(base));
attachTo(const_cast<CStackInstance&>(*base));
}
else //attach directly to obj to which stack belongs and creature type
{
CArmedInstance * army = battle->battleGetArmyObject(side);
attachTo(army);
attachTo(const_cast<CCreature *>(type));
assert(army);
attachTo(*army);
attachTo(const_cast<CCreature&>(*type));
}
nativeTerrain = type->getNativeTerrain(); //save nativeTerrain in the variable on the battle start to avoid dead lock
CUnitState::localInit(this); //it causes execution of the CStack::isOnNativeTerrain where nativeTerrain will be considered