mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed #1686. Compatibility measures to be removed later, when format changes become to big.
This commit is contained in:
parent
77946e88f1
commit
55165a8535
@ -1119,7 +1119,7 @@ void SelectionTab::parseGames(const std::unordered_set<ResourceID> &files, bool
|
||||
{
|
||||
try
|
||||
{
|
||||
CLoadFile lf(*CResourceHandler::get()->getResourceName(file));
|
||||
CLoadFile lf(*CResourceHandler::get()->getResourceName(file), minSupportedVersion);
|
||||
lf.checkMagicBytes(SAVEGAME_MAGIC);
|
||||
// ui8 sign[8];
|
||||
// lf >> sign;
|
||||
|
@ -244,7 +244,7 @@ void CClient::loadGame( const std::string & fname )
|
||||
|
||||
unique_ptr<CLoadFile> loader;
|
||||
{
|
||||
CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName);
|
||||
CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName, minSupportedVersion);
|
||||
loadCommonState(checkingLoader);
|
||||
loader = checkingLoader.decay();
|
||||
}
|
||||
|
@ -41,6 +41,18 @@ class CIdentifierStorage
|
||||
{
|
||||
si32 id;
|
||||
std::string scope; /// scope in which this ID located
|
||||
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
if(version >= 744)
|
||||
h & id & scope;
|
||||
else if(h.saving)
|
||||
{
|
||||
logGlobal->warnStream() << "Save compatibility, making object data with id -1 (can this happen?)";
|
||||
id = -1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::multimap<std::string, ObjectData > registeredObjects;
|
||||
@ -72,6 +84,12 @@ public:
|
||||
|
||||
/// called at the very end of loading to check for any missing ID's
|
||||
void finalize();
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
if(version >= 744)
|
||||
h & registeredObjects;
|
||||
}
|
||||
};
|
||||
|
||||
/// class used to load all game data into handlers. Used only during loading
|
||||
@ -249,5 +267,9 @@ public:
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & allMods & activeMods & settings & modules;
|
||||
if(version >= 744)
|
||||
h & identifiers;
|
||||
else
|
||||
logGlobal->warnStream() << "Savegame compatibility mode, omitting identifiers in modhandler. Related bugs will persist.";
|
||||
}
|
||||
};
|
||||
|
@ -28,7 +28,8 @@
|
||||
#include "mapping/CCampaignHandler.h" //for CCampaignState
|
||||
#include "rmg/CMapGenerator.h" // for CMapGenOptions
|
||||
|
||||
const ui32 version = 743;
|
||||
const ui32 version = 744;
|
||||
const ui32 minSupportedVersion = 743;
|
||||
|
||||
class CConnection;
|
||||
class CGObjectInstance;
|
||||
@ -798,6 +799,13 @@ public:
|
||||
for(typename std::map<T1,T2>::const_iterator i=data.begin();i!=data.end();i++)
|
||||
*this << i->first << i->second;
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
void saveSerializable(const std::multimap<T1, T2> &data)
|
||||
{
|
||||
*this << ui32(data.size());
|
||||
for(typename std::map<T1, T2>::const_iterator i = data.begin(); i != data.end(); i++)
|
||||
*this << i->first << i->second;
|
||||
}
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
void saveSerializable(const boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> &data)
|
||||
{
|
||||
@ -1198,6 +1206,19 @@ public:
|
||||
*this >> data[t];
|
||||
}
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
void loadSerializable(std::multimap<T1, T2> &data)
|
||||
{
|
||||
READ_CHECK_U32(length);
|
||||
data.clear();
|
||||
T1 key;
|
||||
T2 value;
|
||||
for(ui32 i = 0; i < length; i++)
|
||||
{
|
||||
*this >> key >> value;
|
||||
data.insert(std::pair<T1, T2>(std::move(key), std::move(value)));
|
||||
}
|
||||
}
|
||||
void loadSerializable(std::string &data)
|
||||
{
|
||||
READ_CHECK_U32(length);
|
||||
|
@ -477,7 +477,7 @@ void CVCMIServer::loadGame()
|
||||
// }
|
||||
|
||||
{
|
||||
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME)));
|
||||
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME)), minSupportedVersion);
|
||||
gh.loadCommonState(lf);
|
||||
lf >> gh;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user