1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Merge pull request #66 from vcmi/experimental/serializerrefactoring

Works with MVS, merging.
This commit is contained in:
DjWarmonger 2014-12-22 19:28:43 +01:00
commit 083c80c98b
23 changed files with 448 additions and 423 deletions

View File

@ -321,13 +321,13 @@ BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
}
}
void CStupidAI::saveGame(COSer<CSaveFile> &h, const int version)
void CStupidAI::saveGame(COSer & h, const int version)
{
//TODO to be implemented with saving/loading during the battles
assert(0);
}
void CStupidAI::loadGame(CISer<CLoadFile> &h, const int version)
void CStupidAI::loadGame(CISer & h, const int version)
{
//TODO to be implemented with saving/loading during the battles
assert(0);

View File

@ -36,8 +36,8 @@ public:
BattleAction goTowards(const CStack * stack, BattleHex hex );
virtual void saveGame(COSer<CSaveFile> &h, const int version) override;
virtual void loadGame(CISer<CLoadFile> &h, const int version) override;
virtual void saveGame(COSer & h, const int version) override;
virtual void loadGame(CISer & h, const int version) override;
};

View File

@ -598,7 +598,7 @@ void VCAI::showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *do
});
}
void VCAI::saveGame(COSer<CSaveFile> &h, const int version)
void VCAI::saveGame(COSer & h, const int version)
{
LOG_TRACE_PARAMS(logAi, "version '%i'", version);
NET_EVENT_HANDLER;
@ -609,7 +609,7 @@ void VCAI::saveGame(COSer<CSaveFile> &h, const int version)
serializeInternal(h, version);
}
void VCAI::loadGame(CISer<CLoadFile> &h, const int version)
void VCAI::loadGame(CISer & h, const int version)
{
LOG_TRACE_PARAMS(logAi, "version '%i'", version);
NET_EVENT_HANDLER;

View File

@ -190,8 +190,8 @@ public:
virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
virtual void saveGame(COSer<CSaveFile> &h, const int version) override; //saving
virtual void loadGame(CISer<CLoadFile> &h, const int version) override; //loading
virtual void saveGame(COSer & h, const int version) override; //saving
virtual void loadGame(CISer & h, const int version) override; //loading
virtual void finish() override;
virtual void availableCreaturesChanged(const CGDwelling *town) override;

View File

@ -1269,13 +1269,13 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c
h & spellbookSettings;
}
void CPlayerInterface::saveGame( COSer<CSaveFile> &h, const int version )
void CPlayerInterface::saveGame( COSer & h, const int version )
{
EVENT_HANDLER_CALLED_BY_CLIENT;
serializeTempl(h,version);
}
void CPlayerInterface::loadGame( CISer<CLoadFile> &h, const int version )
void CPlayerInterface::loadGame( CISer & h, const int version )
{
EVENT_HANDLER_CALLED_BY_CLIENT;
serializeTempl(h,version);

View File

@ -193,8 +193,8 @@ public:
void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) override;
void playerStartsTurn(PlayerColor player) override; //called before yourTurn on active itnerface
void showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox
void saveGame(COSer<CSaveFile> &h, const int version) override; //saving
void loadGame(CISer<CLoadFile> &h, const int version) override; //loading
void saveGame(COSer & h, const int version) override; //saving
void loadGame(CISer & h, const int version) override; //loading
//for battles
void actionFinished(const BattleAction& action) override;//occurs AFTER action taken by active stack or by the hero

View File

@ -331,7 +331,7 @@ void CClient::loadGame(const std::string & fname, const bool server, const std::
std::cout << x << std::endl;
std::cout << "ENDCLIENTPLAYERS\n";
serialize(*loader,0,clientPlayers);
serialize(loader->serializer,0,clientPlayers);
*serv << ui32(clientPlayers.size());
for(auto & elem : clientPlayers)
*serv << ui8(elem.getNum());
@ -493,11 +493,10 @@ void CClient::newGame( CConnection *con, StartInfo *si )
// }
}
template <typename Handler>
void CClient::serialize( Handler &h, const int version )
void CClient::serialize(COSer & h, const int version)
{
h & hotSeat;
if(h.saving)
assert(h.saving);
h & hotSeat;
{
ui8 players = playerint.size();
h & players;
@ -507,11 +506,15 @@ void CClient::serialize( Handler &h, const int version )
LOG_TRACE_PARAMS(logGlobal, "Saving player %s interface", i->first);
assert(i->first == i->second->playerID);
h & i->first & i->second->dllName & i->second->human;
i->second->saveGame(dynamic_cast<COSer<CSaveFile>&>(h), version);
//evil cast that i still like better than sfinae-magic. If I had a "static if"...
i->second->saveGame(h, version);
}
}
else
}
void CClient::serialize(CISer & h, const int version)
{
assert(!h.saving);
h & hotSeat;
{
ui8 players = 0; //fix for uninitialized warning
h & players;
@ -551,7 +554,7 @@ void CClient::serialize( Handler &h, const int version )
nInt->playerID = pid;
installNewPlayerInterface(nInt, pid);
nInt->loadGame(dynamic_cast<CISer<CLoadFile>&>(h), version); //another evil cast, check above
nInt->loadGame(h, version); //another evil cast, check above
}
if(!vstd::contains(battleints, PlayerColor::NEUTRAL))
@ -559,11 +562,10 @@ void CClient::serialize( Handler &h, const int version )
}
}
template <typename Handler>
void CClient::serialize( Handler &h, const int version, const std::set<PlayerColor>& playerIDs)
void CClient::serialize(COSer & h, const int version, const std::set<PlayerColor> & playerIDs)
{
assert(h.saving);
h & hotSeat;
if(h.saving)
{
ui8 players = playerint.size();
h & players;
@ -573,11 +575,15 @@ void CClient::serialize( Handler &h, const int version, const std::set<PlayerCol
LOG_TRACE_PARAMS(logGlobal, "Saving player %s interface", i->first);
assert(i->first == i->second->playerID);
h & i->first & i->second->dllName & i->second->human;
i->second->saveGame(dynamic_cast<COSer<CSaveFile>&>(h), version);
//evil cast that i still like better than sfinae-magic. If I had a "static if"...
i->second->saveGame(h, version);
}
}
else
}
void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor> & playerIDs)
{
assert(!h.saving);
h & hotSeat;
{
ui8 players = 0; //fix for uninitialized warning
h & players;
@ -620,7 +626,7 @@ void CClient::serialize( Handler &h, const int version, const std::set<PlayerCol
if(playerIDs.count(pid))
installNewPlayerInterface(nInt, pid);
nInt->loadGame(dynamic_cast<CISer<CLoadFile>&>(h), version); //another evil cast, check above
nInt->loadGame(h, version);
}
if(playerIDs.count(PlayerColor::NEUTRAL))
@ -901,8 +907,6 @@ std::string CClient::aiNameForPlayer(const PlayerSettings &ps, bool battleAI)
return goodAI;
}
template void CClient::serialize( CISer<CLoadFile> &h, const int version );
template void CClient::serialize( COSer<CSaveFile> &h, const int version );
void CServerHandler::startServer()
{

View File

@ -32,6 +32,8 @@ struct SharedMem;
class CClient;
class CScriptingModule;
struct CPathsInfo;
class CISer;
class COSer;
namespace boost { class thread; }
/// structure to handle running server and connecting to it
@ -236,7 +238,10 @@ public:
//////////////////////////////////////////////////////////////////////////
template <typename Handler> void serialize(Handler &h, const int version);
template <typename Handler> void serialize(Handler &h, const int version, const std::set<PlayerColor>& playerIDs);
void serialize(COSer &h, const int version);
void serialize(CISer &h, const int version);
void serialize(COSer &h, const int version, const std::set<PlayerColor>& playerIDs);
void serialize(CISer &h, const int version, const std::set<PlayerColor>& playerIDs);
void battleFinished();
};

View File

@ -243,7 +243,7 @@ void CAdventureAI::yourTacticPhase(int distance)
battleAI->yourTacticPhase(distance);
}
void CAdventureAI::saveGame(COSer<CSaveFile> &h, const int version) /*saving */
void CAdventureAI::saveGame(COSer & h, const int version) /*saving */
{
LOG_TRACE_PARAMS(logAi, "version '%i'", version);
CGlobalAI::saveGame(h, version);
@ -256,7 +256,7 @@ void CAdventureAI::saveGame(COSer<CSaveFile> &h, const int version) /*saving */
}
}
void CAdventureAI::loadGame(CISer<CLoadFile> &h, const int version) /*loading */
void CAdventureAI::loadGame(CISer & h, const int version) /*loading */
{
LOG_TRACE_PARAMS(logAi, "version '%i'", version);
CGlobalAI::loadGame(h, version);
@ -273,10 +273,10 @@ void CAdventureAI::loadGame(CISer<CLoadFile> &h, const int version) /*loading */
}
}
void CBattleGameInterface::saveGame(COSer<CSaveFile> &h, const int version)
void CBattleGameInterface::saveGame(COSer & h, const int version)
{
}
void CBattleGameInterface::loadGame(CISer<CLoadFile> &h, const int version)
void CBattleGameInterface::loadGame(CISer & h, const int version)
{
}

