1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Remove save compatibility with 1.5.X

This commit is contained in:
Ivan Savenko
2025-03-18 11:35:15 +00:00
parent 81759143f4
commit eb3b51a6cf
27 changed files with 86 additions and 542 deletions

View File

@ -94,17 +94,7 @@ public:
{ {
h & static_cast<CBonusSystemNode&>(*this); h & static_cast<CBonusSystemNode&>(*this);
h & static_cast<CCombinedArtifactInstance&>(*this); h & static_cast<CCombinedArtifactInstance&>(*this);
if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) h & artTypeID;
{
h & artTypeID;
}
else
{
bool isNull = false;
h & isNull;
if (!isNull)
h & artTypeID;
}
h & id; h & id;
BONUS_TREE_DESERIALIZATION_FIX BONUS_TREE_DESERIALIZATION_FIX
} }

View File

@ -121,24 +121,8 @@ public:
h & resources; h & resources;
h & status; h & status;
h & turnTimer; h & turnTimer;
h & *playerLocalSettings;
if (h.version >= Handler::Version::LOCAL_PLAYER_STATE_DATA) h & ownedObjects;
h & *playerLocalSettings;
if (h.version >= Handler::Version::PLAYER_STATE_OWNED_OBJECTS)
{
h & ownedObjects;
}
else
{
std::vector<const CGObjectInstance* > heroes;
std::vector<const CGObjectInstance* > towns;
std::vector<const CGObjectInstance* > dwellings;
h & heroes;
h & towns;
h & dwellings;
}
h & quests; h & quests;
h & visitedObjects; h & visitedObjects;
h & visitedObjectsGlobal; h & visitedObjectsGlobal;
@ -173,23 +157,9 @@ public:
{ {
h & id; h & id;
h & players; h & players;
if (h.version < Handler::Version::REMOVE_FOG_OF_WAR_POINTER)
{
struct Helper : public Serializeable
{
void serialize(Handler &h) const
{}
};
Helper helper;
auto ptrHelper = &helper;
h & ptrHelper;
}
h & fogOfWarMap; h & fogOfWarMap;
h & static_cast<CBonusSystemNode&>(*this); h & static_cast<CBonusSystemNode&>(*this);
h & scoutedObjects;
if (h.version >= Handler::Version::REWARDABLE_BANKS)
h & scoutedObjects;
} }
}; };

View File

@ -51,11 +51,7 @@ struct DLL_LINKAGE SimturnsInfo
h & requiredTurns; h & requiredTurns;
h & optionalTurns; h & optionalTurns;
h & allowHumanWithAI; h & allowHumanWithAI;
h & ignoreAlliedContacts;
if (h.version >= Handler::Version::SAVE_COMPATIBILITY_FIXES)
h & ignoreAlliedContacts;
else
ignoreAlliedContacts = true;
} }
}; };
@ -108,14 +104,7 @@ struct DLL_LINKAGE PlayerSettings
h & heroNameTextId; h & heroNameTextId;
h & bonus; h & bonus;
h & color; h & color;
if (h.version >= Handler::Version::PLAYER_HANDICAP) h & handicap;
h & handicap;
else
{
enum EHandicap {NO_HANDICAP, MILD, SEVERE};
EHandicap handicapLegacy = NO_HANDICAP;
h & handicapLegacy;
}
h & name; h & name;
h & connectedPlayerIDs; h & connectedPlayerIDs;
h & compOnly; h & compOnly;
@ -173,24 +162,7 @@ struct DLL_LINKAGE StartInfo : public Serializeable
h & mode; h & mode;
h & difficulty; h & difficulty;
h & playerInfos; h & playerInfos;
if (h.version < Handler::Version::REMOVE_LIB_RNG) h & startTime;
{
uint32_t oldSeeds = 0;
h & oldSeeds;
h & oldSeeds;
h & oldSeeds;
}
if (h.version < Handler::Version::FOLDER_NAME_REWORK)
{
std::string startTimeLegacy;
h & startTimeLegacy;
struct std::tm tm;
std::istringstream ss(startTimeLegacy);
ss >> std::get_time(&tm, "%Y%m%dT%H%M%S");
startTime = mktime(&tm);
}
else
h & startTime;
h & fileURI; h & fileURI;
h & simturnsInfo; h & simturnsInfo;
h & turnTimerInfo; h & turnTimerInfo;

