mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-19 00:17:56 +02:00
Remove save compatibility with 1.5.X
This commit is contained in:
@ -162,10 +162,7 @@ public:
|
||||
else
|
||||
{
|
||||
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();
|
||||
else
|
||||
this->read(static_cast<void *>(&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<void *>(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<void *>(data.data()), length, false);
|
||||
loadedStrings.push_back(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,10 +148,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasFeature(Version::COMPACT_INTEGER_SERIALIZATION))
|
||||
saveEncodedInteger(data);
|
||||
else
|
||||
this->write(static_cast<const void *>(&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<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);
|
||||
}
|
||||
save(static_cast<uint32_t>(0));
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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>
|
||||
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()
|
||||
|
Reference in New Issue
Block a user