View File

@ -50,8 +50,8 @@ class CPathsInfo;
class CCreature;
class CLoadFile;
class CSaveFile;
template <typename Serializer> class CISer;
template <typename Serializer> class COSer;
class CISer;
class COSer;
struct ArtifactLocation;
class CScriptingModule;
@ -69,8 +69,8 @@ public:
virtual BattleAction activeStack(const CStack * stack)=0; //called when it's turn of that stack
virtual void yourTacticPhase(int distance){}; //called when interface has opportunity to use Tactics skill -> use cb->battleMakeTacticAction from this function
virtual void saveGame(COSer<CSaveFile> &h, const int version);
virtual void loadGame(CISer<CLoadFile> &h, const int version);
virtual void saveGame(COSer &h, const int version);
virtual void loadGame(CISer &h, const int version);
};
@ -142,6 +142,6 @@ public:
virtual void battleEnd(const BattleResult *br);
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom);
virtual void saveGame(COSer<CSaveFile> &h, const int version); //saving
virtual void loadGame(CISer<CLoadFile> &h, const int version); //loading
virtual void saveGame(COSer & h, const int version); //saving
virtual void loadGame(CISer & h, const int version); //loading
};

View File

@ -878,7 +878,7 @@ void CGameState::initDuel()
else
{
CLoadFile lf(scenarioOps->mapname);
lf >> dp;
lf.serializer >> dp;
}
}
catch(...)

View File

