From eb3b51a6cf348ac0ec7c95c894417d0e02733ab7 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 18 Mar 2025 11:35:15 +0000 Subject: [PATCH] Remove save compatibility with 1.5.X --- lib/CArtifactInstance.h | 12 +---- lib/CPlayerState.h | 36 ++------------- lib/StartInfo.h | 34 ++------------ lib/bonuses/Limiters.h | 11 +---- lib/campaign/CampaignState.h | 45 ++++++------------- lib/gameState/CGameState.cpp | 9 ---- lib/gameState/CGameState.h | 12 +---- lib/gameState/GameStatistics.h | 17 +++---- lib/mapObjects/CBank.h | 5 +-- lib/mapObjects/CGHeroInstance.h | 8 ---- lib/mapObjects/CGMarket.h | 56 +---------------------- lib/mapObjects/CGObjectInstance.h | 6 --- lib/mapObjects/CGTownInstance.h | 38 ++-------------- lib/mapObjects/IMarket.h | 5 --- lib/mapObjects/TownBuildingInstance.h | 11 +---- lib/mapping/CMap.h | 24 +--------- lib/mapping/CMapDefines.h | 60 +++---------------------- lib/mapping/CMapHeader.h | 21 +++------ lib/networkPacks/PacksForClient.h | 3 +- lib/rewardable/Configuration.h | 9 +--- lib/rewardable/Reward.h | 3 +- lib/serializer/BinaryDeserializer.h | 40 ++++++----------- lib/serializer/BinarySerializer.h | 47 ++++++++----------- lib/serializer/ESerializationVersion.h | 41 +---------------- lib/serializer/SerializerReflection.cpp | 22 --------- lib/texts/TextLocalizationContainer.h | 40 +---------------- server/processors/TurnOrderProcessor.h | 13 +----- 27 files changed, 86 insertions(+), 542 deletions(-) diff --git a/lib/CArtifactInstance.h b/lib/CArtifactInstance.h index f994ee03b..8d2d04959 100644 --- a/lib/CArtifactInstance.h +++ b/lib/CArtifactInstance.h @@ -94,17 +94,7 @@ public: { h & static_cast(*this); h & static_cast(*this); - if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) - { - h & artTypeID; - } - else - { - bool isNull = false; - h & isNull; - if (!isNull) - h & artTypeID; - } + h & artTypeID; h & id; BONUS_TREE_DESERIALIZATION_FIX } diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h index 6456681ed..e13fca027 100644 --- a/lib/CPlayerState.h +++ b/lib/CPlayerState.h @@ -121,24 +121,8 @@ public: h & resources; h & status; h & turnTimer; - - if (h.version >= Handler::Version::LOCAL_PLAYER_STATE_DATA) - h & *playerLocalSettings; - - if (h.version >= Handler::Version::PLAYER_STATE_OWNED_OBJECTS) - { - h & ownedObjects; - } - else - { - std::vector heroes; - std::vector towns; - std::vector dwellings; - - h & heroes; - h & towns; - h & dwellings; - } + h & *playerLocalSettings; + h & ownedObjects; h & quests; h & visitedObjects; h & visitedObjectsGlobal; @@ -173,23 +157,9 @@ public: { h & id; 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 & static_cast(*this); - - if (h.version >= Handler::Version::REWARDABLE_BANKS) - h & scoutedObjects; + h & scoutedObjects; } }; diff --git a/lib/StartInfo.h b/lib/StartInfo.h index 8a79dc344..36ba625ec 100644 --- a/lib/StartInfo.h +++ b/lib/StartInfo.h @@ -51,11 +51,7 @@ struct DLL_LINKAGE SimturnsInfo h & requiredTurns; h & optionalTurns; h & allowHumanWithAI; - - if (h.version >= Handler::Version::SAVE_COMPATIBILITY_FIXES) - h & ignoreAlliedContacts; - else - ignoreAlliedContacts = true; + h & ignoreAlliedContacts; } }; @@ -108,14 +104,7 @@ struct DLL_LINKAGE PlayerSettings h & heroNameTextId; h & bonus; h & color; - if (h.version >= Handler::Version::PLAYER_HANDICAP) - h & handicap; - else - { - enum EHandicap {NO_HANDICAP, MILD, SEVERE}; - EHandicap handicapLegacy = NO_HANDICAP; - h & handicapLegacy; - } + h & handicap; h & name; h & connectedPlayerIDs; h & compOnly; @@ -173,24 +162,7 @@ struct DLL_LINKAGE StartInfo : public Serializeable h & mode; h & difficulty; h & playerInfos; - if (h.version < Handler::Version::REMOVE_LIB_RNG) - { - 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 & startTime; h & fileURI; h & simturnsInfo; h & turnTimerInfo; diff --git a/lib/bonuses/Limiters.h b/lib/bonuses/Limiters.h index bafa4f7b0..3023e8779 100644 --- a/lib/bonuses/Limiters.h +++ b/lib/bonuses/Limiters.h @@ -108,16 +108,7 @@ public: template void serialize(Handler &h) { h & static_cast(*this); - - if (h.version < Handler::Version::REMOVE_TOWN_PTR) - { - bool isNull = false; - h & isNull; - if(!isNull) - h & creatureID; - } - else - h & creatureID; + h & creatureID; h & includeUpgrades; } }; diff --git a/lib/campaign/CampaignState.h b/lib/campaign/CampaignState.h index 78017482d..bcff8a883 100644 --- a/lib/campaign/CampaignState.h +++ b/lib/campaign/CampaignState.h @@ -46,16 +46,8 @@ class DLL_LINKAGE CampaignRegions template void serialize(Handler &h) { h & infix; - if (h.version >= Handler::Version::REGION_LABEL) - { - h & pos; - h & labelPos; - } - else - { - h & pos.x; - h & pos.y; - } + h & pos; + h & labelPos; } static CampaignRegions::RegionDescription fromJson(const JsonNode & node); @@ -79,11 +71,8 @@ public: h & campPrefix; h & colorSuffixLength; h & regions; - if (h.version >= Handler::Version::CAMPAIGN_REGIONS) - { - h & campSuffix; - h & campBackground; - } + h & campSuffix; + h & campBackground; } static CampaignRegions fromJson(const JsonNode & node); @@ -150,27 +139,20 @@ public: h & numberOfScenarios; h & name; h & description; - if (h.version >= Handler::Version::MAP_FORMAT_ADDITIONAL_INFOS) - { - h & author; - h & authorContact; - h & campaignVersion; - h & creationDateTime; - } + h & author; + h & authorContact; + h & campaignVersion; + h & creationDateTime; h & difficultyChosenByPlayer; h & filename; h & modName; h & music; h & encoding; h & textContainer; - if (h.version >= Handler::Version::CHRONICLES_SUPPORT) - { - h & loadingBackground; - h & videoRim; - h & introVideo; - } - if (h.version >= Handler::Version::CAMPAIGN_OUTRO_SUPPORT) - h & outroVideo; + h & loadingBackground; + h & videoRim; + h & introVideo; + h & outroVideo; } }; @@ -374,8 +356,7 @@ public: h & chosenCampaignBonuses; h & campaignSet; h & mapTranslations; - if (h.version >= Handler::Version::HIGHSCORE_PARAMETERS) - h & highscoreParameters; + h & highscoreParameters; } }; diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index e21533459..30590019f 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -351,15 +351,6 @@ void CGameState::initCampaign() 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() { const JsonNode & baseBonuses = getSettings().getValue(EGameSettings::BONUSES_GLOBAL); diff --git a/lib/gameState/CGameState.h b/lib/gameState/CGameState.h index 5e77ce7e6..1f18dd11a 100644 --- a/lib/gameState/CGameState.h +++ b/lib/gameState/CGameState.h @@ -171,21 +171,13 @@ public: h & day; h & map; h & players; - if (h.version < Handler::Version::PLAYER_STATE_OWNED_OBJECTS) - generateOwnedObjectsAfterDeserialize(); h & teams; h & heroesPool; h & globalEffects; - if (h.version < Handler::Version::REMOVE_LIB_RNG) - { - std::string oldStateOfRNG; - h & oldStateOfRNG; - } h & currentRumor; h & campaign; h & allocatedArtifacts; - if (h.version >= Handler::Version::STATISTICS) - h & statistic; + h & statistic; BONUS_TREE_DESERIALIZATION_FIX } @@ -213,8 +205,6 @@ private: void initVisitingAndGarrisonedHeroes(); void initCampaign(); - void generateOwnedObjectsAfterDeserialize(); - // ----- bonus system handling ----- void buildBonusSystemTree(); diff --git a/lib/gameState/GameStatistics.h b/lib/gameState/GameStatistics.h index 851f6417c..d867bc015 100644 --- a/lib/gameState/GameStatistics.h +++ b/lib/gameState/GameStatistics.h @@ -63,8 +63,7 @@ struct DLL_LINKAGE StatisticDataSetEntry h & timestamp; h & day; h & player; - if(h.version >= Handler::Version::STATISTICS_SCREEN) - h & playerName; + h & playerName; h & team; h & isHuman; h & status; @@ -92,11 +91,8 @@ struct DLL_LINKAGE StatisticDataSetEntry h & spentResourcesForArmy; h & spentResourcesForBuildings; h & tradeVolume; - if(h.version >= Handler::Version::STATISTICS_SCREEN) - { - h & eventCapturedTown; - h & eventDefeatedStrongestHero; - } + h & eventCapturedTown; + h & eventDefeatedStrongestHero; h & movementPointsUsed; } }; @@ -136,11 +132,8 @@ public: h & spentResourcesForBuildings; h & tradeVolume; h & movementPointsUsed; - if(h.version >= Handler::Version::STATISTICS_SCREEN) - { - h & lastCapturedTownDay; - h & lastDefeatedStrongestHeroDay; - } + h & lastCapturedTownDay; + h & lastDefeatedStrongestHeroDay; } }; std::vector data; diff --git a/lib/mapObjects/CBank.h b/lib/mapObjects/CBank.h index b61563421..13116ab89 100644 --- a/lib/mapObjects/CBank.h +++ b/lib/mapObjects/CBank.h @@ -51,10 +51,7 @@ public: h & bankConfig; h & resetDuration; h & coastVisitable; - if (h.version >= Handler::Version::BANK_UNIT_PLACEMENT) - h & regularUnitPlacement; - else if (!h.saving) - regularUnitPlacement = false; + h & regularUnitPlacement; } friend class CBankInstanceConstructor; diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index d980d5795..59c431671 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -371,14 +371,6 @@ public: h & skillsInfo; h & visitedTown; h & boat; - if (h.version < Handler::Version::REMOVE_TOWN_PTR) - { - HeroTypeID type; - bool isNull = false; - h & isNull; - if(!isNull) - h & type; - } h & commander; h & visitedObjects; BONUS_TREE_DESERIALIZATION_FIX diff --git a/lib/mapObjects/CGMarket.h b/lib/mapObjects/CGMarket.h index 6f4f92a42..76ff390e5 100644 --- a/lib/mapObjects/CGMarket.h +++ b/lib/mapObjects/CGMarket.h @@ -36,37 +36,6 @@ public: int getMarketEfficiency() const override; int availableUnits(EMarketMode mode, int marketItemSerial) const override; //-1 if unlimited std::set availableModes() const override; - - template - void serialize(Handler &h) - { - h & static_cast(*this); - if (h.version < Handler::Version::NEW_MARKETS) - { - std::set 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 void serializeArtifactsAltar(Handler &h) - { - serialize(h); - IMarket::serializeArtifactsAltar(h); - } }; class DLL_LINKAGE CGBlackMarket : public CGMarket @@ -82,24 +51,7 @@ public: template void serialize(Handler &h) { h & static_cast(*this); - 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; - artifacts.push_back(artifact); - } - } - else - { - h & artifacts; - } + h & artifacts; } }; @@ -119,12 +71,6 @@ public: { h & static_cast(*this); h & skills; - if (h.version >= Handler::Version::NEW_MARKETS && h.version < Handler::Version::MARKET_TRANSLATION_FIX) - { - std::string temp; - h & temp; - h & temp; - } } }; diff --git a/lib/mapObjects/CGObjectInstance.h b/lib/mapObjects/CGObjectInstance.h index c201dd4db..4038d22c4 100644 --- a/lib/mapObjects/CGObjectInstance.h +++ b/lib/mapObjects/CGObjectInstance.h @@ -143,12 +143,6 @@ public: template void serialize(Handler &h) { h & instanceName; - if (h.version < Handler::Version::REMOVE_OBJECT_TYPENAME) - { - std::string unused; - h & unused; - h & unused; - } h & pos; h & ID; subID.serializeIdentifier(h, ID); diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index 5918b0621..e2e77bbc0 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -94,43 +94,13 @@ public: h & obligatorySpells; h & spells; h & events; - - if (h.version >= Handler::Version::SPELL_RESEARCH) - { - h & spellResearchCounterDay; - h & spellResearchAcceptedCounter; - h & spellResearchAllowed; - } - - if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS) - { - h & rewardableBuildings; - } - else - { - std::vector 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 & spellResearchCounterDay; + h & spellResearchAcceptedCounter; + h & spellResearchAllowed; + h & rewardableBuildings; h & townAndVis; BONUS_TREE_DESERIALIZATION_FIX - if (h.version < Handler::Version::NEW_TOWN_BUILDINGS) - { - std::set overriddenBuildings; - h & overriddenBuildings; - } - if(!h.saving) postDeserialize(); } diff --git a/lib/mapObjects/IMarket.h b/lib/mapObjects/IMarket.h index b4822e732..b163990cb 100644 --- a/lib/mapObjects/IMarket.h +++ b/lib/mapObjects/IMarket.h @@ -36,11 +36,6 @@ public: 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 - template void serializeArtifactsAltar(Handler &h) - { - h & *altarArtifactsStorage; - } - private: std::unique_ptr altarArtifactsStorage; }; diff --git a/lib/mapObjects/TownBuildingInstance.h b/lib/mapObjects/TownBuildingInstance.h index b7b06a8a2..eace6f9b1 100644 --- a/lib/mapObjects/TownBuildingInstance.h +++ b/lib/mapObjects/TownBuildingInstance.h @@ -43,14 +43,6 @@ public: template void serialize(Handler &h) { 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: @@ -90,8 +82,7 @@ public: template void serialize(Handler &h) { h & static_cast(*this); - if (h.version >= Handler::Version::NEW_TOWN_BUILDINGS) - h & static_cast(*this); + h & static_cast(*this); h & visitors; } }; diff --git a/lib/mapping/CMap.h b/lib/mapping/CMap.h index 9c69be1cd..80b7e6690 100644 --- a/lib/mapping/CMap.h +++ b/lib/mapping/CMap.h @@ -192,31 +192,11 @@ public: // static members h & obeliskCount; h & obelisksVisited; - - 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 & townMerchantArtifacts; h & townUniversitySkills; h & instanceNames; - - if (h.version >= Handler::Version::PER_MAP_GAME_SETTINGS) - h & *gameSettings; + h & *gameSettings; } }; diff --git a/lib/mapping/CMapDefines.h b/lib/mapping/CMapDefines.h index 2655786f6..cb3a1156f 100644 --- a/lib/mapping/CMapDefines.h +++ b/lib/mapping/CMapDefines.h @@ -52,26 +52,12 @@ public: h & name; h & message; h & resources; - if (h.version >= Handler::Version::EVENTS_PLAYER_SET) - { - 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 & players; h & humanAffected; h & computerAffected; h & firstOccurrence; h & nextOccurrence; - if(h.version >= Handler::Version::EVENT_OBJECTS_DELETION) - { - h & deletedObjectsInstances; - } + h & deletedObjectsInstances; } virtual void serializeJson(JsonSerializeFormat & handler); @@ -147,49 +133,13 @@ struct DLL_LINKAGE TerrainTile template void serialize(Handler & h) { - if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) - { - h & terrainType; - } - else - { - bool isNull = false; - h & isNull; - if (!isNull) - h & terrainType; - } + h & terrainType; h & terView; - if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) - { - h & riverType; - } - else - { - bool isNull = false; - h & isNull; - if (!isNull) - h & riverType; - } + h & riverType; h & riverDir; - if (h.version >= Handler::Version::REMOVE_VLC_POINTERS) - { - h & roadType; - } - else - { - bool isNull = false; - h & isNull; - if (!isNull) - h & roadType; - } + h & roadType; h & roadDir; h & extTileFlags; - if (h.version < Handler::Version::REMOVE_VLC_POINTERS) - { - bool unused = false; - h & unused; - h & unused; - } h & visitableObjects; h & blockingObjects; } diff --git a/lib/mapping/CMapHeader.h b/lib/mapping/CMapHeader.h index d5caef3d2..8bd828eb9 100644 --- a/lib/mapping/CMapHeader.h +++ b/lib/mapping/CMapHeader.h @@ -287,25 +287,14 @@ public: h & mods; h & name; h & description; - if (h.version >= Handler::Version::MAP_FORMAT_ADDITIONAL_INFOS) - { - h & author; - h & authorContact; - h & mapVersion; - h & creationDateTime; - } + h & author; + h & authorContact; + h & mapVersion; + h & creationDateTime; h & width; h & height; h & twoLevel; - - if (h.version >= Handler::Version::SAVE_COMPATIBILITY_FIXES) - h & difficulty; - else - { - uint8_t difficultyInteger = static_cast(difficulty); - h & difficultyInteger; - difficulty = static_cast(difficultyInteger); - } + h & difficulty; h & levelLimit; h & areAnyPlayers; diff --git a/lib/networkPacks/PacksForClient.h b/lib/networkPacks/PacksForClient.h index e4f96fa48..4e752845d 100644 --- a/lib/networkPacks/PacksForClient.h +++ b/lib/networkPacks/PacksForClient.h @@ -481,8 +481,7 @@ struct DLL_LINKAGE PlayerEndsGame : public CPackForClient { h & player; h & victoryLossCheckResult; - if (h.version >= Handler::Version::STATISTICS_SCREEN) - h & statistic; + h & statistic; } }; diff --git a/lib/rewardable/Configuration.h b/lib/rewardable/Configuration.h index e9e9f832f..7c1b7548a 100644 --- a/lib/rewardable/Configuration.h +++ b/lib/rewardable/Configuration.h @@ -194,13 +194,8 @@ struct DLL_LINKAGE Configuration h & canRefuse; h & showScoutedPreview; h & infoWindowType; - if (h.version >= Handler::Version::REWARDABLE_BANKS) - { - h & coastVisitable; - h & guardsLayout; - } - else - coastVisitable = false; + h & coastVisitable; + h & guardsLayout; } }; diff --git a/lib/rewardable/Reward.h b/lib/rewardable/Reward.h index a9ad214c9..0dd46d189 100644 --- a/lib/rewardable/Reward.h +++ b/lib/rewardable/Reward.h @@ -129,8 +129,7 @@ struct DLL_LINKAGE Reward final h & removeObject; h & manaPercentage; h & movePercentage; - if (h.version >= Handler::Version::REWARDABLE_GUARDS) - h & guards; + h & guards; h & heroExperience; h & heroLevel; h & manaDiff; diff --git a/lib/serializer/BinaryDeserializer.h b/lib/serializer/BinaryDeserializer.h index 25c232ca5..d4ed96c0a 100644 --- a/lib/serializer/BinaryDeserializer.h +++ b/lib/serializer/BinaryDeserializer.h @@ -162,10 +162,7 @@ public: else { static_assert(!std::is_same_v, "Serialization of unsigned 64-bit value may not work in some cases"); - if (hasFeature(Version::COMPACT_INTEGER_SERIALIZATION)) - data = loadEncodedInteger(); - else - this->read(static_cast(&data), sizeof(data), reverseEndianness); + data = loadEncodedInteger(); } } @@ -444,32 +441,23 @@ public: } void load(std::string &data) { - if (hasFeature(Version::COMPACT_STRING_SERIALIZATION)) - { - int32_t length; - load(length); + int32_t length; + load(length); - if (length < 0) - { - int32_t stringID = -length - 1; // -1, -2 ... -> 0, 1 ... - data = loadedStrings[stringID]; - } - if (length == 0) - { - data = {}; - } - if (length > 0) - { - data.resize(length); - this->read(static_cast(data.data()), length, false); - loadedStrings.push_back(data); - } - } - else + if (length < 0) + { + int32_t stringID = -length - 1; // -1, -2 ... -> 0, 1 ... + data = loadedStrings[stringID]; + } + if (length == 0) + { + data = {}; + } + if (length > 0) { - uint32_t length = readAndCheckLength(); data.resize(length); this->read(static_cast(data.data()), length, false); + loadedStrings.push_back(data); } } diff --git a/lib/serializer/BinarySerializer.h b/lib/serializer/BinarySerializer.h index 87a303706..6b6d170bc 100644 --- a/lib/serializer/BinarySerializer.h +++ b/lib/serializer/BinarySerializer.h @@ -148,10 +148,7 @@ public: } else { - if (hasFeature(Version::COMPACT_INTEGER_SERIALIZATION)) - saveEncodedInteger(data); - else - this->write(static_cast(&data), sizeof(data)); + saveEncodedInteger(data); } } @@ -325,36 +322,28 @@ public: void save(const std::string &data) { - if (hasFeature(Version::COMPACT_STRING_SERIALIZATION)) + if (data.empty()) { - if (data.empty()) - { - save(static_cast(0)); - return; - } - - auto it = savedStrings.find(data); - - if (it == savedStrings.end()) - { - save(static_cast(data.length())); - this->write(static_cast(data.data()), data.size()); - - // -1, -2... - int32_t newStringID = -1 - savedStrings.size(); - - savedStrings[data] = newStringID; - } - else - { - int32_t index = it->second; - save(index); - } + save(static_cast(0)); + return; } - else + + auto it = savedStrings.find(data); + + if (it == savedStrings.end()) { save(static_cast(data.length())); this->write(static_cast(data.data()), data.size()); + + // -1, -2... + int32_t newStringID = -1 - savedStrings.size(); + + savedStrings[data] = newStringID; + } + else + { + int32_t index = it->second; + save(index); } } diff --git a/lib/serializer/ESerializationVersion.h b/lib/serializer/ESerializationVersion.h index c7c47a828..6ba36f9d3 100644 --- a/lib/serializer/ESerializationVersion.h +++ b/lib/serializer/ESerializationVersion.h @@ -31,47 +31,8 @@ enum class ESerializationVersion : int32_t { 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, + MINIMAL = RELEASE_160, MAP_HEADER_DISPOSED_HEROES, // map header contains disposed heroes list diff --git a/lib/serializer/SerializerReflection.cpp b/lib/serializer/SerializerReflection.cpp index ecb3427b8..861174812 100644 --- a/lib/serializer/SerializerReflection.cpp +++ b/lib/serializer/SerializerReflection.cpp @@ -63,24 +63,6 @@ public: } }; -class SerializerCompatibilityBonusingBuilding final : public SerializerCompatibility -{ - void loadPtr(BinaryDeserializer &ar, IGameCallback * cb, Serializeable * data) const override - { - auto * realPtr = dynamic_cast(data); - realPtr->serialize(ar); - } -}; - -class SerializerCompatibilityArtifactsAltar final : public SerializerCompatibility -{ - void loadPtr(BinaryDeserializer &ar, IGameCallback * cb, Serializeable * data) const override - { - auto * realPtr = dynamic_cast(data); - realPtr->serializeArtifactsAltar(ar); - } -}; - template void CSerializationApplier::registerType(uint16_t ID) { @@ -91,10 +73,6 @@ void CSerializationApplier::registerType(uint16_t ID) CSerializationApplier::CSerializationApplier() { registerTypes(*this); - - apps[54].reset(new SerializerCompatibilityBonusingBuilding); - apps[55].reset(new SerializerCompatibilityBonusingBuilding); - apps[81].reset(new SerializerCompatibilityArtifactsAltar); } CSerializationApplier & CSerializationApplier::getInstance() diff --git a/lib/texts/TextLocalizationContainer.h b/lib/texts/TextLocalizationContainer.h index 523335c57..56fcca467 100644 --- a/lib/texts/TextLocalizationContainer.h +++ b/lib/texts/TextLocalizationContainer.h @@ -93,45 +93,7 @@ public: void serialize(Handler & h) { std::lock_guard globalLock(globalTextMutex); - - 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]; - } - } - } + h & stringsLocalizations; } }; diff --git a/server/processors/TurnOrderProcessor.h b/server/processors/TurnOrderProcessor.h index 5b038455f..e4d96d2b2 100644 --- a/server/processors/TurnOrderProcessor.h +++ b/server/processors/TurnOrderProcessor.h @@ -107,16 +107,7 @@ public: h & awaitingPlayers; h & actingPlayers; h & actedPlayers; - - if (h.version >= Handler::Version::VOTING_SIMTURNS) - { - h & simturnsMinDurationDays; - h & simturnsMaxDurationDays; - } - else if (!h.saving) - { - simturnsMinDurationDays.reset(); - simturnsMaxDurationDays.reset(); - } + h & simturnsMinDurationDays; + h & simturnsMaxDurationDays; } };