1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-02 00:10:22 +02:00

Rebase of codebase changes for refactored serializer

Some of newer fixes not yet merged there and save compatibility a bit off.
This commit is contained in:
Ivan Savenko 2016-09-10 03:32:40 +03:00 committed by Arseniy Shestakov
parent 3d1b1f4ba8
commit 5b76c3f4eb
33 changed files with 155 additions and 91 deletions

View File

@ -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 //TODO to be implemented with saving/loading during the battles
assert(0); 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 //TODO to be implemented with saving/loading during the battles
assert(0); assert(0);

View File

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

View File

@ -5,8 +5,9 @@
#include "../../lib/CCreatureHandler.h" #include "../../lib/CCreatureHandler.h"
#include "../../lib/CTownHandler.h" #include "../../lib/CTownHandler.h"
#include "../../lib/spells/CSpellHandler.h" #include "../../lib/spells/CSpellHandler.h"
#include "../../lib/Connection.h"
#include "../../lib/CStopWatch.h" #include "../../lib/CStopWatch.h"
#include "../../lib/mapObjects/CObjectHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h"
/* /*
* AIUtility.h, part of VCMI engine * AIUtility.h, part of VCMI engine

View File

@ -9,7 +9,9 @@
#include "../../lib/CModHandler.h" #include "../../lib/CModHandler.h"
#include "../../lib/CGameState.h" #include "../../lib/CGameState.h"
#include "../../lib/NetPacks.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 * 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); LOG_TRACE_PARAMS(logAi, "version '%i'", version);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
@ -716,7 +718,7 @@ void VCAI::saveGame(COSer & h, const int version)
serializeInternal(h, 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); LOG_TRACE_PARAMS(logAi, "version '%i'", version);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;

View File

@ -14,7 +14,6 @@
#include "../../lib/CTownHandler.h" #include "../../lib/CTownHandler.h"
#include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/mapObjects/MiscObjects.h"
#include "../../lib/spells/CSpellHandler.h" #include "../../lib/spells/CSpellHandler.h"
#include "../../lib/Connection.h"
#include "../../lib/CondSh.h" #include "../../lib/CondSh.h"
struct QuestInfo; struct QuestInfo;
@ -189,8 +188,8 @@ public:
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 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 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 showTeleportDialog(TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID) override;
virtual void saveGame(COSer & h, const int version) override; //saving virtual void saveGame(BinarySerializer & h, const int version) override; //saving
virtual void loadGame(CISer & h, const int version) override; //loading virtual void loadGame(BinaryDeserializer & h, const int version) override; //loading
virtual void finish() override; virtual void finish() override;
virtual void availableCreaturesChanged(const CGDwelling *town) override; virtual void availableCreaturesChanged(const CGDwelling *town) override;

View File

@ -12,7 +12,6 @@
#include "lib/mapObjects/CObjectClassesHandler.h" #include "lib/mapObjects/CObjectClassesHandler.h"
#include "lib/CGeneralTextHandler.h" #include "lib/CGeneralTextHandler.h"
#include "lib/CHeroHandler.h" #include "lib/CHeroHandler.h"
#include "lib/Connection.h"
#include "lib/NetPacks.h" #include "lib/NetPacks.h"
#include "client/mapHandler.h" #include "client/mapHandler.h"
#include "lib/spells/CSpellHandler.h" #include "lib/spells/CSpellHandler.h"

View File

@ -108,6 +108,10 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
# define STRONG_INLINE inline # define STRONG_INLINE inline
#endif #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 #define _USE_MATH_DEFINES
#include <cstdio> #include <cstdio>
@ -222,7 +226,6 @@ typedef boost::lock_guard<boost::recursive_mutex> TLockGuardRec;
# define DLL_IMPORT __attribute__ ((visibility("default"))) # define DLL_IMPORT __attribute__ ((visibility("default")))
# define DLL_EXPORT __attribute__ ((visibility("default"))) # define DLL_EXPORT __attribute__ ((visibility("default")))
# define ELF_VISIBILITY __attribute__ ((visibility("default"))) # define ELF_VISIBILITY __attribute__ ((visibility("default")))
# define ELF_VISIBILITY __attribute__ ((visibility("default")))
# endif # endif
#endif #endif

View File

@ -27,7 +27,8 @@
#include "Graphics.h" #include "Graphics.h"
#include "Client.h" #include "Client.h"
#include "../lib/CConfigHandler.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/VCMI_Lib.h"
#include "../lib/VCMIDirs.h" #include "../lib/VCMIDirs.h"
#include "../lib/NetPacks.h" #include "../lib/NetPacks.h"

View File

@ -22,7 +22,9 @@
#include "../lib/CArtHandler.h" #include "../lib/CArtHandler.h"
#include "../lib/CGeneralTextHandler.h" #include "../lib/CGeneralTextHandler.h"
#include "../lib/CHeroHandler.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/spells/CSpellHandler.h"
#include "../lib/CTownHandler.h" #include "../lib/CTownHandler.h"
#include "../lib/mapObjects/CObjectClassesHandler.h" // For displaying correct UI when interacting with objects #include "../lib/mapObjects/CObjectClassesHandler.h" // For displaying correct UI when interacting with objects
@ -1310,13 +1312,13 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c
h & spellbookSettings; h & spellbookSettings;
} }
void CPlayerInterface::saveGame( COSer & h, const int version ) void CPlayerInterface::saveGame( BinarySerializer & h, const int version )
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
serializeTempl(h,version); serializeTempl(h,version);
} }
void CPlayerInterface::loadGame( CISer & h, const int version ) void CPlayerInterface::loadGame( BinaryDeserializer & h, const int version )
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
serializeTempl(h,version); serializeTempl(h,version);

View File

@ -192,8 +192,8 @@ public:
void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) override; void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) override;
void playerStartsTurn(PlayerColor player) override; //called before yourTurn on active itnerface 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 showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox
void saveGame(COSer & h, const int version) override; //saving void saveGame(BinarySerializer & h, const int version) override; //saving
void loadGame(CISer & h, const int version) override; //loading void loadGame(BinaryDeserializer & h, const int version) override; //loading
void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions) override; void showWorldViewEx(const std::vector<ObjectPosInfo> & objectPositions) override;
//for battles //for battles

View File

@ -17,7 +17,8 @@
#include "CMusicHandler.h" #include "CMusicHandler.h"
#include "CVideoHandler.h" #include "CVideoHandler.h"
#include "Graphics.h" #include "Graphics.h"
#include "../lib/Connection.h" #include "../lib/serializer/Connection.h"
#include "../lib/serializer/CTypeList.h"
#include "../lib/VCMIDirs.h" #include "../lib/VCMIDirs.h"
#include "../lib/mapping/CMap.h" #include "../lib/mapping/CMap.h"
#include "windows/GUIClasses.h" #include "windows/GUIClasses.h"
@ -1011,7 +1012,7 @@ void CSelectionScreen::processPacks()
{ {
CPackForSelectionScreen *pack = upcomingPacks.front(); CPackForSelectionScreen *pack = upcomingPacks.front();
upcomingPacks.pop_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); apply->applyOnPG(this, pack);
delete pack; delete pack;
} }

View File

@ -19,7 +19,9 @@
#include "../lib/CTownHandler.h" #include "../lib/CTownHandler.h"
#include "../lib/CBuildingHandler.h" #include "../lib/CBuildingHandler.h"
#include "../lib/spells/CSpellHandler.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 #ifndef VCMI_ANDROID
#include "../lib/Interprocess.h" #include "../lib/Interprocess.h"
#endif #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); assert(h.saving);
h & hotSeat; 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); assert(!h.saving);
h & hotSeat; 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<PlayerColor> & playerIDs) void CClient::serialize(BinarySerializer & h, const int version, const std::set<PlayerColor> & playerIDs)
{ {
assert(h.saving); assert(h.saving);
h & hotSeat; h & hotSeat;
@ -597,7 +599,7 @@ void CClient::serialize(COSer & h, const int version, const std::set<PlayerColor
} }
} }
void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor> & playerIDs) void CClient::serialize(BinaryDeserializer & h, const int version, const std::set<PlayerColor> & playerIDs)
{ {
assert(!h.saving); assert(!h.saving);
h & hotSeat; h & hotSeat;
@ -653,12 +655,12 @@ void CClient::serialize(CISer & h, const int version, const std::set<PlayerColor
void CClient::handlePack( CPack * pack ) void CClient::handlePack( CPack * pack )
{ {
if (pack == nullptr) if(pack == nullptr)
{ {
logNetwork->error("Dropping nullptr CPack! You should check whether client and server ABI matches."); logNetwork->error("Dropping nullptr CPack! You should check whether client and server ABI matches.");
return; return;
} }
CBaseForCLApply *apply = applier->apps[typeList.getTypeID(pack)]; //find the applier CBaseForCLApply *apply = applier->getApplier(typeList.getTypeID(pack)); //find the applier
if(apply) if(apply)
{ {
boost::unique_lock<boost::recursive_mutex> guiLock(*LOCPLINT->pim); boost::unique_lock<boost::recursive_mutex> guiLock(*LOCPLINT->pim);

View File

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

View File

@ -7,7 +7,8 @@
#include "Client.h" #include "Client.h"
#include "CPlayerInterface.h" #include "CPlayerInterface.h"
#include "CGameInfo.h" #include "CGameInfo.h"
#include "../lib/Connection.h" #include "../lib/serializer/Connection.h"
#include "../lib/serializer/BinarySerializer.h"
#include "../lib/CGeneralTextHandler.h" #include "../lib/CGeneralTextHandler.h"
#include "../lib/CHeroHandler.h" #include "../lib/CHeroHandler.h"
#include "../lib/VCMI_Lib.h" #include "../lib/VCMI_Lib.h"

View File

@ -9,7 +9,8 @@
#else #else
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#include "Connection.h" #include "serializer/BinaryDeserializer.h"
#include "serializer/BinarySerializer.h"
/* /*
* CGameInterface.cpp, part of VCMI engine * CGameInterface.cpp, part of VCMI engine
@ -243,29 +244,29 @@ void CAdventureAI::yourTacticPhase(int distance)
battleAI->yourTacticPhase(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); LOG_TRACE_PARAMS(logAi, "version '%i'", version);
CGlobalAI::saveGame(h, version); CGlobalAI::saveGame(h, version);
bool hasBattleAI = static_cast<bool>(battleAI); bool hasBattleAI = static_cast<bool>(battleAI);
h << hasBattleAI; h & hasBattleAI;
if(hasBattleAI) if(hasBattleAI)
{ {
h << std::string(battleAI->dllName); h & std::string(battleAI->dllName);
battleAI->saveGame(h, version); 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); LOG_TRACE_PARAMS(logAi, "version '%i'", version);
CGlobalAI::loadGame(h, version); CGlobalAI::loadGame(h, version);
bool hasBattleAI = false; bool hasBattleAI = false;
h >> hasBattleAI; h & hasBattleAI;
if(hasBattleAI) if(hasBattleAI)
{ {
std::string dllName; std::string dllName;
h >> dllName; h & dllName;
battleAI = CDynLibHandler::getNewBattleAI(dllName); battleAI = CDynLibHandler::getNewBattleAI(dllName);
assert(cbc); //it should have been set by the one who new'ed us assert(cbc); //it should have been set by the one who new'ed us
battleAI->init(cbc); 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)
{ {
} }

View File

@ -54,8 +54,8 @@ struct CPathsInfo;
class CCreature; class CCreature;
class CLoadFile; class CLoadFile;
class CSaveFile; class CSaveFile;
class CISer; class BinaryDeserializer;
class COSer; class BinarySerializer;
struct ArtifactLocation; struct ArtifactLocation;
class CScriptingModule; class CScriptingModule;
@ -73,8 +73,8 @@ public:
virtual BattleAction activeStack(const CStack * stack)=0; //called when it's turn of that stack 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 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 saveGame(BinarySerializer & h, const int version);
virtual void loadGame(CISer &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 battleEnd(const BattleResult *br) override;
virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override;
virtual void saveGame(COSer & h, const int version) override; //saving virtual void saveGame(BinarySerializer & h, const int version) override; //saving
virtual void loadGame(CISer & h, const int version) override; //loading virtual void loadGame(BinaryDeserializer & h, const int version) override; //loading
}; };

View File

@ -11,7 +11,6 @@
#include "CHeroHandler.h" #include "CHeroHandler.h"
#include "mapObjects/CObjectHandler.h" #include "mapObjects/CObjectHandler.h"
#include "CModHandler.h" #include "CModHandler.h"
#include "Connection.h"
#include "mapping/CMap.h" #include "mapping/CMap.h"
#include "mapping/CMapService.h" #include "mapping/CMapService.h"
#include "StartInfo.h" #include "StartInfo.h"
@ -25,6 +24,8 @@
#include "rmg/CMapGenerator.h" #include "rmg/CMapGenerator.h"
#include "CStopWatch.h" #include "CStopWatch.h"
#include "mapping/CMapEditManager.h" #include "mapping/CMapEditManager.h"
#include "serializer/CTypeList.h"
#include "serializer/CMemorySerializer.h"
#ifdef min #ifdef min
#undef min #undef min
@ -871,7 +872,7 @@ void CGameState::initDuel()
else else
{ {
CLoadFile lf(scenarioOps->mapname); CLoadFile lf(scenarioOps->mapname);
lf.serializer >> dp; lf.serializer & dp;
} }
} }
catch(...) catch(...)
@ -2059,7 +2060,7 @@ PlayerRelations::PlayerRelations CGameState::getPlayerRelations( PlayerColor col
void CGameState::apply(CPack *pack) void CGameState::apply(CPack *pack)
{ {
ui16 typ = typeList.getTypeID(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) void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out)

View File

@ -59,6 +59,14 @@ set(lib_SRCS
rmg/CRmgTemplateStorage.cpp rmg/CRmgTemplateStorage.cpp
rmg/CZoneGraphGenerator.cpp rmg/CZoneGraphGenerator.cpp
rmg/CZonePlacer.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/CSpellHandler.cpp
spells/ISpellMechanics.cpp spells/ISpellMechanics.cpp
@ -102,7 +110,6 @@ set(lib_SRCS
CGameInfoCallback.cpp CGameInfoCallback.cpp
CPathfinder.cpp CPathfinder.cpp
CGameState.cpp CGameState.cpp
Connection.cpp
NetPacksLib.cpp NetPacksLib.cpp
serializer/JsonSerializer.cpp serializer/JsonSerializer.cpp

View File

@ -18,8 +18,8 @@
* *
*/ */
extern template void registerTypes<CISer>(CISer & s); extern template void registerTypes<BinaryDeserializer>(BinaryDeserializer & s);
extern template void registerTypes<COSer>(COSer & s); extern template void registerTypes<BinarySerializer>(BinarySerializer & s);
extern template void registerTypes<CTypeList>(CTypeList & s); extern template void registerTypes<CTypeList>(CTypeList & s);
CTypeList typeList; CTypeList typeList;

