mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Initial refactoring
* reduce registerTypes* templtates instantiation
This commit is contained in:
parent
fee2184996
commit
3bca68fd2d
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
@ -507,7 +507,7 @@ 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);
|
||||
i->second->saveGame(dynamic_cast<COSer & >(h), version);
|
||||
//evil cast that i still like better than sfinae-magic. If I had a "static if"...
|
||||
}
|
||||
}
|
||||
@ -551,7 +551,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(dynamic_cast<CISer & >(h), version); //another evil cast, check above
|
||||
}
|
||||
|
||||
if(!vstd::contains(battleints, PlayerColor::NEUTRAL))
|
||||
@ -573,7 +573,7 @@ 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);
|
||||
i->second->saveGame(dynamic_cast<COSer & >(h), version);
|
||||
//evil cast that i still like better than sfinae-magic. If I had a "static if"...
|
||||
}
|
||||
}
|
||||
@ -620,7 +620,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(dynamic_cast<CISer & >(h), version); //another evil cast, check above
|
||||
}
|
||||
|
||||
if(playerIDs.count(PlayerColor::NEUTRAL))
|
||||
@ -901,8 +901,8 @@ 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 );
|
||||
template void CClient::serialize(CISer & h, const int version);
|
||||
template void CClient::serialize(COSer & h, const int version);
|
||||
|
||||
void CServerHandler::startServer()
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -878,7 +878,7 @@ void CGameState::initDuel()
|
||||
else
|
||||
{
|
||||
CLoadFile lf(scenarioOps->mapname);
|
||||
lf >> dp;
|
||||
lf.serializer >> dp;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
|
@ -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,37 @@ 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;
|
||||
iser.sendStackInstanceByIds = false;
|
||||
oser.sendStackInstanceByIds = false;
|
||||
}
|
||||
|
||||
void CConnection::enableStackSendingByID()
|
||||
{
|
||||
CISer<CConnection>::sendStackInstanceByIds = true;
|
||||
COSer<CConnection>::sendStackInstanceByIds = true;
|
||||
iser.sendStackInstanceByIds = true;
|
||||
oser.sendStackInstanceByIds = true;
|
||||
}
|
||||
|
||||
void CConnection::disableSmartPointerSerialization()
|
||||
{
|
||||
CISer<CConnection>::smartPointerSerialization = false;
|
||||
COSer<CConnection>::smartPointerSerialization = false;
|
||||
iser.smartPointerSerialization = false;
|
||||
oser.smartPointerSerialization = false;
|
||||
}
|
||||
|
||||
void CConnection::enableSmartPointerSerializatoin()
|
||||
{
|
||||
CISer<CConnection>::smartPointerSerialization = true;
|
||||
COSer<CConnection>::smartPointerSerialization = true;
|
||||
iser.smartPointerSerialization = true;
|
||||
oser.smartPointerSerialization = true;
|
||||
}
|
||||
|
||||
void CConnection::prepareForSendingHeroes()
|
||||
{
|
||||
loadedPointers.clear();
|
||||
savedPointers.clear();
|
||||
iser.loadedPointers.clear();
|
||||
oser.savedPointers.clear();
|
||||
disableSmartVectorMemberSerialization();
|
||||
enableSmartPointerSerializatoin();
|
||||
disableStackSendingByID();
|
||||
@ -276,25 +271,25 @@ void CConnection::prepareForSendingHeroes()
|
||||
|
||||
void CConnection::enterPregameConnectionMode()
|
||||
{
|
||||
loadedPointers.clear();
|
||||
savedPointers.clear();
|
||||
iser.loadedPointers.clear();
|
||||
oser.savedPointers.clear();
|
||||
disableSmartVectorMemberSerialization();
|
||||
disableSmartPointerSerialization();
|
||||
}
|
||||
|
||||
void CConnection::disableSmartVectorMemberSerialization()
|
||||
{
|
||||
smartVectorMembersSerialization = false;
|
||||
iser.smartVectorMembersSerialization = oser.smartVectorMembersSerialization = false;
|
||||
}
|
||||
|
||||
void CConnection::enableSmartVectorMemberSerializatoin()
|
||||
{
|
||||
smartVectorMembersSerialization = true;
|
||||
iser.smartVectorMembersSerialization = oser.smartVectorMembersSerialization = true;
|
||||
}
|
||||
|
||||
CSaveFile::CSaveFile( const std::string &fname )
|
||||
CSaveFile::CSaveFile( const std::string &fname ): serializer(this)
|
||||
{
|
||||
registerTypes(*this);
|
||||
registerTypes(serializer);
|
||||
openNextFile(fname);
|
||||
}
|
||||
|
||||
@ -320,7 +315,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 +345,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 +363,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 +381,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 +422,7 @@ void CLoadFile::clear()
|
||||
{
|
||||
sfile = nullptr;
|
||||
fName.clear();
|
||||
fileVersion = 0;
|
||||
serializer.fileVersion = 0;
|
||||
}
|
||||
|
||||
void CLoadFile::checkMagicBytes( const std::string &text )
|
||||
@ -579,14 +574,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 +610,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 +642,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);
|
||||
}
|
||||
|
||||
|
215
lib/Connection.h
215
lib/Connection.h
@ -570,8 +570,23 @@ public:
|
||||
void addStdVecItems(CGameState *gs, LibClasses *lib = VLC);
|
||||
};
|
||||
|
||||
class IBinaryWriter
|
||||
{
|
||||
public:
|
||||
virtual int write(const void * data, unsigned size) = 0;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CSaverBase : public virtual CSerializer
|
||||
{
|
||||
private:
|
||||
IBinaryWriter * writer;
|
||||
public:
|
||||
CSaverBase(IBinaryWriter * w): writer(w){};
|
||||
|
||||
inline int write(const void * data, unsigned size)
|
||||
{
|
||||
return writer->write(data, size);
|
||||
};
|
||||
};
|
||||
|
||||
class CBasicPointerSaver
|
||||
@ -711,7 +726,7 @@ 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:
|
||||
bool saving;
|
||||
@ -720,7 +735,7 @@ public:
|
||||
std::map<const void*, ui32> savedPointers;
|
||||
bool smartPointerSerialization;
|
||||
|
||||
COSer()
|
||||
COSer(IBinaryWriter * w): CSaverBase(w)
|
||||
{
|
||||
saving=true;
|
||||
smartPointerSerialization = true;
|
||||
@ -738,7 +753,7 @@ public:
|
||||
{
|
||||
auto ID = typeList.getTypeID(t);
|
||||
if(!savers.count(ID))
|
||||
savers[ID] = new CPointerSaver<COSer<Serializer>, T>;
|
||||
savers[ID] = new CPointerSaver<COSer, T>;
|
||||
}
|
||||
|
||||
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)
|
||||
@ -748,31 +763,28 @@ public:
|
||||
addSaver(d);
|
||||
}
|
||||
|
||||
Serializer * This()
|
||||
{
|
||||
return static_cast<Serializer*>(this);
|
||||
}
|
||||
// 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>
|
||||
@ -802,7 +814,7 @@ public:
|
||||
|
||||
if(sendStackInstanceByIds)
|
||||
{
|
||||
const bool gotSaved = SaveIfStackInstance<Serializer,T>::invoke(*This(), data);
|
||||
const bool gotSaved = SaveIfStackInstance<COSer,T>::invoke(*this, data);
|
||||
if(gotSaved)
|
||||
return;
|
||||
}
|
||||
@ -830,7 +842,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 +868,27 @@ public:
|
||||
typedef
|
||||
//if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Boolean> >,
|
||||
mpl::identity<SaveBoolean<Serializer> >,
|
||||
mpl::identity<SaveBoolean<COSer> >,
|
||||
//else if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<BooleanVector> >,
|
||||
mpl::identity<SaveBooleanVector<Serializer> >,
|
||||
mpl::identity<SaveBooleanVector<COSer> >,
|
||||
//else if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
|
||||
mpl::identity<SavePrimitive<Serializer,T> >,
|
||||
mpl::identity<SavePrimitive<COSer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Enum> >,
|
||||
mpl::identity<SaveEnum<Serializer,T> >,
|
||||
mpl::identity<SaveEnum<COSer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
||||
mpl::identity<SavePointer<Serializer,T> >,
|
||||
mpl::identity<SavePointer<COSer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
|
||||
mpl::identity<SaveArray<Serializer,T> >,
|
||||
mpl::identity<SaveArray<COSer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
||||
mpl::identity<SaveSerializable<Serializer,T> >,
|
||||
mpl::identity<SaveSerializable<COSer,T> >,
|
||||
//else
|
||||
mpl::identity<SaveWrong<Serializer,T> >
|
||||
mpl::identity<SaveWrong<COSer,T> >
|
||||
>
|
||||
>
|
||||
>
|
||||
@ -884,7 +896,7 @@ public:
|
||||
>
|
||||
>
|
||||
>::type typex;
|
||||
typex::invoke(* this->This(), data);
|
||||
typex::invoke(* this, data);
|
||||
}
|
||||
template <typename T>
|
||||
void saveSerializable(const T &data)
|
||||
@ -947,7 +959,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 +986,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 +1021,24 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class IBinaryReader
|
||||
{
|
||||
public:
|
||||
virtual int read(void * data, unsigned size) = 0;
|
||||
};
|
||||
|
||||
class DLL_LINKAGE CLoaderBase : public virtual CSerializer
|
||||
{};
|
||||
{
|
||||
private:
|
||||
IBinaryReader * reader;
|
||||
public:
|
||||
CLoaderBase(IBinaryReader * r): reader(r){};
|
||||
|
||||
inline int read(void * data, unsigned size)
|
||||
{
|
||||
return reader->read(data, size);
|
||||
};
|
||||
};
|
||||
|
||||
class CBasicPointerLoader
|
||||
{
|
||||
@ -1059,7 +1085,7 @@ public:
|
||||
};
|
||||
|
||||
/// The class which manages loading of objects.
|
||||
template <typename Serializer> class DLL_LINKAGE CISer : public CLoaderBase
|
||||
class DLL_LINKAGE CISer : public CLoaderBase
|
||||
{
|
||||
public:
|
||||
bool saving;
|
||||
@ -1073,7 +1099,7 @@ public:
|
||||
|
||||
bool smartPointerSerialization;
|
||||
|
||||
CISer()
|
||||
CISer(IBinaryReader * r): CLoaderBase(r)
|
||||
{
|
||||
saving = false;
|
||||
fileVersion = 0;
|
||||
@ -1094,7 +1120,7 @@ public:
|
||||
{
|
||||
auto ID = typeList.getTypeID(t);
|
||||
if(!loaders.count(ID))
|
||||
loaders[ID] = new CPointerLoader<CISer<Serializer>, T>;
|
||||
loaders[ID] = new CPointerLoader<CISer, T>;
|
||||
}
|
||||
|
||||
template<typename Base, typename Derived> void registerType(const Base * b = nullptr, const Derived * d = nullptr)
|
||||
@ -1103,23 +1129,23 @@ public:
|
||||
addLoader(b);
|
||||
addLoader(d);
|
||||
}
|
||||
|
||||
Serializer * This()
|
||||
{
|
||||
return static_cast<Serializer*>(this);
|
||||
}
|
||||
//
|
||||
// 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 +1155,27 @@ public:
|
||||
typedef
|
||||
//if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Boolean> >,
|
||||
mpl::identity<LoadBoolean<Serializer> >,
|
||||
mpl::identity<LoadBoolean<CISer> >,
|
||||
//else if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<BooleanVector> >,
|
||||
mpl::identity<LoadBooleanVector<Serializer> >,
|
||||
mpl::identity<LoadBooleanVector<CISer> >,
|
||||
//else if
|
||||
typename mpl::eval_if< mpl::equal_to<SerializationLevel<T>,mpl::int_<Primitive> >,
|
||||
mpl::identity<LoadPrimitive<Serializer,T> >,
|
||||
mpl::identity<LoadPrimitive<CISer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Enum> >,
|
||||
mpl::identity<LoadEnum<Serializer,T> >,
|
||||
mpl::identity<LoadEnum<CISer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
||||
mpl::identity<LoadPointer<Serializer,T> >,
|
||||
mpl::identity<LoadPointer<CISer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
|
||||
mpl::identity<LoadArray<Serializer,T> >,
|
||||
mpl::identity<LoadArray<CISer,T> >,
|
||||
//else if
|
||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
||||
mpl::identity<LoadSerializable<Serializer,T> >,
|
||||
mpl::identity<LoadSerializable<CISer,T> >,
|
||||
//else
|
||||
mpl::identity<LoadWrong<Serializer,T> >
|
||||
mpl::identity<LoadWrong<CISer,T> >
|
||||
>
|
||||
>
|
||||
>
|
||||
@ -1157,20 +1183,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);
|
||||
}
|
||||
@ -1228,7 +1254,7 @@ public:
|
||||
|
||||
if(sendStackInstanceByIds)
|
||||
{
|
||||
bool gotLoaded = LoadIfStackInstance<Serializer,T>::invoke(*This(), data);
|
||||
bool gotLoaded = LoadIfStackInstance<CISer,T>::invoke(* this, data);
|
||||
if(gotLoaded)
|
||||
return;
|
||||
}
|
||||
@ -1252,7 +1278,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
|
||||
@ -1437,7 +1463,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 +1532,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 +1606,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 +1614,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 +1634,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 +1654,26 @@ 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;
|
||||
}
|
||||
|
||||
void addStdVecItems(CGameState *gs, LibClasses *lib = VLC)
|
||||
{
|
||||
iser.addStdVecItems(gs, lib);
|
||||
oser.addStdVecItems(gs, lib);
|
||||
}
|
||||
};
|
||||
|
||||
DLL_LINKAGE std::ostream &operator<<(std::ostream &str, const CConnection &cpc);
|
||||
@ -1613,14 +1681,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 +1699,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;
|
||||
}
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user