View File

@ -108,16 +108,7 @@ public:
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & static_cast<ILimiter&>(*this); h & static_cast<ILimiter&>(*this);
h & creatureID;
if (h.version < Handler::Version::REMOVE_TOWN_PTR)
{
bool isNull = false;
h & isNull;
if(!isNull)
h & creatureID;
}
else
h & creatureID;
h & includeUpgrades; h & includeUpgrades;
} }
}; };

View File

@ -46,16 +46,8 @@ class DLL_LINKAGE CampaignRegions
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & infix; h & infix;
if (h.version >= Handler::Version::REGION_LABEL) h & pos;
{ h & labelPos;
h & pos;
h & labelPos;
}
else
{
h & pos.x;
h & pos.y;
}
} }
static CampaignRegions::RegionDescription fromJson(const JsonNode & node); static CampaignRegions::RegionDescription fromJson(const JsonNode & node);
@ -79,11 +71,8 @@ public:
h & campPrefix; h & campPrefix;
h & colorSuffixLength; h & colorSuffixLength;
h & regions; h & regions;
if (h.version >= Handler::Version::CAMPAIGN_REGIONS) h & campSuffix;
{ h & campBackground;
h & campSuffix;
h & campBackground;
}
} }
static CampaignRegions fromJson(const JsonNode & node); static CampaignRegions fromJson(const JsonNode & node);
@ -150,27 +139,20 @@ public:
h & numberOfScenarios; h & numberOfScenarios;
h & name; h & name;
h & description; h & description;
if (h.version >= Handler::Version::MAP_FORMAT_ADDITIONAL_INFOS) h & author;
{ h & authorContact;
h & author; h & campaignVersion;
h & authorContact; h & creationDateTime;
h & campaignVersion;
h & creationDateTime;
}
h & difficultyChosenByPlayer; h & difficultyChosenByPlayer;
h & filename; h & filename;
h & modName; h & modName;
h & music; h & music;
h & encoding; h & encoding;
h & textContainer; h & textContainer;
if (h.version >= Handler::Version::CHRONICLES_SUPPORT) h & loadingBackground;
{ h & videoRim;
h & loadingBackground; h & introVideo;
h & videoRim; h & outroVideo;
h & introVideo;
}
if (h.version >= Handler::Version::CAMPAIGN_OUTRO_SUPPORT)
h & outroVideo;
} }
}; };
@ -374,8 +356,7 @@ public:
h & chosenCampaignBonuses; h & chosenCampaignBonuses;
h & campaignSet; h & campaignSet;
h & mapTranslations; h & mapTranslations;
if (h.version >= Handler::Version::HIGHSCORE_PARAMETERS) h & highscoreParameters;
h & highscoreParameters;
} }
}; };

View File