View File

@ -17,7 +17,12 @@
#include "CBonusTypeHandler.h" #include "CBonusTypeHandler.h"
#include "CModHandler.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 "mapObjects/CObjectClassesHandler.h"
#include "StartInfo.h" #include "StartInfo.h"
#include "CGameState.h" #include "CGameState.h"
@ -157,16 +162,16 @@ void CPrivilagedInfoCallback::loadCommonState(Loader &in)
StartInfo *si; StartInfo *si;
logGlobal->infoStream() <<"\tReading header"; logGlobal->infoStream() <<"\tReading header";
in.serializer >> dum; in.serializer & dum;
logGlobal->infoStream() << "\tReading options"; logGlobal->infoStream() << "\tReading options";
in.serializer >> si; in.serializer & si;
logGlobal->infoStream() <<"\tReading handlers"; logGlobal->infoStream() <<"\tReading handlers";
in.serializer >> *VLC; in.serializer & *VLC;
logGlobal->infoStream() <<"\tReading gamestate"; logGlobal->infoStream() <<"\tReading gamestate";
in.serializer >> gs; in.serializer & gs;
} }
template<typename Saver> template<typename Saver>
@ -175,13 +180,13 @@ void CPrivilagedInfoCallback::saveCommonState(Saver &out) const
logGlobal->infoStream() << "Saving lib part of game..."; logGlobal->infoStream() << "Saving lib part of game...";
out.putMagicBytes(SAVEGAME_MAGIC); out.putMagicBytes(SAVEGAME_MAGIC);
logGlobal->infoStream() <<"\tSaving header"; logGlobal->infoStream() <<"\tSaving header";
out.serializer << static_cast<CMapHeader&>(*gs->map); out.serializer & static_cast<CMapHeader&>(*gs->map);
logGlobal->infoStream() << "\tSaving options"; logGlobal->infoStream() << "\tSaving options";
out.serializer << gs->scenarioOps; out.serializer & gs->scenarioOps;
logGlobal->infoStream() << "\tSaving handlers"; logGlobal->infoStream() << "\tSaving handlers";
out.serializer << *VLC; out.serializer & *VLC;
logGlobal->infoStream() << "\tSaving gamestate"; logGlobal->infoStream() << "\tSaving gamestate";
out.serializer << gs; out.serializer & gs;
} }
// hardly memory usage for `-gdwarf-4` flag // hardly memory usage for `-gdwarf-4` flag