@ -18,14 +18,9 @@
using namespace boost;
using namespace boost::asio::ip;
extern template void registerTypes<CISer<CConnection> >(CISer<CConnection>& s);
extern template void registerTypes<COSer<CConnection> >(COSer<CConnection>& s);
extern template void registerTypes<CISer<CMemorySerializer> >(CISer<CMemorySerializer>& s);
extern template void registerTypes<COSer<CMemorySerializer> >(COSer<CMemorySerializer>& s);
extern template void registerTypes<CSaveFile>(CSaveFile & s);
extern template void registerTypes<CLoadFile>(CLoadFile & s);
extern template void registerTypes<CISer>(CISer & s);
extern template void registerTypes<COSer>(COSer & s);
extern template void registerTypes<CTypeList>(CTypeList & s);
extern template void registerTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
CTypeList typeList;
@ -50,8 +45,8 @@ void CConnection::init()
enableSmartPointerSerializatoin();
disableStackSendingByID();
registerTypes(static_cast<CISer<CConnection>&>(*this));
registerTypes(static_cast<COSer<CConnection>&>(*this));
registerTypes(iser);
registerTypes(oser);
#ifdef LIL_ENDIAN
myEndianess = true;
#else
@ -60,8 +55,8 @@ void CConnection::init()
connected = true;
std::string pom;
//we got connection
(*this) << std::string("Aiya!\n") << name << myEndianess; //identify ourselves
(*this) >> pom >> pom >> contactEndianess;
oser << std::string("Aiya!\n") << name << myEndianess; //identify ourselves
iser >> pom >> pom >> contactEndianess;
logNetwork->infoStream() << "Established connection with "<<pom;
wmx = new boost::mutex;
rmx = new boost::mutex;
@ -73,7 +68,7 @@ void CConnection::init()
}
CConnection::CConnection(std::string host, std::string port, std::string Name)
:io_service(new asio::io_service), name(Name)
:iser(this), oser(this), io_service(new asio::io_service), name(Name)
{
int i;
boost::system::error_code error = asio::error::host_not_found;
@ -128,12 +123,12 @@ connerror1:
throw std::runtime_error("Can't establish connection :(");
}
CConnection::CConnection(TSocket * Socket, std::string Name )
:socket(Socket),io_service(&Socket->get_io_service()), name(Name)//, send(this), rec(this)
:iser(this), oser(this), socket(Socket),io_service(&Socket->get_io_service()), name(Name)//, send(this), rec(this)
{
init();
}
CConnection::CConnection(TAcceptor * acceptor, boost::asio::io_service *Io_service, std::string Name)
: name(Name)//, send(this), rec(this)
: iser(this), oser(this), name(Name)//, send(this), rec(this)
{
boost::system::error_code error = asio::error::host_not_found;
socket = new tcp::socket(*io_service);
@ -229,7 +224,7 @@ CPack * CConnection::retreivePack()
CPack *ret = nullptr;
boost::unique_lock<boost::mutex> lock(*rmx);
logNetwork->traceStream() << "Listening... ";
*this >> ret;
iser >> ret;
logNetwork->traceStream() << "\treceived server message of type " << typeid(*ret).name() << ", data: " << ret;
return ret;
}
@ -238,37 +233,33 @@ void CConnection::sendPackToServer(const CPack &pack, PlayerColor player, ui32 r
{
boost::unique_lock<boost::mutex> lock(*wmx);
logNetwork->traceStream() << "Sending to server a pack of type " << typeid(pack).name();
*this << player << requestID << &pack; //packs has to be sent as polymorphic pointers!
oser << player << requestID << &pack; //packs has to be sent as polymorphic pointers!
}
void CConnection::disableStackSendingByID()
{
CISer<CConnection>::sendStackInstanceByIds = false;
COSer<CConnection>::sendStackInstanceByIds = false;
CSerializer::sendStackInstanceByIds = false;
}
void CConnection::enableStackSendingByID()
{
CISer<CConnection>::sendStackInstanceByIds = true;
COSer<CConnection>::sendStackInstanceByIds = true;
CSerializer::sendStackInstanceByIds = true;
}
void CConnection::disableSmartPointerSerialization()
{
CISer<CConnection>::smartPointerSerialization = false;
COSer<CConnection>::smartPointerSerialization = false;
iser.smartPointerSerialization = oser.smartPointerSerialization = false;
}
void CConnection::enableSmartPointerSerializatoin()
{
CISer<CConnection>::smartPointerSerialization = true;
COSer<CConnection>::smartPointerSerialization = true;
iser.smartPointerSerialization = oser.smartPointerSerialization = true;
}
void CConnection::prepareForSendingHeroes()
{
loadedPointers.clear();
savedPointers.clear();
iser.loadedPointers.clear();
oser.savedPointers.clear();
disableSmartVectorMemberSerialization();
enableSmartPointerSerializatoin();
disableStackSendingByID();
@ -276,25 +267,25 @@ void CConnection::prepareForSendingHeroes()
void CConnection::enterPregameConnectionMode()
{
loadedPointers.clear();
savedPointers.clear();
iser.loadedPointers.clear();
oser.savedPointers.clear();
disableSmartVectorMemberSerialization();
disableSmartPointerSerialization();
}
void CConnection::disableSmartVectorMemberSerialization()
{
smartVectorMembersSerialization = false;
CSerializer::smartVectorMembersSerialization = false;
}
void CConnection::enableSmartVectorMemberSerializatoin()
{
smartVectorMembersSerialization = true;
CSerializer::smartVectorMembersSerialization = true;
}
CSaveFile::CSaveFile( const std::string &fname )
CSaveFile::CSaveFile( const std::string &fname ): serializer(this)
{
registerTypes(*this);
registerTypes(serializer);
openNextFile(fname);
}
@ -320,7 +311,7 @@ void CSaveFile::openNextFile(const std::string &fname)
THROW_FORMAT("Error: cannot open to write %s!", fname);
sfile->write("VCMI",4); //write magic identifier
*this << version; //write format version
serializer << version; //write format version
}
catch(...)
{
@ -350,9 +341,9 @@ void CSaveFile::putMagicBytes( const std::string &text )
write(text.c_str(), text.length());
}
CLoadFile::CLoadFile(const boost::filesystem::path & fname, int minimalVersion /*= version*/)
CLoadFile::CLoadFile(const boost::filesystem::path & fname, int minimalVersion /*= version*/): serializer(this)
{
registerTypes(*this);
registerTypes(serializer);
openNextFile(fname, minimalVersion);
}
@ -368,7 +359,7 @@ int CLoadFile::read(void * data, unsigned size)
void CLoadFile::openNextFile(const boost::filesystem::path & fname, int minimalVersion)
{
assert(!reverseEndianess);
assert(!serializer.reverseEndianess);
assert(minimalVersion <= version);
try
@ -386,22 +377,22 @@ void CLoadFile::openNextFile(const boost::filesystem::path & fname, int minimalV
if(std::memcmp(buffer,"VCMI",4))
THROW_FORMAT("Error: not a VCMI file(%s)!", fName);
*this >> fileVersion;
if(fileVersion < minimalVersion)
serializer >> serializer.fileVersion;
if(serializer.fileVersion < minimalVersion)
THROW_FORMAT("Error: too old file format (%s)!", fName);
if(fileVersion > version)
if(serializer.fileVersion > version)
{
logGlobal->warnStream() << boost::format("Warning format version mismatch: found %d when current is %d! (file %s)\n") % fileVersion % version % fName;
logGlobal->warnStream() << boost::format("Warning format version mismatch: found %d when current is %d! (file %s)\n") % serializer.fileVersion % version % fName;
auto versionptr = (char*)&fileVersion;
auto versionptr = (char*)&serializer.fileVersion;
std::reverse(versionptr, versionptr + 4);
logGlobal->warnStream() << "Version number reversed is " << fileVersion << ", checking...";
logGlobal->warnStream() << "Version number reversed is " << serializer.fileVersion << ", checking...";
if(fileVersion == version)
if(serializer.fileVersion == version)
{
logGlobal->warnStream() << fname << " seems to have different endianness! Entering reversing mode.";
reverseEndianess = true;
serializer.reverseEndianess = true;
}
else
THROW_FORMAT("Error: too new file format (%s)!", fName);
@ -427,7 +418,7 @@ void CLoadFile::clear()
{
sfile = nullptr;
fName.clear();
fileVersion = 0;
serializer.fileVersion = 0;
}
void CLoadFile::checkMagicBytes( const std::string &text )
@ -579,14 +570,14 @@ void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib)
}
CLoadIntegrityValidator::CLoadIntegrityValidator( const std::string &primaryFileName, const std::string &controlFileName, int minimalVersion /*= version*/ )
: foundDesync(false)
: serializer(this), foundDesync(false)
{
registerTypes(*this);
registerTypes(serializer);
primaryFile = make_unique<CLoadFile>(primaryFileName, minimalVersion);
controlFile = make_unique<CLoadFile>(controlFileName, minimalVersion);
assert(primaryFile->fileVersion == controlFile->fileVersion);
fileVersion = primaryFile->fileVersion;
assert(primaryFile->serializer.fileVersion == controlFile->serializer.fileVersion);
serializer.fileVersion = primaryFile->serializer.fileVersion;
}
int CLoadIntegrityValidator::read( void * data, unsigned size )
@ -615,8 +606,8 @@ int CLoadIntegrityValidator::read( void * data, unsigned size )
unique_ptr<CLoadFile> CLoadIntegrityValidator::decay()
{
primaryFile->loadedPointers = this->loadedPointers;
primaryFile->loadedPointersTypes = this->loadedPointersTypes;
primaryFile->serializer.loadedPointers = this->serializer.loadedPointers;
primaryFile->serializer.loadedPointersTypes = this->serializer.loadedPointersTypes;
return std::move(primaryFile);
}
@ -647,10 +638,10 @@ int CMemorySerializer::write(const void * data, unsigned size)
return size;
}
CMemorySerializer::CMemorySerializer()
CMemorySerializer::CMemorySerializer(): iser(this), oser(this)
{
readPos = 0;
registerTypes(static_cast<CISer<CMemorySerializer>&>(*this));
registerTypes(static_cast<COSer<CMemorySerializer>&>(*this));
registerTypes(iser);
registerTypes(oser);
}

View File

@ -30,6 +30,8 @@
const ui32 version = 750;
const ui32 minSupportedVersion = version;
class CISer;
class COSer;
class CConnection;
class CGObjectInstance;
class CStackInstance;
@ -266,140 +268,6 @@ public:
extern DLL_LINKAGE CTypeList typeList;
template<typename Ser>
struct SaveBoolean
{
static void invoke(Ser &s, const bool &data)
{
s.saveBoolean(data);
}
};
template<typename Ser>
struct LoadBoolean
{
static void invoke(Ser &s, bool &data)
{
s.loadBoolean(data);
}
};
template<typename Ser>
struct SaveBooleanVector
{
static void invoke(Ser &s, const std::vector<bool> &data)
{
s.saveBooleanVector(data);
}
};
template<typename Ser>
struct LoadBooleanVector
{
static void invoke(Ser &s, std::vector<bool> &data)
{
s.loadBooleanVector(data);
}
};
template<typename Ser,typename T>
struct SavePrimitive
{
static void invoke(Ser &s, const T &data)
{
s.savePrimitive(data);
}
};
template<typename Ser,typename T>
struct SaveSerializable
{
static void invoke(Ser &s, const T &data)
{
s.saveSerializable(data);
}
};
template<typename Ser,typename T>
struct SaveEnum
{
static void invoke(Ser &s, const T &data)
{
s.saveEnum(data);
}
};
template<typename Ser,typename T>
struct LoadEnum
{
static void invoke(Ser &s, T &data)
{
s.loadEnum(data);
}
};
template<typename Ser,typename T>
struct LoadPrimitive
{
static void invoke(Ser &s, T &data)
{
s.loadPrimitive(data);
}
};
template<typename Ser,typename T>
struct SavePointer
{
static void invoke(Ser &s, const T &data)
{
s.savePointer(data);
}
};
template<typename Ser,typename T>
struct LoadPointer
{
static void invoke(Ser &s, T &data)
{
s.loadPointer(data);
}
};
template<typename Ser,typename T>
struct SaveArray
{
static void invoke(Ser &s, const T &data)
{
s.saveArray(data);
}
};
template<typename Ser,typename T>
struct LoadArray
{
static void invoke(Ser &s, T &data)
{
s.loadArray(data);
}
};
template<typename Ser,typename T>
struct LoadSerializable
{
static void invoke(Ser &s, T &data)
{
s.loadSerializable(data);
}
};
template<typename Ser,typename T>
struct SaveWrong
{
static void invoke(Ser &s, const T &data)
{
throw std::runtime_error("Wrong save serialization call!");
}
};
template<typename Ser,typename T>
struct LoadWrong
{
static void invoke(Ser &s, const T &data)
{
throw std::runtime_error("Wrong load serialization call!");
}
};
template<typename Variant, typename Source>
struct VariantLoaderHelper
{
@ -570,8 +438,23 @@ public:
void addStdVecItems(CGameState *gs, LibClasses *lib = VLC);
};
class DLL_LINKAGE CSaverBase : public virtual CSerializer
class IBinaryWriter : public virtual CSerializer
{
public:
virtual int write(const void * data, unsigned size) = 0;
};
class DLL_LINKAGE CSaverBase
{
protected:
IBinaryWriter * writer;
public:
CSaverBase(IBinaryWriter * w): writer(w){};
inline int write(const void * data, unsigned size)
{
return writer->write(data, size);
};
};
class CBasicPointerSaver
@ -581,19 +464,6 @@ public:
virtual ~CBasicPointerSaver(){}
};
template <typename Serializer, typename T> class CPointerSaver : public CBasicPointerSaver
{
public:
void savePtr(CSaverBase &ar, const void *data) const
{
Serializer &s = static_cast<Serializer&>(ar);
const T *ptr = static_cast<const T*>(data);
//T is most derived known type, it's time to call actual serialize
const_cast<T&>(*ptr).serialize(s,version);
}
};
template <typename T> //metafunction returning CGObjectInstance if T is its derivate or T elsewise
struct VectorisedTypeFor
{
@ -658,6 +528,7 @@ struct SaveIfStackInstance
return false;
}
};
template<typename Ser>
struct SaveIfStackInstance<Ser, CStackInstance *>
{
@ -676,6 +547,7 @@ struct SaveIfStackInstance<Ser, CStackInstance *>
return true;
}
};
template<typename Ser,typename T>
struct LoadIfStackInstance
{
@ -711,16 +583,101 @@ struct LoadIfStackInstance<Ser, CStackInstance *>
/// The class which manages saving objects.
template <typename Serializer> class DLL_LINKAGE COSer : public CSaverBase
class DLL_LINKAGE COSer : public CSaverBase
{
public:
struct SaveBoolean
{
static void invoke(COSer &s, const bool &data)
{
s.saveBoolean(data);
}
};
struct SaveBooleanVector
{
static void invoke(COSer &s, const std::vector<bool> &data)
{
s.saveBooleanVector(data);
}
};
template<typename T>
struct SavePrimitive
{
static void invoke(COSer &s, const T &data)
{
s.savePrimitive(data);
}
};
template<typename T>
struct SaveSerializable
{
static void invoke(COSer &s, const T &data)
{
s.saveSerializable(data);
}
};
template<typename T>
struct SaveEnum
{
static void invoke(COSer &s, const T &data)
{
s.saveEnum(data);
}
};
template<typename T>
struct SavePointer
{
static void invoke(COSer &s, const T &data)
{
s.savePointer(data);
}
};
template<typename T>
struct SaveArray
{
static void invoke(COSer &s, const T &data)
{
s.saveArray(data);
}
};
template<typename T>
struct SaveWrong
{
static void invoke(COSer &s, const T &data)
{
throw std::runtime_error("Wrong save serialization call!");
}
};
template <typename T>
class CPointerSaver : public CBasicPointerSaver
{
public:
void savePtr(CSaverBase &ar, const void *data) const override
{
COSer &s = static_cast<COSer&>(ar);
const T *ptr = static_cast<const T*>(data);
//T is most derived known type, it's time to call actual serialize
const_cast<T&>(*ptr).serialize(s,version);
}
};
bool saving;
std::map<ui16,CBasicPointerSaver*> savers; // typeID => CPointerSaver<serializer,type>
std::map<const void*, ui32> savedPointers;
bool smartPointerSerialization;
COSer()
COSer(IBinaryWriter * w): CSaverBase(w)
{
saving=true;
smartPointerSerialization = true;
@ -738,7 +695,7 @@ public:
{
auto ID = typeList.getTypeID(t);
if(!savers.count(ID))
savers[ID] = new CPointerSaver<COSer<Serializer>, T>;
savers[ID] = new CPointerSaver<T>;
}
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)
@ -748,31 +705,23 @@ public:
addSaver(d);
}
Serializer * This()
{
return static_cast<Serializer*>(this);
}
template<class T>
Serializer & operator<<(const T &t)
COSer & operator<<(const T &t)
{
this->This()->save(t);
return * this->This();
this->save(t);
return * this;
}
template<class T>
COSer & operator&(const T & t)
{
return * this->This() << t;
return * this << t;
}
int write(const void * data, unsigned size);
template <typename T>
void savePrimitive(const T &data)
{
this->This()->write(&data,sizeof(data));
this->write(&data,sizeof(data));
}
template <typename T>
@ -786,23 +735,23 @@ public:
if(!hlp)
return;
if(smartVectorMembersSerialization)
if(writer->smartVectorMembersSerialization)
{
typedef typename boost::remove_const<typename boost::remove_pointer<T>::type>::type TObjectType;
typedef typename VectorisedTypeFor<TObjectType>::type VType;
typedef typename VectorizedIDType<TObjectType>::type IDType;
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
if(const auto *info = writer->getVectorisedTypeInfo<VType, IDType>())
{
IDType id = getIdFromVectorItem<VType>(*info, data);
IDType id = writer->getIdFromVectorItem<VType>(*info, data);
*this << id;
if(id != IDType(-1)) //vector id is enough
return;
}
}
if(sendStackInstanceByIds)
if(writer->sendStackInstanceByIds)
{
const bool gotSaved = SaveIfStackInstance<Serializer,T>::invoke(*This(), data);
const bool gotSaved = SaveIfStackInstance<COSer,T>::invoke(*this, data);
if(gotSaved)
return;
}
@ -830,7 +779,7 @@ public:
ui16 tid = typeList.getTypeID(data);
*this << tid;
This()->savePointerHlp(tid, data);
this->savePointerHlp(tid, data);
}
//that part of ptr serialization was extracted to allow customization of its behavior in derived classes
@ -856,27 +805,27 @@ public:
typedef
//if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Boolean> >,
mpl::identity<SaveBoolean<Serializer> >,
mpl::identity<SaveBoolean>,
//else if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<BooleanVector> >,
mpl::identity<SaveBooleanVector<Serializer> >,
mpl::identity<SaveBooleanVector>,
//else if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
mpl::identity<SavePrimitive<Serializer,T> >,
mpl::identity<SavePrimitive<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Enum> >,
mpl::identity<SaveEnum<Serializer,T> >,
mpl::identity<SaveEnum<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
mpl::identity<SavePointer<Serializer,T> >,
mpl::identity<SavePointer<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
mpl::identity<SaveArray<Serializer,T> >,
mpl::identity<SaveArray<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
mpl::identity<SaveSerializable<Serializer,T> >,
mpl::identity<SaveSerializable<T> >,
//else
mpl::identity<SaveWrong<Serializer,T> >
mpl::identity<SaveWrong<T> >
>
>
>
@ -884,7 +833,7 @@ public:
>
>
>::type typex;
typex::invoke(* this->This(), data);
typex::invoke(* this, data);
}
template <typename T>
void saveSerializable(const T &data)
@ -947,7 +896,7 @@ public:
void saveSerializable(const std::string &data)
{
*this << ui32(data.length());
this->This()->write(data.c_str(),data.size());
this->write(data.c_str(),data.size());
}
template <typename T1, typename T2>
void saveSerializable(const std::pair<T1,T2> &data)
@ -974,7 +923,7 @@ public:
si32 which = data.which();
*this << which;
VariantVisitorSaver<Serializer> visitor(*this->This());
VariantVisitorSaver<COSer> visitor(*this);
boost::apply_visitor(visitor, data);
}
template <typename T>
@ -1009,10 +958,24 @@ public:
}
};
class IBinaryReader : public virtual CSerializer
{
public:
virtual int read(void * data, unsigned size) = 0;
};
class DLL_LINKAGE CLoaderBase : public virtual CSerializer
{};
class DLL_LINKAGE CLoaderBase
{
protected:
IBinaryReader * reader;
public:
CLoaderBase(IBinaryReader * r): reader(r){};
inline int read(void * data, unsigned size)
{
return reader->read(data, size);
};
};
class CBasicPointerLoader
{
@ -1040,28 +1003,99 @@ struct ClassObjectCreator<T, typename std::enable_if<std::is_abstract<T>::value>
}
};
template <typename Serializer, typename T> class CPointerLoader : public CBasicPointerLoader
{
public:
const std::type_info * loadPtr(CLoaderBase &ar, void *data, ui32 pid) const //data is pointer to the ACTUAL POINTER
{
Serializer &s = static_cast<Serializer&>(ar);
T *&ptr = *static_cast<T**>(data);
//create new object under pointer
typedef typename boost::remove_pointer<T>::type npT;
ptr = ClassObjectCreator<npT>::invoke(); //does new npT or throws for abstract classes
s.ptrAllocated(ptr, pid);
//T is most derived known type, it's time to call actual serialize
ptr->serialize(s,version);
return &typeid(T);
}
};
/// The class which manages loading of objects.
template <typename Serializer> class DLL_LINKAGE CISer : public CLoaderBase
class DLL_LINKAGE CISer : public CLoaderBase
{
public:
struct LoadBoolean
{
static void invoke(CISer &s, bool &data)
{
s.loadBoolean(data);
}
};
struct LoadBooleanVector
{
static void invoke(CISer &s, std::vector<bool> &data)
{
s.loadBooleanVector(data);
}
};
template<typename T>
struct LoadEnum
{
static void invoke(CISer &s, T &data)
{
s.loadEnum(data);
}
};
template<typename T>
struct LoadPrimitive
{
static void invoke(CISer &s, T &data)
{
s.loadPrimitive(data);
}
};
template<typename T>
struct LoadPointer
{
static void invoke(CISer &s, T &data)
{
s.loadPointer(data);
}
};
template<typename T>
struct LoadArray
{
static void invoke(CISer &s, T &data)
{
s.loadArray(data);
}
};
template<typename T>
struct LoadSerializable
{
static void invoke(CISer &s, T &data)
{
s.loadSerializable(data);
}
};
template<typename T>
struct LoadWrong
{
static void invoke(CISer &s, const T &data)
{
throw std::runtime_error("Wrong load serialization call!");
}
};
template <typename T> class CPointerLoader : public CBasicPointerLoader
{
public:
const std::type_info * loadPtr(CLoaderBase &ar, void *data, ui32 pid) const override //data is pointer to the ACTUAL POINTER
{
CISer &s = static_cast<CISer&>(ar);
T *&ptr = *static_cast<T**>(data);
//create new object under pointer
typedef typename boost::remove_pointer<T>::type npT;
ptr = ClassObjectCreator<npT>::invoke(); //does new npT or throws for abstract classes
s.ptrAllocated(ptr, pid);
//T is most derived known type, it's time to call actual serialize
ptr->serialize(s,version);
return &typeid(T);
}
};
bool saving;
std::map<ui16,CBasicPointerLoader*> loaders; // typeID => CPointerSaver<serializer,type>
si32 fileVersion;
@ -1073,7 +1107,7 @@ public:
bool smartPointerSerialization;
CISer()
CISer(IBinaryReader * r): CLoaderBase(r)
{
saving = false;
fileVersion = 0;
@ -1094,7 +1128,7 @@ public:
{
auto ID = typeList.getTypeID(t);
if(!loaders.count(ID))
loaders[ID] = new CPointerLoader<CISer<Serializer>, T>;
loaders[ID] = new CPointerLoader<T>;
}
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)
@ -1104,22 +1138,17 @@ public:
addLoader(d);
}
Serializer * This()
{
return static_cast<Serializer*>(this);
}
template<class T>
Serializer & operator>>(T &t)
CISer & operator>>(T &t)
{
this->This()->load(t);
return * this->This();
this->load(t);
return * this;
}
template<class T>
CISer & operator&(T & t)
{
return * this->This() >> t;
return * this >> t;
}
int write(const void * data, unsigned size);
@ -1129,27 +1158,27 @@ public:
typedef
//if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Boolean> >,
mpl::identity<LoadBoolean<Serializer> >,
mpl::identity<LoadBoolean>,
//else if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<BooleanVector> >,
mpl::identity<LoadBooleanVector<Serializer> >,
mpl::identity<LoadBooleanVector>,
//else if
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
mpl::identity<LoadPrimitive<Serializer,T> >,
mpl::identity<LoadPrimitive<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Enum> >,
mpl::identity<LoadEnum<Serializer,T> >,
mpl::identity<LoadEnum<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
mpl::identity<LoadPointer<Serializer,T> >,
mpl::identity<LoadPointer<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
mpl::identity<LoadArray<Serializer,T> >,
mpl::identity<LoadArray<T> >,
//else if
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
mpl::identity<LoadSerializable<Serializer,T> >,
mpl::identity<LoadSerializable<T> >,
//else
mpl::identity<LoadWrong<Serializer,T> >
mpl::identity<LoadWrong<T> >
>
>
>
@ -1157,20 +1186,20 @@ public:
>
>
>::type typex;
typex::invoke(* this->This(), data);
typex::invoke(* this, data);
}
template <typename T>
void loadPrimitive(T &data)
{
if(0) //for testing #989
{
this->This()->read(&data,sizeof(data));
this->read(&data,sizeof(data));
}
else
{
unsigned length = sizeof(data);
char* dataPtr = (char*)&data;
this->This()->read(dataPtr,length);
this->read(dataPtr,length);
if(reverseEndianess)
std::reverse(dataPtr, dataPtr + length);
}
@ -1209,26 +1238,26 @@ public:
return;
}
if(smartVectorMembersSerialization)
if(reader->smartVectorMembersSerialization)
{
typedef typename boost::remove_const<typename boost::remove_pointer<T>::type>::type TObjectType; //eg: const CGHeroInstance * => CGHeroInstance
typedef typename VectorisedTypeFor<TObjectType>::type VType; //eg: CGHeroInstance -> CGobjectInstance
typedef typename VectorizedIDType<TObjectType>::type IDType;
if(const auto *info = getVectorisedTypeInfo<VType, IDType>())
if(const auto *info = reader->getVectorisedTypeInfo<VType, IDType>())
{
IDType id;
*this >> id;
if(id != IDType(-1))
{
data = static_cast<T>(getVectorItemFromId<VType, IDType>(*info, id));
data = static_cast<T>(reader->getVectorItemFromId<VType, IDType>(*info, id));
return;
}
}
}
if(sendStackInstanceByIds)
if(reader->sendStackInstanceByIds)
{
bool gotLoaded = LoadIfStackInstance<Serializer,T>::invoke(*This(), data);
bool gotLoaded = LoadIfStackInstance<CISer,T>::invoke(* this, data);
if(gotLoaded)
return;
}
@ -1252,7 +1281,7 @@ public:
//get type id
ui16 tid;
*this >> tid;
This()->loadPointerHlp(tid, data, pid);
this->loadPointerHlp(tid, data, pid);
}
//that part of ptr deserialization was extracted to allow customization of its behavior in derived classes
@ -1290,7 +1319,7 @@ public:
if(length > 500000) \
{ \
logGlobal->warnStream() << "Warning: very big length: " << length;\
reportState(logGlobal); \
reader->reportState(logGlobal); \
};
@ -1437,7 +1466,7 @@ public:
{
READ_CHECK_U32(length);
data.resize(length);
this->This()->read((void*)data.c_str(),length);
this->read((void*)data.c_str(),length);
}
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
@ -1506,52 +1535,71 @@ public:
};
class DLL_LINKAGE CSaveFile
: public COSer<CSaveFile>
:public IBinaryWriter
{
public:
COSer serializer;
std::string fName;
unique_ptr<std::ofstream> sfile;
CSaveFile(const std::string &fname); //throws!
~CSaveFile();
int write(const void * data, unsigned size);
int write(const void * data, unsigned size) override;
void openNextFile(const std::string &fname); //throws!
void clear();
void reportState(CLogger * out);
void putMagicBytes(const std::string &text);
template<class T>
CSaveFile & operator<<(const T &t)
{
serializer << t;
return * this;
}
};
class DLL_LINKAGE CLoadFile
: public CISer<CLoadFile>
: public IBinaryReader
{
public:
CISer serializer;
std::string fName;
unique_ptr<boost::filesystem::ifstream> sfile;
CLoadFile(const boost::filesystem::path & fname, int minimalVersion = version); //throws!
~CLoadFile();
int read(void * data, unsigned size); //throws!
int read(void * data, unsigned size) override; //throws!
void openNextFile(const boost::filesystem::path & fname, int minimalVersion); //throws!
void clear();
void reportState(CLogger * out);
void checkMagicBytes(const std::string & text);
template<class T>
CLoadFile & operator>>(T &t)
{
serializer >> t;
return * this;
}
};
class DLL_LINKAGE CLoadIntegrityValidator : public CISer<CLoadIntegrityValidator>
class DLL_LINKAGE CLoadIntegrityValidator
: public IBinaryReader
{
public:
CISer serializer;
unique_ptr<CLoadFile> primaryFile, controlFile;
bool foundDesync;
CLoadIntegrityValidator(const std::string &primaryFileName, const std::string &controlFileName, int minimalVersion = version); //throws!
int read( void * data, unsigned size); //throws!
int read( void * data, unsigned size) override; //throws!
void checkMagicBytes(const std::string &text);
unique_ptr<CLoadFile> decay(); //returns primary file. CLoadIntegrityValidator stops being usable anymore
@ -1561,7 +1609,7 @@ typedef boost::asio::basic_stream_socket < boost::asio::ip::tcp , boost::asio::s
typedef boost::asio::basic_socket_acceptor<boost::asio::ip::tcp, boost::asio::socket_acceptor_service<boost::asio::ip::tcp> > TAcceptor;
class DLL_LINKAGE CConnection
: public CISer<CConnection>, public COSer<CConnection>
: public IBinaryReader, public IBinaryWriter
{
//CGameState *gs;
CConnection(void);
@ -1569,6 +1617,9 @@ class DLL_LINKAGE CConnection
void init();
void reportState(CLogger * out);
public:
CISer iser;
COSer oser;
boost::mutex *rmx, *wmx; // read/write mutexes
TSocket * socket;
bool logging;
@ -1586,8 +1637,8 @@ public:
CConnection(TAcceptor * acceptor, boost::asio::io_service *Io_service, std::string Name);
CConnection(TSocket * Socket, std::string Name); //use immediately after accepting connection into socket
int write(const void * data, unsigned size);
int read(void * data, unsigned size);
int write(const void * data, unsigned size) override;
int read(void * data, unsigned size) override;
void close();
bool isOpen() const;
template<class T>
@ -1606,6 +1657,20 @@ public:
void prepareForSendingHeroes(); //disables sending vectorised, enables smart pointer serialization, clears saved/loaded ptr cache
void enterPregameConnectionMode();
template<class T>
CConnection & operator>>(T &t)
{
iser >> t;
return * this;
}
template<class T>
CConnection & operator<<(const T &t)
{
oser << t;
return * this;
}
};
DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc);
@ -1613,14 +1678,17 @@ DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc);
// Serializer that stores objects in the dynamic buffer. Allows performing deep object copies.
class DLL_LINKAGE CMemorySerializer
: public CISer<CMemorySerializer>, public COSer<CMemorySerializer>
: public IBinaryReader, public IBinaryWriter
{
std::vector<ui8> buffer;
size_t readPos; //index of the next byte to be read
public:
int read(void * data, unsigned size); //throws!
int write(const void * data, unsigned size);
CISer iser;
COSer oser;
int read(void * data, unsigned size) override; //throws!
int write(const void * data, unsigned size) override;
CMemorySerializer();
@ -1628,10 +1696,10 @@ public:
static unique_ptr<T> deepCopy(const T &data)
{
CMemorySerializer mem;
mem << &data;
mem.oser << &data;
unique_ptr<T> ret;
mem >> ret;
mem.iser >> ret;
return ret;
}
};