@ -351,15 +351,6 @@ void CGameState::initCampaign()
map = campaign->getCurrentMap(); map = campaign->getCurrentMap();
} }
void CGameState::generateOwnedObjectsAfterDeserialize()
{
for (auto & object : map->objects)
{
if (object && object->asOwnable() && object->getOwner().isValidPlayer())
players.at(object->getOwner()).addOwnedObject(object.get());
}
}
void CGameState::initGlobalBonuses() void CGameState::initGlobalBonuses()
{ {
const JsonNode & baseBonuses = getSettings().getValue(EGameSettings::BONUSES_GLOBAL); const JsonNode & baseBonuses = getSettings().getValue(EGameSettings::BONUSES_GLOBAL);

View File

@ -171,21 +171,13 @@ public:
h & day; h & day;
h & map; h & map;
h & players; h & players;
if (h.version < Handler::Version::PLAYER_STATE_OWNED_OBJECTS)
generateOwnedObjectsAfterDeserialize();
h & teams; h & teams;
h & heroesPool; h & heroesPool;
h & globalEffects; h & globalEffects;
if (h.version < Handler::Version::REMOVE_LIB_RNG)
{
std::string oldStateOfRNG;
h & oldStateOfRNG;
}
h & currentRumor; h & currentRumor;
h & campaign; h & campaign;
h & allocatedArtifacts; h & allocatedArtifacts;
if (h.version >= Handler::Version::STATISTICS) h & statistic;
h & statistic;
BONUS_TREE_DESERIALIZATION_FIX BONUS_TREE_DESERIALIZATION_FIX
} }
@ -213,8 +205,6 @@ private:
void initVisitingAndGarrisonedHeroes(); void initVisitingAndGarrisonedHeroes();
void initCampaign(); void initCampaign();
void generateOwnedObjectsAfterDeserialize();
// ----- bonus system handling ----- // ----- bonus system handling -----
void buildBonusSystemTree(); void buildBonusSystemTree();

View File

@ -63,8 +63,7 @@ struct DLL_LINKAGE StatisticDataSetEntry
h & timestamp; h & timestamp;
h & day; h & day;
h & player; h & player;
if(h.version >= Handler::Version::STATISTICS_SCREEN) h & playerName;
h & playerName;
h & team; h & team;
h & isHuman; h & isHuman;
h & status; h & status;
@ -92,11 +91,8 @@ struct DLL_LINKAGE StatisticDataSetEntry
h & spentResourcesForArmy; h & spentResourcesForArmy;
h & spentResourcesForBuildings; h & spentResourcesForBuildings;
h & tradeVolume; h & tradeVolume;
if(h.version >= Handler::Version::STATISTICS_SCREEN) h & eventCapturedTown;
{ h & eventDefeatedStrongestHero;
h & eventCapturedTown;
h & eventDefeatedStrongestHero;
}
h & movementPointsUsed; h & movementPointsUsed;
} }
}; };
@ -136,11 +132,8 @@ public:
h & spentResourcesForBuildings; h & spentResourcesForBuildings;
h & tradeVolume; h & tradeVolume;
h & movementPointsUsed; h & movementPointsUsed;
if(h.version >= Handler::Version::STATISTICS_SCREEN) h & lastCapturedTownDay;
{ h & lastDefeatedStrongestHeroDay;
h & lastCapturedTownDay;
h & lastDefeatedStrongestHeroDay;
}
} }
}; };
std::vector<StatisticDataSetEntry> data; std::vector<StatisticDataSetEntry> data;

View File

@ -51,10 +51,7 @@ public:
h & bankConfig; h & bankConfig;
h & resetDuration; h & resetDuration;
h & coastVisitable; h & coastVisitable;
if (h.version >= Handler::Version::BANK_UNIT_PLACEMENT) h & regularUnitPlacement;
h & regularUnitPlacement;
else if (!h.saving)
regularUnitPlacement = false;
} }
friend class CBankInstanceConstructor; friend class CBankInstanceConstructor;

View File

@ -371,14 +371,6 @@ public:
h & skillsInfo; h & skillsInfo;
h & visitedTown; h & visitedTown;
h & boat; h & boat;
if (h.version < Handler::Version::REMOVE_TOWN_PTR)
{
HeroTypeID type;
bool isNull = false;
h & isNull;
if(!isNull)
h & type;
}
h & commander; h & commander;
h & visitedObjects; h & visitedObjects;
BONUS_TREE_DESERIALIZATION_FIX BONUS_TREE_DESERIALIZATION_FIX

View File

