From 5b76c3f4eb96caf18a52e7338ccd20f9f77b8fd7 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 10 Sep 2016 03:32:40 +0300 Subject: [PATCH] Rebase of codebase changes for refactored serializer Some of newer fixes not yet merged there and save compatibility a bit off. --- AI/StupidAI/StupidAI.cpp | 4 ++-- AI/StupidAI/StupidAI.h | 4 ++-- AI/VCAI/AIUtility.h | 3 ++- AI/VCAI/VCAI.cpp | 8 +++++--- AI/VCAI/VCAI.h | 5 ++--- CCallback.cpp | 1 - Global.h | 5 ++++- client/CMT.cpp | 3 ++- client/CPlayerInterface.cpp | 8 +++++--- client/CPlayerInterface.h | 4 ++-- client/CPreGame.cpp | 5 +++-- client/Client.cpp | 16 +++++++++------- client/Client.h | 12 ++++++------ client/NetPacksClient.cpp | 3 ++- lib/CGameInterface.cpp | 19 ++++++++++--------- lib/CGameInterface.h | 12 ++++++------ lib/CGameState.cpp | 7 ++++--- lib/CMakeLists.txt | 9 ++++++++- lib/Connection.cpp | 4 ++-- lib/IGameCallback.cpp | 23 ++++++++++++++--------- lib/registerTypes/RegisterTypes.cpp | 12 ++++++++---- lib/registerTypes/RegisterTypes.h | 9 ++++++--- lib/registerTypes/TypesClientPacks1.cpp | 8 ++++++-- lib/registerTypes/TypesClientPacks2.cpp | 8 ++++++-- lib/registerTypes/TypesMapObjects1.cpp | 8 ++++++-- lib/registerTypes/TypesMapObjects2.cpp | 8 ++++++-- lib/registerTypes/TypesMapObjects3.cpp | 8 ++++++-- lib/registerTypes/TypesPregamePacks.cpp | 9 +++++++-- lib/registerTypes/TypesServerPacks.cpp | 8 ++++++-- server/CGameHandler.cpp | 8 +++++--- server/CGameHandler.h | 1 - server/CVCMIServer.cpp | 3 ++- server/NetPacksServer.cpp | 1 + 33 files changed, 155 insertions(+), 91 deletions(-) diff --git a/AI/StupidAI/StupidAI.cpp b/AI/StupidAI/StupidAI.cpp index 7f74bf433..0777a5e1a 100644 --- a/AI/StupidAI/StupidAI.cpp +++ b/AI/StupidAI/StupidAI.cpp @@ -327,13 +327,13 @@ BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination) } } -void CStupidAI::saveGame(COSer & h, const int version) +void CStupidAI::saveGame(BinarySerializer & h, const int version) { //TODO to be implemented with saving/loading during the battles assert(0); } -void CStupidAI::loadGame(CISer & h, const int version) +void CStupidAI::loadGame(BinaryDeserializer & h, const int version) { //TODO to be implemented with saving/loading during the battles assert(0); diff --git a/AI/StupidAI/StupidAI.h b/AI/StupidAI/StupidAI.h index a8a96e33e..439a1d3cf 100644 --- a/AI/StupidAI/StupidAI.h +++ b/AI/StupidAI/StupidAI.h @@ -36,8 +36,8 @@ public: BattleAction goTowards(const CStack * stack, BattleHex hex ); - virtual void saveGame(COSer & h, const int version) override; - virtual void loadGame(CISer & h, const int version) override; + virtual void saveGame(BinarySerializer & h, const int version) override; + virtual void loadGame(BinaryDeserializer & h, const int version) override; }; diff --git a/AI/VCAI/AIUtility.h b/AI/VCAI/AIUtility.h index abf6a3b47..bbe96f897 100644 --- a/AI/VCAI/AIUtility.h +++ b/AI/VCAI/AIUtility.h @@ -5,8 +5,9 @@ #include "../../lib/CCreatureHandler.h" #include "../../lib/CTownHandler.h" #include "../../lib/spells/CSpellHandler.h" -#include "../../lib/Connection.h" #include "../../lib/CStopWatch.h" +#include "../../lib/mapObjects/CObjectHandler.h" +#include "../../lib/mapObjects/CGHeroInstance.h" /* * AIUtility.h, part of VCMI engine diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 3162b2ef1..841c21383 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -9,7 +9,9 @@ #include "../../lib/CModHandler.h" #include "../../lib/CGameState.h" #include "../../lib/NetPacks.h" - +#include "../../lib/serializer/CTypeList.h" +#include "../../lib/serializer/BinarySerializer.h" +#include "../../lib/serializer/BinaryDeserializer.h" /* * VCAI.cpp, part of VCMI engine @@ -705,7 +707,7 @@ void VCAI::showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *do }); } -void VCAI::saveGame(COSer & h, const int version) +void VCAI::saveGame(BinarySerializer & h, const int version) { LOG_TRACE_PARAMS(logAi, "version '%i'", version); NET_EVENT_HANDLER; @@ -716,7 +718,7 @@ void VCAI::saveGame(COSer & h, const int version) serializeInternal(h, version); } -void VCAI::loadGame(CISer & h, const int version) +void VCAI::loadGame(BinaryDeserializer & h, const int version) { LOG_TRACE_PARAMS(logAi, "version '%i'", version); NET_EVENT_HANDLER; diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index 136ce7488..f82b8c037 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -14,7 +14,6 @@ #include "../../lib/CTownHandler.h" #include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/spells/CSpellHandler.h" -#include "../../lib/Connection.h" #include "../../lib/CondSh.h" struct QuestInfo; @@ -189,8 +188,8 @@ public: virtual void showBlockingDialog(const std::string &text, const std::vector &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 showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override; - virtual void saveGame(COSer & h, const int version) override; //saving - virtual void loadGame(CISer & h, const int version) override; //loading + virtual void saveGame(BinarySerializer & h, const int version) override; //saving + virtual void loadGame(BinaryDeserializer & h, const int version) override; //loading virtual void finish() override; virtual void availableCreaturesChanged(const CGDwelling *town) override; diff --git a/CCallback.cpp b/CCallback.cpp index 84d55d946..1b965ebd4 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -12,7 +12,6 @@ #include "lib/mapObjects/CObjectClassesHandler.h" #include "lib/CGeneralTextHandler.h" #include "lib/CHeroHandler.h" -#include "lib/Connection.h" #include "lib/NetPacks.h" #include "client/mapHandler.h" #include "lib/spells/CSpellHandler.h" diff --git a/Global.h b/Global.h index 3dabeba83..b661afa91 100644 --- a/Global.h +++ b/Global.h @@ -108,6 +108,10 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # define STRONG_INLINE inline #endif +#define TO_STRING_HELPER(x) #x +#define TO_STRING(x) TO_STRING_HELPER(x) +#define LINE_IN_FILE __FILE__ ":" TO_STRING(__LINE__) + #define _USE_MATH_DEFINES #include @@ -222,7 +226,6 @@ typedef boost::lock_guard TLockGuardRec; # define DLL_IMPORT __attribute__ ((visibility("default"))) # define DLL_EXPORT __attribute__ ((visibility("default"))) # define ELF_VISIBILITY __attribute__ ((visibility("default"))) -# define ELF_VISIBILITY __attribute__ ((visibility("default"))) # endif #endif diff --git a/client/CMT.cpp b/client/CMT.cpp index de65277c6..1a27d974b 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -27,7 +27,8 @@ #include "Graphics.h" #include "Client.h" #include "../lib/CConfigHandler.h" -#include "../lib/Connection.h" +#include "../lib/serializer/BinaryDeserializer.h" +#include "../lib/serializer/BinarySerializer.h" #include "../lib/VCMI_Lib.h" #include "../lib/VCMIDirs.h" #include "../lib/NetPacks.h" diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 35bffe24a..6d3f79846 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -22,7 +22,9 @@ #include "../lib/CArtHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" -#include "../lib/Connection.h" +#include "../lib/serializer/CTypeList.h" +#include "../lib/serializer/BinaryDeserializer.h" +#include "../lib/serializer/BinarySerializer.h" #include "../lib/spells/CSpellHandler.h" #include "../lib/CTownHandler.h" #include "../lib/mapObjects/CObjectClassesHandler.h" // For displaying correct UI when interacting with objects @@ -1310,13 +1312,13 @@ template void CPlayerInterface::serializeTempl( Handler &h, c h & spellbookSettings; } -void CPlayerInterface::saveGame( COSer & h, const int version ) +void CPlayerInterface::saveGame( BinarySerializer & h, const int version ) { EVENT_HANDLER_CALLED_BY_CLIENT; serializeTempl(h,version); } -void CPlayerInterface::loadGame( CISer & h, const int version ) +void CPlayerInterface::loadGame( BinaryDeserializer & h, const int version ) { EVENT_HANDLER_CALLED_BY_CLIENT; serializeTempl(h,version); diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index 4bff5d61a..53c259b08 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -192,8 +192,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 & h, const int version) override; //saving - void loadGame(CISer & h, const int version) override; //loading + void saveGame(BinarySerializer & h, const int version) override; //saving + void loadGame(BinaryDeserializer & h, const int version) override; //loading void showWorldViewEx(const std::vector & objectPositions) override; //for battles diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 8b9ef86d6..a9522fa73 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -17,7 +17,8 @@ #include "CMusicHandler.h" #include "CVideoHandler.h" #include "Graphics.h" -#include "../lib/Connection.h" +#include "../lib/serializer/Connection.h" +#include "../lib/serializer/CTypeList.h" #include "../lib/VCMIDirs.h" #include "../lib/mapping/CMap.h" #include "windows/GUIClasses.h" @@ -1011,7 +1012,7 @@ void CSelectionScreen::processPacks() { CPackForSelectionScreen *pack = upcomingPacks.front(); upcomingPacks.pop_front(); - CBaseForPGApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier + CBaseForPGApply *apply = applier->getApplier(typeList.getTypeID(pack)); //find the applier apply->applyOnPG(this, pack); delete pack; } diff --git a/client/Client.cpp b/client/Client.cpp index 9bf2f1425..0e175b54a 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -19,7 +19,9 @@ #include "../lib/CTownHandler.h" #include "../lib/CBuildingHandler.h" #include "../lib/spells/CSpellHandler.h" -#include "../lib/Connection.h" +#include "../lib/serializer/CTypeList.h" +#include "../lib/serializer/Connection.h" +#include "../lib/serializer/CLoadIntegrityValidator.h" #ifndef VCMI_ANDROID #include "../lib/Interprocess.h" #endif @@ -510,7 +512,7 @@ void CClient::newGame( CConnection *con, StartInfo *si ) // } } -void CClient::serialize(COSer & h, const int version) +void CClient::serialize(BinarySerializer & h, const int version) { assert(h.saving); h & hotSeat; @@ -528,7 +530,7 @@ void CClient::serialize(COSer & h, const int version) } } -void CClient::serialize(CISer & h, const int version) +void CClient::serialize(BinaryDeserializer & h, const int version) { assert(!h.saving); h & hotSeat; @@ -579,7 +581,7 @@ void CClient::serialize(CISer & h, const int version) } } -void CClient::serialize(COSer & h, const int version, const std::set & playerIDs) +void CClient::serialize(BinarySerializer & h, const int version, const std::set & playerIDs) { assert(h.saving); h & hotSeat; @@ -597,7 +599,7 @@ void CClient::serialize(COSer & h, const int version, const std::set & playerIDs) +void CClient::serialize(BinaryDeserializer & h, const int version, const std::set & playerIDs) { assert(!h.saving); h & hotSeat; @@ -653,12 +655,12 @@ void CClient::serialize(CISer & h, const int version, const std::seterror("Dropping nullptr CPack! You should check whether client and server ABI matches."); return; } - CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier + CBaseForCLApply *apply = applier->getApplier(typeList.getTypeID(pack)); //find the applier if(apply) { boost::unique_lock guiLock(*LOCPLINT->pim); diff --git a/client/Client.h b/client/Client.h index 8d250321e..ef7c55836 100644 --- a/client/Client.h +++ b/client/Client.h @@ -32,8 +32,8 @@ struct SharedMem; class CClient; class CScriptingModule; struct CPathsInfo; -class CISer; -class COSer; +class BinaryDeserializer; +class BinarySerializer; namespace boost { class thread; } /// structure to handle running server and connecting to it @@ -238,10 +238,10 @@ public: ////////////////////////////////////////////////////////////////////////// - void serialize(COSer &h, const int version); - void serialize(CISer &h, const int version); + void serialize(BinarySerializer & h, const int version); + void serialize(BinaryDeserializer & 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 serialize(BinarySerializer & h, const int version, const std::set& playerIDs); + void serialize(BinaryDeserializer & h, const int version, const std::set& playerIDs); void battleFinished(); }; diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 3149fdbcd..742564977 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -7,7 +7,8 @@ #include "Client.h" #include "CPlayerInterface.h" #include "CGameInfo.h" -#include "../lib/Connection.h" +#include "../lib/serializer/Connection.h" +#include "../lib/serializer/BinarySerializer.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/VCMI_Lib.h" diff --git a/lib/CGameInterface.cpp b/lib/CGameInterface.cpp index 8d301b394..977c548b1 100644 --- a/lib/CGameInterface.cpp +++ b/lib/CGameInterface.cpp @@ -9,7 +9,8 @@ #else #include #endif -#include "Connection.h" +#include "serializer/BinaryDeserializer.h" +#include "serializer/BinarySerializer.h" /* * CGameInterface.cpp, part of VCMI engine @@ -243,29 +244,29 @@ void CAdventureAI::yourTacticPhase(int distance) battleAI->yourTacticPhase(distance); } -void CAdventureAI::saveGame(COSer & h, const int version) /*saving */ +void CAdventureAI::saveGame(BinarySerializer & h, const int version) /*saving */ { LOG_TRACE_PARAMS(logAi, "version '%i'", version); CGlobalAI::saveGame(h, version); bool hasBattleAI = static_cast(battleAI); - h << hasBattleAI; + h & hasBattleAI; if(hasBattleAI) { - h << std::string(battleAI->dllName); + h & std::string(battleAI->dllName); battleAI->saveGame(h, version); } } -void CAdventureAI::loadGame(CISer & h, const int version) /*loading */ +void CAdventureAI::loadGame(BinaryDeserializer & h, const int version) /*loading */ { LOG_TRACE_PARAMS(logAi, "version '%i'", version); CGlobalAI::loadGame(h, version); bool hasBattleAI = false; - h >> hasBattleAI; + h & hasBattleAI; if(hasBattleAI) { std::string dllName; - h >> dllName; + h & dllName; battleAI = CDynLibHandler::getNewBattleAI(dllName); assert(cbc); //it should have been set by the one who new'ed us battleAI->init(cbc); @@ -273,10 +274,10 @@ void CAdventureAI::loadGame(CISer & h, const int version) /*loading */ } } -void CBattleGameInterface::saveGame(COSer & h, const int version) +void CBattleGameInterface::saveGame(BinarySerializer & h, const int version) { } -void CBattleGameInterface::loadGame(CISer & h, const int version) +void CBattleGameInterface::loadGame(BinaryDeserializer & h, const int version) { } diff --git a/lib/CGameInterface.h b/lib/CGameInterface.h index bba6027c9..08e293a63 100644 --- a/lib/CGameInterface.h +++ b/lib/CGameInterface.h @@ -54,8 +54,8 @@ struct CPathsInfo; class CCreature; class CLoadFile; class CSaveFile; -class CISer; -class COSer; +class BinaryDeserializer; +class BinarySerializer; struct ArtifactLocation; class CScriptingModule; @@ -73,8 +73,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 &h, const int version); - virtual void loadGame(CISer &h, const int version); + virtual void saveGame(BinarySerializer & h, const int version); + virtual void loadGame(BinaryDeserializer & h, const int version); }; @@ -150,6 +150,6 @@ public: virtual void battleEnd(const BattleResult *br) override; virtual void battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; - virtual void saveGame(COSer & h, const int version) override; //saving - virtual void loadGame(CISer & h, const int version) override; //loading + virtual void saveGame(BinarySerializer & h, const int version) override; //saving + virtual void loadGame(BinaryDeserializer & h, const int version) override; //loading }; diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 7d6100c46..3de4d4c4a 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -11,7 +11,6 @@ #include "CHeroHandler.h" #include "mapObjects/CObjectHandler.h" #include "CModHandler.h" -#include "Connection.h" #include "mapping/CMap.h" #include "mapping/CMapService.h" #include "StartInfo.h" @@ -25,6 +24,8 @@ #include "rmg/CMapGenerator.h" #include "CStopWatch.h" #include "mapping/CMapEditManager.h" +#include "serializer/CTypeList.h" +#include "serializer/CMemorySerializer.h" #ifdef min #undef min @@ -871,7 +872,7 @@ void CGameState::initDuel() else { CLoadFile lf(scenarioOps->mapname); - lf.serializer >> dp; + lf.serializer & dp; } } catch(...) @@ -2059,7 +2060,7 @@ PlayerRelations::PlayerRelations CGameState::getPlayerRelations( PlayerColor col void CGameState::apply(CPack *pack) { ui16 typ = typeList.getTypeID(pack); - applierGs->apps[typ]->applyOnGS(this,pack); + applierGs->getApplier(typ)->applyOnGS(this,pack); } void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index bd4508242..02ce6b2a6 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -59,6 +59,14 @@ set(lib_SRCS rmg/CRmgTemplateStorage.cpp rmg/CZoneGraphGenerator.cpp rmg/CZonePlacer.cpp + + serializer/BinaryDeserializer.cpp + serializer/BinarySerializer.cpp + serializer/CLoadIntegrityValidator.cpp + serializer/CMemorySerializer.cpp + serializer/Connection.cpp + serializer/CSerializer.cpp + serializer/CTypeList.cpp spells/CSpellHandler.cpp spells/ISpellMechanics.cpp @@ -102,7 +110,6 @@ set(lib_SRCS CGameInfoCallback.cpp CPathfinder.cpp CGameState.cpp - Connection.cpp NetPacksLib.cpp serializer/JsonSerializer.cpp diff --git a/lib/Connection.cpp b/lib/Connection.cpp index 91081fa16..47833e325 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -18,8 +18,8 @@ * */ -extern template void registerTypes(CISer & s); -extern template void registerTypes(COSer & s); +extern template void registerTypes(BinaryDeserializer & s); +extern template void registerTypes(BinarySerializer & s); extern template void registerTypes(CTypeList & s); CTypeList typeList; diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index bc0b57581..ee0c4206e 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -17,7 +17,12 @@ #include "CBonusTypeHandler.h" #include "CModHandler.h" -#include "Connection.h" // for SAVEGAME_MAGIC +#include "serializer/CSerializer.h" // for SAVEGAME_MAGIC +#include "serializer/BinaryDeserializer.h" +#include "serializer/BinarySerializer.h" +#include "serializer/CLoadIntegrityValidator.h" +#include "rmg/CMapGenOptions.h" +#include "mapping/CCampaignHandler.h" #include "mapObjects/CObjectClassesHandler.h" #include "StartInfo.h" #include "CGameState.h" @@ -157,16 +162,16 @@ void CPrivilagedInfoCallback::loadCommonState(Loader &in) StartInfo *si; logGlobal->infoStream() <<"\tReading header"; - in.serializer >> dum; + in.serializer & dum; logGlobal->infoStream() << "\tReading options"; - in.serializer >> si; + in.serializer & si; logGlobal->infoStream() <<"\tReading handlers"; - in.serializer >> *VLC; + in.serializer & *VLC; logGlobal->infoStream() <<"\tReading gamestate"; - in.serializer >> gs; + in.serializer & gs; } template @@ -175,13 +180,13 @@ void CPrivilagedInfoCallback::saveCommonState(Saver &out) const logGlobal->infoStream() << "Saving lib part of game..."; out.putMagicBytes(SAVEGAME_MAGIC); logGlobal->infoStream() <<"\tSaving header"; - out.serializer << static_cast(*gs->map); + out.serializer & static_cast(*gs->map); logGlobal->infoStream() << "\tSaving options"; - out.serializer << gs->scenarioOps; + out.serializer & gs->scenarioOps; logGlobal->infoStream() << "\tSaving handlers"; - out.serializer << *VLC; + out.serializer & *VLC; logGlobal->infoStream() << "\tSaving gamestate"; - out.serializer << gs; + out.serializer & gs; } // hardly memory usage for `-gdwarf-4` flag diff --git a/lib/registerTypes/RegisterTypes.cpp b/lib/registerTypes/RegisterTypes.cpp index 77f3ead3a..a0f116094 100644 --- a/lib/registerTypes/RegisterTypes.cpp +++ b/lib/registerTypes/RegisterTypes.cpp @@ -12,6 +12,10 @@ #include "../spells/CSpellHandler.h" #include "../mapping/CCampaignHandler.h" +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" + // For reference: peak memory usage by gcc during compilation of register type templates // registerTypesMapObjects: 1.9 Gb // registerTypes2: 2.2 Gb @@ -22,8 +26,8 @@ #define DEFINE_EXTERNAL_METHOD(METHODNAME) \ -extern template DLL_LINKAGE void METHODNAME(CISer & s); \ -extern template DLL_LINKAGE void METHODNAME(COSer & s); \ +extern template DLL_LINKAGE void METHODNAME(BinaryDeserializer & s); \ +extern template DLL_LINKAGE void METHODNAME(BinarySerializer & s); \ extern template DLL_LINKAGE void METHODNAME(CTypeList & s); \ //DEFINE_EXTERNAL_METHOD(registerTypesMapObjects) @@ -34,6 +38,6 @@ DEFINE_EXTERNAL_METHOD(registerTypesClientPacks2) DEFINE_EXTERNAL_METHOD(registerTypesServerPacks) DEFINE_EXTERNAL_METHOD(registerTypesPregamePacks) -template void registerTypes(CISer & s); -template void registerTypes(COSer & s); +template void registerTypes(BinaryDeserializer & s); +template void registerTypes(BinarySerializer & s); template void registerTypes(CTypeList & s); diff --git a/lib/registerTypes/RegisterTypes.h b/lib/registerTypes/RegisterTypes.h index b1982bb9a..77816278d 100644 --- a/lib/registerTypes/RegisterTypes.h +++ b/lib/registerTypes/RegisterTypes.h @@ -1,6 +1,5 @@ #pragma once -#include "../Connection.h" #include "../NetPacks.h" #include "../VCMI_Lib.h" #include "../CArtHandler.h" @@ -24,6 +23,10 @@ * */ +class BinarySerializer; +class BinaryDeserializer; +class CTypeList; + template void registerTypesMapObjects1(Serializer &s) { @@ -376,8 +379,8 @@ void registerTypes(Serializer &s) #ifndef INSTANTIATE_REGISTER_TYPES_HERE -extern template DLL_LINKAGE void registerTypes(CISer & s); -extern template DLL_LINKAGE void registerTypes(COSer & s); +extern template DLL_LINKAGE void registerTypes(BinaryDeserializer & s); +extern template DLL_LINKAGE void registerTypes(BinarySerializer & s); extern template DLL_LINKAGE void registerTypes(CTypeList & s); #endif diff --git a/lib/registerTypes/TypesClientPacks1.cpp b/lib/registerTypes/TypesClientPacks1.cpp index cb7471787..28986b6f8 100644 --- a/lib/registerTypes/TypesClientPacks1.cpp +++ b/lib/registerTypes/TypesClientPacks1.cpp @@ -18,7 +18,11 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" -template void registerTypesClientPacks1(CISer & s); -template void registerTypesClientPacks1(COSer & s); + +template void registerTypesClientPacks1(BinaryDeserializer & s); +template void registerTypesClientPacks1(BinarySerializer & s); template void registerTypesClientPacks1(CTypeList & s); diff --git a/lib/registerTypes/TypesClientPacks2.cpp b/lib/registerTypes/TypesClientPacks2.cpp index 6dee5e84e..cf371cd13 100644 --- a/lib/registerTypes/TypesClientPacks2.cpp +++ b/lib/registerTypes/TypesClientPacks2.cpp @@ -18,9 +18,13 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" -template void registerTypesClientPacks2(CISer & s); -template void registerTypesClientPacks2(COSer & s); + +template void registerTypesClientPacks2(BinaryDeserializer & s); +template void registerTypesClientPacks2(BinarySerializer & s); template void registerTypesClientPacks2(CTypeList & s); diff --git a/lib/registerTypes/TypesMapObjects1.cpp b/lib/registerTypes/TypesMapObjects1.cpp index 6f28f4fde..d977a69e8 100644 --- a/lib/registerTypes/TypesMapObjects1.cpp +++ b/lib/registerTypes/TypesMapObjects1.cpp @@ -18,8 +18,12 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" -template void registerTypesMapObjects1(CISer & s); -template void registerTypesMapObjects1(COSer & s); +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" + +template void registerTypesMapObjects1(BinaryDeserializer & s); +template void registerTypesMapObjects1(BinarySerializer & s); template void registerTypesMapObjects1(CTypeList & s); diff --git a/lib/registerTypes/TypesMapObjects2.cpp b/lib/registerTypes/TypesMapObjects2.cpp index 676e29700..67897b7a2 100644 --- a/lib/registerTypes/TypesMapObjects2.cpp +++ b/lib/registerTypes/TypesMapObjects2.cpp @@ -18,8 +18,12 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" -template void registerTypesMapObjects2(CISer & s); -template void registerTypesMapObjects2(COSer & s); + +template void registerTypesMapObjects2(BinaryDeserializer & s); +template void registerTypesMapObjects2(BinarySerializer & s); template void registerTypesMapObjects2(CTypeList & s); diff --git a/lib/registerTypes/TypesMapObjects3.cpp b/lib/registerTypes/TypesMapObjects3.cpp index 12bd4d818..3dcb08ba2 100644 --- a/lib/registerTypes/TypesMapObjects3.cpp +++ b/lib/registerTypes/TypesMapObjects3.cpp @@ -18,6 +18,10 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" -template void registerTypesMapObjectTypes(CISer & s); -template void registerTypesMapObjectTypes(COSer & s); +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" + +template void registerTypesMapObjectTypes(BinaryDeserializer & s); +template void registerTypesMapObjectTypes(BinarySerializer & s); template void registerTypesMapObjectTypes(CTypeList & s); diff --git a/lib/registerTypes/TypesPregamePacks.cpp b/lib/registerTypes/TypesPregamePacks.cpp index 7f6aeb46a..2fba9ac9e 100644 --- a/lib/registerTypes/TypesPregamePacks.cpp +++ b/lib/registerTypes/TypesPregamePacks.cpp @@ -17,8 +17,13 @@ #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" +#include "../rmg/CMapGenOptions.h" -template void registerTypesPregamePacks(CISer & s); -template void registerTypesPregamePacks(COSer & s); +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" + +template void registerTypesPregamePacks(BinaryDeserializer & s); +template void registerTypesPregamePacks(BinarySerializer & s); template void registerTypesPregamePacks(CTypeList & s); diff --git a/lib/registerTypes/TypesServerPacks.cpp b/lib/registerTypes/TypesServerPacks.cpp index c46a0c628..291014c0b 100644 --- a/lib/registerTypes/TypesServerPacks.cpp +++ b/lib/registerTypes/TypesServerPacks.cpp @@ -18,6 +18,10 @@ #include "../NetPacks.h" #include "../mapObjects/CObjectClassesHandler.h" -template void registerTypesServerPacks(CISer & s); -template void registerTypesServerPacks(COSer & s); +#include "../serializer/BinaryDeserializer.h" +#include "../serializer/BinarySerializer.h" +#include "../serializer/CTypeList.h" + +template void registerTypesServerPacks(BinaryDeserializer & s); +template void registerTypesServerPacks(BinarySerializer & s); template void registerTypesServerPacks(CTypeList & s); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index f5307ed9c..291ee01b4 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -20,6 +20,7 @@ #include "../lib/NetPacks.h" #include "../lib/VCMI_Lib.h" #include "../lib/mapping/CMap.h" +#include "../lib/rmg/CMapGenOptions.h" #include "../lib/VCMIDirs.h" #include "../lib/ScopeGuard.h" #include "../lib/CSoundBase.h" @@ -29,6 +30,8 @@ #include "../lib/CThreadHelper.h" #include "../lib/GameConstants.h" #include "../lib/registerTypes/RegisterTypes.h" +#include "../lib/serializer/CTypeList.h" +#include "../lib/serializer/Connection.h" /* * CGameHandler.cpp, part of VCMI engine @@ -957,9 +960,8 @@ void CGameHandler::handleConnection(std::set players, CConnection & boost::unique_lock lock(*c.wmx); c << &applied; }; - - CBaseForGHApply *apply = applier->apps[packType]; //and appropriate applier object - if (isBlockedByQueries(pack, player)) + CBaseForGHApply *apply = applier->getApplier(packType); //and appropriate applier object + if(isBlockedByQueries(pack, player)) { sendPackageResponse(false); } diff --git a/server/CGameHandler.h b/server/CGameHandler.h index a707bbfe2..2f0ba6172 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -2,7 +2,6 @@ #include "../lib/FunctionList.h" -#include "../lib/Connection.h" #include "../lib/IGameCallback.h" #include "../lib/BattleAction.h" #include "CQuery.h" diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index ea7c4f329..e62dc0215 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -5,7 +5,7 @@ #include "../lib/filesystem/Filesystem.h" #include "../lib/mapping/CCampaignHandler.h" #include "../lib/CThreadHelper.h" -#include "../lib/Connection.h" +#include "../lib/serializer/Connection.h" #include "../lib/CModHandler.h" #include "../lib/CArtHandler.h" #include "../lib/CGeneralTextHandler.h" @@ -18,6 +18,7 @@ #include "CVCMIServer.h" #include "../lib/StartInfo.h" #include "../lib/mapping/CMap.h" +#include "../lib/rmg/CMapGenOptions.h" #ifndef VCMI_ANDROID #include "../lib/Interprocess.h" #endif diff --git a/server/NetPacksServer.cpp b/server/NetPacksServer.cpp index 7938e8ae1..998ab86cc 100644 --- a/server/NetPacksServer.cpp +++ b/server/NetPacksServer.cpp @@ -7,6 +7,7 @@ #include "../lib/CGameState.h" #include "../lib/BattleState.h" #include "../lib/BattleAction.h" +#include "../lib/serializer/Connection.h" #define PLAYER_OWNS(id) (gh->getPlayerAt(c)==gh->getOwner(id))