View File

@ -149,16 +149,16 @@ void CPrivilagedInfoCallback::loadCommonState(Loader &in)
StartInfo *si;
logGlobal->infoStream() <<"\tReading header";
in >> dum;
in.serializer >> dum;
logGlobal->infoStream() << "\tReading options";
in >> si;
in.serializer >> si;
logGlobal->infoStream() <<"\tReading handlers";
in >> *VLC;
in.serializer >> *VLC;
logGlobal->infoStream() <<"\tReading gamestate";
in >> gs;
in.serializer >> gs;
}
template<typename Saver>
@ -167,13 +167,13 @@ void CPrivilagedInfoCallback::saveCommonState(Saver &out) const
logGlobal->infoStream() << "Saving lib part of game...";
out.putMagicBytes(SAVEGAME_MAGIC);
logGlobal->infoStream() <<"\tSaving header";
out << static_cast<CMapHeader&>(*gs->map);
out.serializer << static_cast<CMapHeader&>(*gs->map);
logGlobal->infoStream() << "\tSaving options";
out << gs->scenarioOps;
out.serializer << gs->scenarioOps;
logGlobal->infoStream() << "\tSaving handlers";
out << *VLC;
out.serializer << *VLC;
logGlobal->infoStream() << "\tSaving gamestate";
out << gs;
out.serializer << gs;
}
// hardly memory usage for `-gdwarf-4` flag