@ -36,37 +36,6 @@ public:
int getMarketEfficiency() const override; int getMarketEfficiency() const override;
int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited
std::set<EMarketMode> availableModes() const override; std::set<EMarketMode> availableModes() const override;
template <typename Handler>
void serialize(Handler &h)
{
h & static_cast<CGObjectInstance&>(*this);
if (h.version < Handler::Version::NEW_MARKETS)
{
std::set<EMarketMode> marketModes;
h & marketModes;
}
if (h.version < Handler::Version::MARKET_TRANSLATION_FIX)
{
int unused = 0;
h & unused;
}
if (h.version < Handler::Version::NEW_MARKETS)
{
std::string speech;
std::string title;
h & speech;
h & title;
}
}
template <typename Handler> void serializeArtifactsAltar(Handler &h)
{
serialize(h);
IMarket::serializeArtifactsAltar(h);
}
}; };
class DLL_LINKAGE CGBlackMarket : public CGMarket class DLL_LINKAGE CGBlackMarket : public CGMarket
@ -82,24 +51,7 @@ public:
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & static_cast<CGMarket&>(*this); h & static_cast<CGMarket&>(*this);
if (h.version < Handler::Version::REMOVE_VLC_POINTERS) h & artifacts;
{
int32_t size = 0;
h & size;
for (int32_t i = 0; i < size; ++i)
{
bool isNull = false;
ArtifactID artifact;
h & isNull;
if (!isNull)
h & artifact;
artifacts.push_back(artifact);
}
}
else
{
h & artifacts;
}
} }
}; };
@ -119,12 +71,6 @@ public:
{ {
h & static_cast<CGMarket&>(*this); h & static_cast<CGMarket&>(*this);
h & skills; h & skills;
if (h.version >= Handler::Version::NEW_MARKETS && h.version < Handler::Version::MARKET_TRANSLATION_FIX)
{
std::string temp;
h & temp;
h & temp;
}
} }
}; };

View File

@ -143,12 +143,6 @@ public:
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & instanceName; h & instanceName;
if (h.version < Handler::Version::REMOVE_OBJECT_TYPENAME)
{
std::string unused;
h & unused;
h & unused;
}
h & pos; h & pos;
h & ID; h & ID;
subID.serializeIdentifier(h, ID); subID.serializeIdentifier(h, ID);

View File

@ -94,43 +94,13 @@ public:
h & obligatorySpells; h & obligatorySpells;
h & spells; h & spells;
h & events; h & events;
h & spellResearchCounterDay;
if (h.version >= Handler::Version::SPELL_RESEARCH) h & spellResearchAcceptedCounter;
{ h & spellResearchAllowed;
h & spellResearchCounterDay; h & rewardableBuildings;
h & spellResearchAcceptedCounter;
h & spellResearchAllowed;
}
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS)
{
h & rewardableBuildings;
}
else
{
std::vector<TownRewardableBuildingInstance*> oldVector;
h & oldVector;
rewardableBuildings = convertOldBuildings(oldVector);
}
if (h.version < Handler::Version::REMOVE_TOWN_PTR)
{
FactionID faction;
bool isNull = false;
h & isNull;
if (!isNull)
h & faction;
}
h & townAndVis; h & townAndVis;
BONUS_TREE_DESERIALIZATION_FIX BONUS_TREE_DESERIALIZATION_FIX
if (h.version < Handler::Version::NEW_TOWN_BUILDINGS)
{
std::set<BuildingID> overriddenBuildings;
h & overriddenBuildings;
}
if(!h.saving) if(!h.saving)
postDeserialize(); postDeserialize();
} }

View File

@ -36,11 +36,6 @@ public:
CArtifactSet * getArtifactsStorage() const; CArtifactSet * getArtifactsStorage() const;
bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units
template <typename Handler> void serializeArtifactsAltar(Handler &h)
{
h & *altarArtifactsStorage;
}
private: private:
std::unique_ptr<CArtifactSetAltar> altarArtifactsStorage; std::unique_ptr<CArtifactSetAltar> altarArtifactsStorage;
}; };

