1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00

Serialize new field with new save format

This commit is contained in:
Tomasz Zieliński 2022-09-06 15:53:32 +02:00
parent dad4520b18
commit b817e6509b
3 changed files with 13 additions and 5 deletions

View File

@ -234,7 +234,7 @@ CMapHeader::~CMapHeader()
CMap::CMap()
: checksum(0), grailPos(-1, -1, -1), grailRadius(0), terrain(nullptr),
guardingCreaturePositions(nullptr),
uid_counter(0)
uidCounter(0)
{
allHeroes.resize(allowedHeroes.size());
allowedAbilities = VLC->skillh->getDefaultAllowed();
@ -608,7 +608,7 @@ void CMap::setUniqueInstanceName(CGObjectInstance* obj)
{
//this gives object unique name even if objects are removed later
auto uid = uid_counter++;
auto uid = uidCounter++;
boost::format fmt("%s_%d");
fmt % obj->typeName % uid;

View File

@ -412,7 +412,7 @@ public:
private:
/// a 3-dimensional array of terrain tiles, access is as follows: x, y, level. where level=1 is underground
TerrainTile*** terrain;
si32 uid_counter; //TODO: initialize when loading an old map
si32 uidCounter; //TODO: initialize when loading an old map
public:
template <typename Handler>
@ -490,6 +490,14 @@ public:
h & CGTownInstance::universitySkills;
h & instanceNames;
h & uid_counter;
if (!h.saving && formatVersion < 804)
{
uidCounter = objects.size();
}
else
{
h & uidCounter;
}
}
};

View File

@ -12,7 +12,7 @@
#include "../ConstTransitivePtr.h"
#include "../GameConstants.h"
const ui32 SERIALIZATION_VERSION = 803;
const ui32 SERIALIZATION_VERSION = 804;
const ui32 MINIMAL_SERIALIZATION_VERSION = 803;
const std::string SAVEGAME_MAGIC = "VCMISVG";