View File

@ -27,15 +27,11 @@
// registerTypesServerPacks: 1.3 Gb
// registerTypes4: 1.3 Gb
#define DEFINE_EXTERNAL_METHOD(METHODNAME) \
extern template DLL_LINKAGE void METHODNAME<CISer<CConnection>>(CISer<CConnection>& s); \
extern template DLL_LINKAGE void METHODNAME<COSer<CConnection>>(COSer<CConnection>& s); \
extern template DLL_LINKAGE void METHODNAME<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s); \
extern template DLL_LINKAGE void METHODNAME<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s); \
extern template DLL_LINKAGE void METHODNAME<CSaveFile>(CSaveFile & s); \
extern template DLL_LINKAGE void METHODNAME<CLoadFile>(CLoadFile & s); \
extern template DLL_LINKAGE void METHODNAME<CISer>(CISer & s); \
extern template DLL_LINKAGE void METHODNAME<COSer>(COSer & s); \
extern template DLL_LINKAGE void METHODNAME<CTypeList>(CTypeList & s); \
extern template DLL_LINKAGE void METHODNAME<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
//DEFINE_EXTERNAL_METHOD(registerTypesMapObjects)
DEFINE_EXTERNAL_METHOD(registerTypesMapObjects1)
@ -45,11 +41,6 @@ DEFINE_EXTERNAL_METHOD(registerTypesClientPacks2)
DEFINE_EXTERNAL_METHOD(registerTypesServerPacks)
DEFINE_EXTERNAL_METHOD(registerTypesPregamePacks)
template void registerTypes<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypes<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypes<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypes<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypes<CSaveFile>(CSaveFile & s);
template void registerTypes<CLoadFile>(CLoadFile & s);
template void registerTypes<CISer>(CISer & s);
template void registerTypes<COSer>(COSer & s);
template void registerTypes<CTypeList>(CTypeList & s);
template void registerTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -367,13 +367,10 @@ void registerTypes(Serializer &s)
}
#ifndef INSTANTIATE_REGISTER_TYPES_HERE
extern template DLL_LINKAGE void registerTypes<CISer<CConnection>>(CISer<CConnection>& s);
extern template DLL_LINKAGE void registerTypes<COSer<CConnection>>(COSer<CConnection>& s);
extern template DLL_LINKAGE void registerTypes<CSaveFile>(CSaveFile & s);
extern template DLL_LINKAGE void registerTypes<CLoadFile>(CLoadFile & s);
extern template DLL_LINKAGE void registerTypes<CISer>(CISer & s);
extern template DLL_LINKAGE void registerTypes<COSer>(COSer & s);
extern template DLL_LINKAGE void registerTypes<CTypeList>(CTypeList & s);
extern template DLL_LINKAGE void registerTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);
extern template DLL_LINKAGE void registerTypes<CISer<CMemorySerializer>>(CISer<CMemorySerializer> & s);
extern template DLL_LINKAGE void registerTypes<COSer<CMemorySerializer>>(COSer<CMemorySerializer> & s);
#endif