View File

@ -43,14 +43,6 @@ public:
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & bID; h & bID;
if (h.version < Handler::Version::NEW_TOWN_BUILDINGS)
{
// compatibility code
si32 indexOnTV = 0; //identifies its index on towns vector
BuildingSubID::EBuildingSubID bType = BuildingSubID::NONE;
h & indexOnTV;
h & bType;
}
} }
private: private:
@ -90,8 +82,7 @@ public:
template <typename Handler> void serialize(Handler &h) template <typename Handler> void serialize(Handler &h)
{ {
h & static_cast<TownBuildingInstance&>(*this); h & static_cast<TownBuildingInstance&>(*this);
if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS) h & static_cast<Rewardable::Interface&>(*this);
h & static_cast<Rewardable::Interface&>(*this);
h & visitors; h & visitors;
} }
}; };

View File

@ -192,31 +192,11 @@ public:
// static members // static members
h & obeliskCount; h & obeliskCount;
h & obelisksVisited; h & obelisksVisited;
h & townMerchantArtifacts;
if (h.version < Handler::Version::REMOVE_VLC_POINTERS)
{
int32_t size = 0;
h & size;
for (int32_t i = 0; i < size; ++i)
{
bool isNull = false;
ArtifactID artifact;
h & isNull;
if (!isNull)
h & artifact;
townMerchantArtifacts.push_back(artifact);
}
}
else
{
h & townMerchantArtifacts;
}
h & townUniversitySkills; h & townUniversitySkills;
h & instanceNames; h & instanceNames;
h & *gameSettings;
if (h.version >= Handler::Version::PER_MAP_GAME_SETTINGS)
h & *gameSettings;
} }
}; };

View File

@ -52,26 +52,12 @@ public:
h & name; h & name;
h & message; h & message;
h & resources; h & resources;
if (h.version >= Handler::Version::EVENTS_PLAYER_SET) h & players;
{
h & players;
}
else
{
ui8 playersMask = 0;
h & playersMask;
for (int i = 0; i < 8; ++i)
if ((playersMask & (1 << i)) != 0)
players.insert(PlayerColor(i));
}
h & humanAffected; h & humanAffected;
h & computerAffected; h & computerAffected;
h & firstOccurrence; h & firstOccurrence;
h & nextOccurrence; h & nextOccurrence;
if(h.version >= Handler::Version::EVENT_OBJECTS_DELETION) h & deletedObjectsInstances;
{
h & deletedObjectsInstances;
}
} }
virtual void serializeJson(JsonSerializeFormat & handler); virtual void serializeJson(JsonSerializeFormat & handler);
@ -147,49 +133,13 @@ struct DLL_LINKAGE TerrainTile
template <typename Handler> template <typename Handler>
void serialize(Handler & h) void serialize(Handler & h)
{ {
if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) h & terrainType;
{
h & terrainType;
}
else
{
bool isNull = false;
h & isNull;
if (!isNull)
h & terrainType;
}
h & terView; h & terView;
if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) h & riverType;
{
h & riverType;
}
else
{
bool isNull = false;
h & isNull;
if (!isNull)
h & riverType;
}
h & riverDir; h & riverDir;
if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) h & roadType;
{
h & roadType;
}
else
{
bool isNull = false;
h & isNull;
if (!isNull)
h & roadType;
}
h & roadDir; h & roadDir;
h & extTileFlags; h & extTileFlags;
if (h.version < Handler::Version::REMOVE_VLC_POINTERS)
{
bool unused = false;
h & unused;
h & unused;
}
h & visitableObjects; h & visitableObjects;
h & blockingObjects; h & blockingObjects;
} }

View File

