From 2b88a914fffae12b9bc1568dee5c1df68c81d73c Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 21 Dec 2014 22:33:20 +0300 Subject: [PATCH] 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) --- client/Client.cpp | 38 +++++++++++++++++++++----------------- client/Client.h | 9 +++++++-- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/client/Client.cpp b/client/Client.cpp index 64c2b97c7..c259e8690 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -493,11 +493,10 @@ void CClient::newGame( CConnection *con, StartInfo *si ) // } } -template -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(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(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 -void CClient::serialize( Handler &h, const int version, const std::set& playerIDs) +void CClient::serialize(COSer & h, const int version, const std::set & 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::setfirst); assert(i->first == i->second->playerID); h & i->first & i->second->dllName & i->second->human; - i->second->saveGame(dynamic_cast(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 & 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::setloadGame(dynamic_cast(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() { diff --git a/client/Client.h b/client/Client.h index 3740c3a1f..0939197d7 100644 --- a/client/Client.h +++ b/client/Client.h @@ -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 void serialize(Handler &h, const int version); - template void serialize(Handler &h, const int version, const std::set& 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& playerIDs); + void serialize(CISer &h, const int version, const std::set& playerIDs); void battleFinished(); };