View File

@ -19,11 +19,6 @@
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesClientPacks1<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesClientPacks1<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesClientPacks1<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesClientPacks1<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesClientPacks1<CSaveFile>(CSaveFile & s);
template void registerTypesClientPacks1<CLoadFile>(CLoadFile & s);
template void registerTypesClientPacks1<CISer>(CISer & s);
template void registerTypesClientPacks1<COSer>(COSer & s);
template void registerTypesClientPacks1<CTypeList>(CTypeList & s);
template void registerTypesClientPacks1<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -19,11 +19,8 @@
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesClientPacks2<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesClientPacks2<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesClientPacks2<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesClientPacks2<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesClientPacks2<CSaveFile>(CSaveFile & s);
template void registerTypesClientPacks2<CLoadFile>(CLoadFile & s);
template void registerTypesClientPacks2<CISer>(CISer & s);
template void registerTypesClientPacks2<COSer>(COSer & s);
template void registerTypesClientPacks2<CTypeList>(CTypeList & s);
template void registerTypesClientPacks2<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -18,12 +18,8 @@
#include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjects1<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjects1<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjects1<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesMapObjects1<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesMapObjects1<CSaveFile>(CSaveFile & s);
template void registerTypesMapObjects1<CLoadFile>(CLoadFile & s);
template void registerTypesMapObjects1<CISer>(CISer & s);
template void registerTypesMapObjects1<COSer>(COSer & s);
template void registerTypesMapObjects1<CTypeList>(CTypeList & s);
template void registerTypesMapObjects1<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -19,12 +19,7 @@
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjects2<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjects2<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjects2<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesMapObjects2<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesMapObjects2<CSaveFile>(CSaveFile & s);
template void registerTypesMapObjects2<CLoadFile>(CLoadFile & s);
template void registerTypesMapObjects2<CISer>(CISer & s);
template void registerTypesMapObjects2<COSer>(COSer & s);
template void registerTypesMapObjects2<CTypeList>(CTypeList & s);
template void registerTypesMapObjects2<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -18,11 +18,6 @@
#include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjectTypes<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesMapObjectTypes<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesMapObjectTypes<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesMapObjectTypes<CSaveFile>(CSaveFile & s);
template void registerTypesMapObjectTypes<CLoadFile>(CLoadFile & s);
template void registerTypesMapObjectTypes<CISer>(CISer & s);
template void registerTypesMapObjectTypes<COSer>(COSer & s);
template void registerTypesMapObjectTypes<CTypeList>(CTypeList & s);
template void registerTypesMapObjectTypes<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -18,11 +18,7 @@
#include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesPregamePacks<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesPregamePacks<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesPregamePacks<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesPregamePacks<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesPregamePacks<CSaveFile>(CSaveFile & s);
template void registerTypesPregamePacks<CLoadFile>(CLoadFile & s);
template void registerTypesPregamePacks<CISer>(CISer & s);
template void registerTypesPregamePacks<COSer>(COSer & s);
template void registerTypesPregamePacks<CTypeList>(CTypeList & s);
template void registerTypesPregamePacks<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);

View File

@ -18,11 +18,6 @@
#include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesServerPacks<CISer<CConnection>>(CISer<CConnection>& s);
template void registerTypesServerPacks<COSer<CConnection>>(COSer<CConnection>& s);
template void registerTypesServerPacks<CISer<CMemorySerializer>>(CISer<CMemorySerializer>& s);
template void registerTypesServerPacks<COSer<CMemorySerializer>>(COSer<CMemorySerializer>& s);
template void registerTypesServerPacks<CSaveFile>(CSaveFile & s);
template void registerTypesServerPacks<CLoadFile>(CLoadFile & s);
template void registerTypesServerPacks<CISer>(CISer & s);
template void registerTypesServerPacks<COSer>(COSer & s);
template void registerTypesServerPacks<CTypeList>(CTypeList & s);
template void registerTypesServerPacks<CLoadIntegrityValidator>(CLoadIntegrityValidator & s);