@ -287,25 +287,14 @@ public:
h & mods; h & mods;
h & name; h & name;
h & description; h & description;
if (h.version >= Handler::Version::MAP_FORMAT_ADDITIONAL_INFOS) h & author;
{ h & authorContact;
h & author; h & mapVersion;
h & authorContact; h & creationDateTime;
h & mapVersion;
h & creationDateTime;
}
h & width; h & width;
h & height; h & height;
h & twoLevel; h & twoLevel;
h & difficulty;
if (h.version >= Handler::Version::SAVE_COMPATIBILITY_FIXES)
h & difficulty;
else
{
uint8_t difficultyInteger = static_cast<uint8_t>(difficulty);
h & difficultyInteger;
difficulty = static_cast<EMapDifficulty>(difficultyInteger);
}
h & levelLimit; h & levelLimit;
h & areAnyPlayers; h & areAnyPlayers;

View File

@ -481,8 +481,7 @@ struct DLL_LINKAGE PlayerEndsGame : public CPackForClient
{ {
h & player; h & player;
h & victoryLossCheckResult; h & victoryLossCheckResult;
if (h.version >= Handler::Version::STATISTICS_SCREEN) h & statistic;
h & statistic;
} }
}; };

View File

@ -194,13 +194,8 @@ struct DLL_LINKAGE Configuration
h & canRefuse; h & canRefuse;
h & showScoutedPreview; h & showScoutedPreview;
h & infoWindowType; h & infoWindowType;
if (h.version >= Handler::Version::REWARDABLE_BANKS) h & coastVisitable;
{ h & guardsLayout;
h & coastVisitable;
h & guardsLayout;
}
else
coastVisitable = false;
} }
}; };

View File

@ -129,8 +129,7 @@ struct DLL_LINKAGE Reward final
h & removeObject; h & removeObject;
h & manaPercentage; h & manaPercentage;
h & movePercentage; h & movePercentage;
if (h.version >= Handler::Version::REWARDABLE_GUARDS) h & guards;
h & guards;
h & heroExperience; h & heroExperience;
h & heroLevel; h & heroLevel;
h & manaDiff; h & manaDiff;

View File

@ -162,10 +162,7 @@ public:
else else
{ {
static_assert(!std::is_same_v<uint64_t, T>, "Serialization of unsigned 64-bit value may not work in some cases"); static_assert(!std::is_same_v<uint64_t, T>, "Serialization of unsigned 64-bit value may not work in some cases");
if (hasFeature(Version::COMPACT_INTEGER_SERIALIZATION)) data = loadEncodedInteger();
data = loadEncodedInteger();
else
this->read(static_cast<void *>(&data), sizeof(data), reverseEndianness);
} }
} }
@ -444,32 +441,23 @@ public:
} }
void load(std::string &data) void load(std::string &data)
{ {
if (hasFeature(Version::COMPACT_STRING_SERIALIZATION)) int32_t length;
{ load(length);
int32_t length;
load(length);
if (length < 0) if (length < 0)
{ {
int32_t stringID = -length - 1; // -1, -2 ... -> 0, 1 ... int32_t stringID = -length - 1; // -1, -2 ... -> 0, 1 ...
data = loadedStrings[stringID]; data = loadedStrings[stringID];
} }
if (length == 0) if (length == 0)
{ {
data = {}; data = {};
} }
if (length > 0) if (length > 0)
{
data.resize(length);
this->read(static_cast<void *>(data.data()), length, false);
loadedStrings.push_back(data);
}
}
else
{ {
uint32_t length = readAndCheckLength();
data.resize(length); data.resize(length);
this->read(static_cast<void *>(data.data()), length, false); this->read(static_cast<void *>(data.data()), length, false);
loadedStrings.push_back(data);
} }
} }

View File

