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

Fix client build

* use regular overloaded methods for client serialization.
(serialize template not needed if connection.h already included and save/load code is different)
This commit is contained in:
AlexVinS 2014-12-21 22:33:20 +03:00
parent 74161198c4
commit 2b88a914ff
2 changed files with 28 additions and 19 deletions

View File

@ -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 & >(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 & >(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 & >(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 & >(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 & h, const int version);
template void CClient::serialize(COSer & 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();
};