View File

@ -12,6 +12,10 @@
#include "../spells/CSpellHandler.h" #include "../spells/CSpellHandler.h"
#include "../mapping/CCampaignHandler.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 // For reference: peak memory usage by gcc during compilation of register type templates
// registerTypesMapObjects: 1.9 Gb // registerTypesMapObjects: 1.9 Gb
// registerTypes2: 2.2 Gb // registerTypes2: 2.2 Gb
@ -22,8 +26,8 @@
#define DEFINE_EXTERNAL_METHOD(METHODNAME) \ #define DEFINE_EXTERNAL_METHOD(METHODNAME) \
extern template DLL_LINKAGE void METHODNAME<CISer>(CISer & s); \ extern template DLL_LINKAGE void METHODNAME<BinaryDeserializer>(BinaryDeserializer & s); \
extern template DLL_LINKAGE void METHODNAME<COSer>(COSer & s); \ extern template DLL_LINKAGE void METHODNAME<BinarySerializer>(BinarySerializer & s); \
extern template DLL_LINKAGE void METHODNAME<CTypeList>(CTypeList & s); \ extern template DLL_LINKAGE void METHODNAME<CTypeList>(CTypeList & s); \
//DEFINE_EXTERNAL_METHOD(registerTypesMapObjects) //DEFINE_EXTERNAL_METHOD(registerTypesMapObjects)
@ -34,6 +38,6 @@ DEFINE_EXTERNAL_METHOD(registerTypesClientPacks2)
DEFINE_EXTERNAL_METHOD(registerTypesServerPacks) DEFINE_EXTERNAL_METHOD(registerTypesServerPacks)
DEFINE_EXTERNAL_METHOD(registerTypesPregamePacks) DEFINE_EXTERNAL_METHOD(registerTypesPregamePacks)
template void registerTypes<CISer>(CISer & s); template void registerTypes<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypes<COSer>(COSer & s); template void registerTypes<BinarySerializer>(BinarySerializer & s);
template void registerTypes<CTypeList>(CTypeList & s); template void registerTypes<CTypeList>(CTypeList & s);

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include "../Connection.h"
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../VCMI_Lib.h" #include "../VCMI_Lib.h"
#include "../CArtHandler.h" #include "../CArtHandler.h"
@ -24,6 +23,10 @@
* *
*/ */
class BinarySerializer;
class BinaryDeserializer;
class CTypeList;
template<typename Serializer> template<typename Serializer>
void registerTypesMapObjects1(Serializer &s) void registerTypesMapObjects1(Serializer &s)
{ {
@ -376,8 +379,8 @@ void registerTypes(Serializer &s)
#ifndef INSTANTIATE_REGISTER_TYPES_HERE #ifndef INSTANTIATE_REGISTER_TYPES_HERE
extern template DLL_LINKAGE void registerTypes<CISer>(CISer & s); extern template DLL_LINKAGE void registerTypes<BinaryDeserializer>(BinaryDeserializer & s);
extern template DLL_LINKAGE void registerTypes<COSer>(COSer & s); extern template DLL_LINKAGE void registerTypes<BinarySerializer>(BinarySerializer & s);
extern template DLL_LINKAGE void registerTypes<CTypeList>(CTypeList & s); extern template DLL_LINKAGE void registerTypes<CTypeList>(CTypeList & s);
#endif #endif

View File

@ -18,7 +18,11 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
#include "../serializer/BinaryDeserializer.h"
#include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesClientPacks1<CISer>(CISer & s);
template void registerTypesClientPacks1<COSer>(COSer & s); template void registerTypesClientPacks1<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesClientPacks1<BinarySerializer>(BinarySerializer & s);
template void registerTypesClientPacks1<CTypeList>(CTypeList & s); template void registerTypesClientPacks1<CTypeList>(CTypeList & s);

View File

@ -18,9 +18,13 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
#include "../serializer/BinaryDeserializer.h"
#include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesClientPacks2<CISer>(CISer & s);
template void registerTypesClientPacks2<COSer>(COSer & s); template void registerTypesClientPacks2<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesClientPacks2<BinarySerializer>(BinarySerializer & s);
template void registerTypesClientPacks2<CTypeList>(CTypeList & s); template void registerTypesClientPacks2<CTypeList>(CTypeList & s);

View File

@ -18,8 +18,12 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjects1<CISer>(CISer & s); #include "../serializer/BinaryDeserializer.h"
template void registerTypesMapObjects1<COSer>(COSer & s); #include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesMapObjects1<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesMapObjects1<BinarySerializer>(BinarySerializer & s);
template void registerTypesMapObjects1<CTypeList>(CTypeList & s); template void registerTypesMapObjects1<CTypeList>(CTypeList & s);

View File

@ -18,8 +18,12 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
#include "../serializer/BinaryDeserializer.h"
#include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesMapObjects2<CISer>(CISer & s);
template void registerTypesMapObjects2<COSer>(COSer & s); template void registerTypesMapObjects2<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesMapObjects2<BinarySerializer>(BinarySerializer & s);
template void registerTypesMapObjects2<CTypeList>(CTypeList & s); template void registerTypesMapObjects2<CTypeList>(CTypeList & s);

View File

@ -18,6 +18,10 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesMapObjectTypes<CISer>(CISer & s); #include "../serializer/BinaryDeserializer.h"
template void registerTypesMapObjectTypes<COSer>(COSer & s); #include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesMapObjectTypes<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesMapObjectTypes<BinarySerializer>(BinarySerializer & s);
template void registerTypesMapObjectTypes<CTypeList>(CTypeList & s); template void registerTypesMapObjectTypes<CTypeList>(CTypeList & s);

View File

@ -17,8 +17,13 @@
#include "../mapping/CCampaignHandler.h" #include "../mapping/CCampaignHandler.h"
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
#include "../rmg/CMapGenOptions.h"
template void registerTypesPregamePacks<CISer>(CISer & s); #include "../serializer/BinaryDeserializer.h"
template void registerTypesPregamePacks<COSer>(COSer & s); #include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesPregamePacks<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesPregamePacks<BinarySerializer>(BinarySerializer & s);
template void registerTypesPregamePacks<CTypeList>(CTypeList & s); template void registerTypesPregamePacks<CTypeList>(CTypeList & s);

View File

@ -18,6 +18,10 @@
#include "../NetPacks.h" #include "../NetPacks.h"
#include "../mapObjects/CObjectClassesHandler.h" #include "../mapObjects/CObjectClassesHandler.h"
template void registerTypesServerPacks<CISer>(CISer & s); #include "../serializer/BinaryDeserializer.h"
template void registerTypesServerPacks<COSer>(COSer & s); #include "../serializer/BinarySerializer.h"
#include "../serializer/CTypeList.h"
template void registerTypesServerPacks<BinaryDeserializer>(BinaryDeserializer & s);
template void registerTypesServerPacks<BinarySerializer>(BinarySerializer & s);
template void registerTypesServerPacks<CTypeList>(CTypeList & s); template void registerTypesServerPacks<CTypeList>(CTypeList & s);

View File

@ -20,6 +20,7 @@
#include "../lib/NetPacks.h" #include "../lib/NetPacks.h"
#include "../lib/VCMI_Lib.h" #include "../lib/VCMI_Lib.h"
#include "../lib/mapping/CMap.h" #include "../lib/mapping/CMap.h"
#include "../lib/rmg/CMapGenOptions.h"
#include "../lib/VCMIDirs.h" #include "../lib/VCMIDirs.h"
#include "../lib/ScopeGuard.h" #include "../lib/ScopeGuard.h"
#include "../lib/CSoundBase.h" #include "../lib/CSoundBase.h"
@ -29,6 +30,8 @@
#include "../lib/CThreadHelper.h" #include "../lib/CThreadHelper.h"
#include "../lib/GameConstants.h" #include "../lib/GameConstants.h"
#include "../lib/registerTypes/RegisterTypes.h" #include "../lib/registerTypes/RegisterTypes.h"
#include "../lib/serializer/CTypeList.h"
#include "../lib/serializer/Connection.h"
/* /*
* CGameHandler.cpp, part of VCMI engine * CGameHandler.cpp, part of VCMI engine
@ -957,9 +960,8 @@ void CGameHandler::handleConnection(std::set<PlayerColor> players, CConnection &
boost::unique_lock<boost::mutex> lock(*c.wmx); boost::unique_lock<boost::mutex> lock(*c.wmx);
c << &applied; c << &applied;
}; };
CBaseForGHApply *apply = applier->getApplier(packType); //and appropriate applier object
CBaseForGHApply *apply = applier->apps[packType]; //and appropriate applier object if(isBlockedByQueries(pack, player))
if (isBlockedByQueries(pack, player))
{ {
sendPackageResponse(false); sendPackageResponse(false);
} }

View File

@ -2,7 +2,6 @@
#include "../lib/FunctionList.h" #include "../lib/FunctionList.h"
#include "../lib/Connection.h"
#include "../lib/IGameCallback.h" #include "../lib/IGameCallback.h"
#include "../lib/BattleAction.h" #include "../lib/BattleAction.h"
#include "CQuery.h" #include "CQuery.h"

View File

@ -5,7 +5,7 @@
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
#include "../lib/mapping/CCampaignHandler.h" #include "../lib/mapping/CCampaignHandler.h"
#include "../lib/CThreadHelper.h" #include "../lib/CThreadHelper.h"
#include "../lib/Connection.h" #include "../lib/serializer/Connection.h"
#include "../lib/CModHandler.h" #include "../lib/CModHandler.h"
#include "../lib/CArtHandler.h" #include "../lib/CArtHandler.h"
#include "../lib/CGeneralTextHandler.h" #include "../lib/CGeneralTextHandler.h"
@ -18,6 +18,7 @@
#include "CVCMIServer.h" #include "CVCMIServer.h"
#include "../lib/StartInfo.h" #include "../lib/StartInfo.h"
#include "../lib/mapping/CMap.h" #include "../lib/mapping/CMap.h"
#include "../lib/rmg/CMapGenOptions.h"
#ifndef VCMI_ANDROID #ifndef VCMI_ANDROID
#include "../lib/Interprocess.h" #include "../lib/Interprocess.h"
#endif #endif

View File

@ -7,6 +7,7 @@
#include "../lib/CGameState.h" #include "../lib/CGameState.h"
#include "../lib/BattleState.h" #include "../lib/BattleState.h"
#include "../lib/BattleAction.h" #include "../lib/BattleAction.h"
#include "../lib/serializer/Connection.h"
#define PLAYER_OWNS(id) (gh->getPlayerAt(c)==gh->getOwner(id)) #define PLAYER_OWNS(id) (gh->getPlayerAt(c)==gh->getOwner(id))