@ -148,10 +148,7 @@ public:
} }
else else
{ {
if (hasFeature(Version::COMPACT_INTEGER_SERIALIZATION)) saveEncodedInteger(data);
saveEncodedInteger(data);
else
this->write(static_cast<const void *>(&data), sizeof(data));
} }
} }
@ -325,36 +322,28 @@ public:
void save(const std::string &data) void save(const std::string &data)
{ {
if (hasFeature(Version::COMPACT_STRING_SERIALIZATION)) if (data.empty())
{ {
if (data.empty()) save(static_cast<uint32_t>(0));
{ return;
save(static_cast<uint32_t>(0));
return;
}
auto it = savedStrings.find(data);
if (it == savedStrings.end())
{
save(static_cast<uint32_t>(data.length()));
this->write(static_cast<const void *>(data.data()), data.size());
// -1, -2...
int32_t newStringID = -1 - savedStrings.size();
savedStrings[data] = newStringID;
}
else
{
int32_t index = it->second;
save(index);
}
} }
else
auto it = savedStrings.find(data);
if (it == savedStrings.end())
{ {
save(static_cast<uint32_t>(data.length())); save(static_cast<uint32_t>(data.length()));
this->write(static_cast<const void *>(data.data()), data.size()); this->write(static_cast<const void *>(data.data()), data.size());
// -1, -2...
int32_t newStringID = -1 - savedStrings.size();
savedStrings[data] = newStringID;
}
else
{
int32_t index = it->second;
save(index);
} }
} }

View File

