mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Fix stackinstance deserialization
This commit is contained in:
@ -859,9 +859,6 @@ PlayerColor CStackInstance::getOwner() const
|
|||||||
|
|
||||||
void CStackInstance::deserializationFix()
|
void CStackInstance::deserializationFix()
|
||||||
{
|
{
|
||||||
const CCreature *backup = type;
|
|
||||||
type = nullptr;
|
|
||||||
setType(backup);
|
|
||||||
const CArmedInstance *armyBackup = _armyObj;
|
const CArmedInstance *armyBackup = _armyObj;
|
||||||
_armyObj = nullptr;
|
_armyObj = nullptr;
|
||||||
setArmyObj(armyBackup);
|
setArmyObj(armyBackup);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "HeroBonus.h"
|
#include "HeroBonus.h"
|
||||||
#include "GameConstants.h"
|
#include "GameConstants.h"
|
||||||
#include "CArtHandler.h"
|
#include "CArtHandler.h"
|
||||||
|
#include "CCreatureHandler.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -40,7 +41,20 @@ public:
|
|||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & type;
|
if(h.saving)
|
||||||
|
{
|
||||||
|
CreatureID idNumber = type ? type->idNumber : CreatureID(CreatureID::NONE);
|
||||||
|
h & idNumber;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreatureID idNumber;
|
||||||
|
h & idNumber;
|
||||||
|
if(idNumber != CreatureID::NONE)
|
||||||
|
setType(VLC->creh->objects[idNumber]);
|
||||||
|
else
|
||||||
|
type = nullptr;
|
||||||
|
}
|
||||||
h & count;
|
h & count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user