@ -31,47 +31,8 @@ enum class ESerializationVersion : int32_t
{ {
NONE = 0, NONE = 0,
RELEASE_150 = 840,
MINIMAL = RELEASE_150,
VOTING_SIMTURNS, // 841 - allow modification of simturns duration via vote
REMOVE_TEXT_CONTAINER_SIZE_T, // 842 Fixed serialization of size_t from text containers
BANK_UNIT_PLACEMENT, // 843 Banks have unit placement flag
RELEASE_156 = BANK_UNIT_PLACEMENT,
COMPACT_STRING_SERIALIZATION, // 844 - optimized serialization of previously encountered strings
COMPACT_INTEGER_SERIALIZATION, // 845 - serialize integers in forms similar to protobuf
REMOVE_FOG_OF_WAR_POINTER, // 846 - fog of war is serialized as reference instead of pointer
SIMPLE_TEXT_CONTAINER_SERIALIZATION, // 847 - text container is serialized using common routine instead of custom approach
MAP_FORMAT_ADDITIONAL_INFOS, // 848 - serialize new infos in map format
REMOVE_LIB_RNG, // 849 - removed random number generators from library classes
HIGHSCORE_PARAMETERS, // 850 - saves parameter for campaign
PLAYER_HANDICAP, // 851 - player handicap selection at game start
STATISTICS, // 852 - removed random number generators from library classes
CAMPAIGN_REGIONS, // 853 - configurable campaign regions
EVENTS_PLAYER_SET, // 854 - map & town events use std::set instead of bitmask to store player list
NEW_TOWN_BUILDINGS, // 855 - old bonusing buildings have been removed
STATISTICS_SCREEN, // 856 - extent statistic functions
NEW_MARKETS, // 857 - reworked market classes
PLAYER_STATE_OWNED_OBJECTS, // 858 - player state stores all owned objects in a single list
SAVE_COMPATIBILITY_FIXES, // 859 - implementation of previoulsy postponed changes to serialization
CHRONICLES_SUPPORT, // 860 - support for heroes chronicles
PER_MAP_GAME_SETTINGS, // 861 - game settings are now stored per-map
CAMPAIGN_OUTRO_SUPPORT, // 862 - support for campaign outro video
REWARDABLE_BANKS, // 863 - team state contains list of scouted objects, coast visitable rewardable objects
REGION_LABEL, // 864 - labels for campaign regions
SPELL_RESEARCH, // 865 - spell research
LOCAL_PLAYER_STATE_DATA, // 866 - player state contains arbitrary client-side data
REMOVE_TOWN_PTR, // 867 - removed pointer to CTown from CGTownInstance
REMOVE_OBJECT_TYPENAME, // 868 - remove typename from CGObjectInstance
REMOVE_VLC_POINTERS, // 869 removed remaining pointers to LIBRARY entities
FOLDER_NAME_REWORK, // 870 - rework foldername
REWARDABLE_GUARDS, // 871 - fix missing serialization of guards in rewardable objects
MARKET_TRANSLATION_FIX, // 872 - remove serialization of markets translateable strings
EVENT_OBJECTS_DELETION, //873 - allow events to remove map objects
RELEASE_160 = 873, RELEASE_160 = 873,
MINIMAL = RELEASE_160,
MAP_HEADER_DISPOSED_HEROES, // map header contains disposed heroes list MAP_HEADER_DISPOSED_HEROES, // map header contains disposed heroes list

View File

@ -63,24 +63,6 @@ public:
} }
}; };
class SerializerCompatibilityBonusingBuilding final : public SerializerCompatibility<TownRewardableBuildingInstance, ESerializationVersion::NEW_TOWN_BUILDINGS>
{
void loadPtr(BinaryDeserializer &ar, IGameCallback * cb, Serializeable * data) const override
{
auto * realPtr = dynamic_cast<TownRewardableBuildingInstance *>(data);
realPtr->serialize(ar);
}
};
class SerializerCompatibilityArtifactsAltar final : public SerializerCompatibility<CGMarket, ESerializationVersion::NEW_MARKETS>
{
void loadPtr(BinaryDeserializer &ar, IGameCallback * cb, Serializeable * data) const override
{
auto * realPtr = dynamic_cast<CGMarket *>(data);
realPtr->serializeArtifactsAltar(ar);
}
};
template<typename Type> template<typename Type>
void CSerializationApplier::registerType(uint16_t ID) void CSerializationApplier::registerType(uint16_t ID)
{ {
@ -91,10 +73,6 @@ void CSerializationApplier::registerType(uint16_t ID)
CSerializationApplier::CSerializationApplier() CSerializationApplier::CSerializationApplier()
{ {
registerTypes(*this); registerTypes(*this);
apps[54].reset(new SerializerCompatibilityBonusingBuilding);
apps[55].reset(new SerializerCompatibilityBonusingBuilding);
apps[81].reset(new SerializerCompatibilityArtifactsAltar);
} }
CSerializationApplier & CSerializationApplier::getInstance() CSerializationApplier & CSerializationApplier::getInstance()

View File

@ -93,45 +93,7 @@ public:
void serialize(Handler & h) void serialize(Handler & h)
{ {
std::lock_guard globalLock(globalTextMutex); std::lock_guard globalLock(globalTextMutex);
h & stringsLocalizations;
if (h.version >= Handler::Version::SIMPLE_TEXT_CONTAINER_SERIALIZATION)
{
h & stringsLocalizations;
}
else
{
std::string key;
int64_t sz = stringsLocalizations.size();
if (h.version >= Handler::Version::REMOVE_TEXT_CONTAINER_SIZE_T)
{
int64_t size = sz;
h & size;
sz = size;
}
else
{
h & sz;
}
if(h.saving)
{
for(auto & s : stringsLocalizations)
{
key = s.first;
h & key;
h & s.second;
}
}
else
{
for(size_t i = 0; i < sz; ++i)
{
h & key;
h & stringsLocalizations[key];
}
}
}
} }
}; };

View File

@ -107,16 +107,7 @@ public:
h & awaitingPlayers; h & awaitingPlayers;
h & actingPlayers; h & actingPlayers;
h & actedPlayers; h & actedPlayers;
h & simturnsMinDurationDays;
if (h.version >= Handler::Version::VOTING_SIMTURNS) h & simturnsMaxDurationDays;
{
h & simturnsMinDurationDays;
h & simturnsMaxDurationDays;
}
else if (!h.saving)
{
simturnsMinDurationDays.reset();
simturnsMaxDurationDays.reset();
}
} }
}; };