diff --git a/AI/VCAI/AIUtility.cpp b/AI/VCAI/AIUtility.cpp index 8de8aa9f5..4ffbef8c6 100644 --- a/AI/VCAI/AIUtility.cpp +++ b/AI/VCAI/AIUtility.cpp @@ -9,6 +9,7 @@ #include "../../lib/mapObjects/CBank.h" #include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapObjects/CQuest.h" +#include "../../lib/CPathfinder.h" /* * AIUtility.cpp, part of VCMI engine diff --git a/AI/VCAI/AIUtility.h b/AI/VCAI/AIUtility.h index 3ec1f8110..2d3577202 100644 --- a/AI/VCAI/AIUtility.h +++ b/AI/VCAI/AIUtility.h @@ -6,7 +6,7 @@ #include "../../lib/CTownHandler.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/Connection.h" -#include "../../lib/CGameState.h" +//#include "../../lib/CGameState.h" #include "../../lib/NetPacks.h" #include "../../lib/CStopWatch.h" @@ -20,6 +20,8 @@ * */ +class CCallback; + typedef const int3& crint3; typedef const std::string& crstring; diff --git a/AI/VCAI/Fuzzy.cpp b/AI/VCAI/Fuzzy.cpp index bc7b60cfe..59e959924 100644 --- a/AI/VCAI/Fuzzy.cpp +++ b/AI/VCAI/Fuzzy.cpp @@ -5,6 +5,8 @@ #include "../../lib/mapObjects/MapObjects.h" #include "../../lib/mapObjects/CommonConstructors.h" #include "../../lib/CCreatureHandler.h" +#include "../../lib/CPathfinder.h" +#include "../../lib/CGameStateFwd.h" #include "../../lib/VCMI_Lib.h" #include "../../CCallback.h" #include "VCAI.h" diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 3fb441c5a..6b15add0d 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -3,6 +3,7 @@ #include "VCAI.h" #include "Fuzzy.h" #include "../../lib/mapping/CMap.h" //for victory conditions +#include "../../lib/CPathfinder.h" /* * Goals.cpp, part of VCMI engine diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index c1b6a43bd..143e2b849 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -8,6 +8,7 @@ #include "../../lib/CConfigHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/CModHandler.h" +#include "../../lib/CGameState.h" /* diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index 0da2ee61c..19c638cc2 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -15,7 +15,7 @@ #include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/Connection.h" -#include "../../lib/CGameState.h" +//#include "../../lib/CGameState.h" #include "../../lib/NetPacks.h" #include "../../lib/CondSh.h" diff --git a/CCallback.cpp b/CCallback.cpp index e48197d63..6b8a28958 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -18,12 +18,7 @@ #include "lib/spells/CSpellHandler.h" #include "lib/CArtHandler.h" #include "lib/GameConstants.h" -#ifdef min -#undef min -#endif -#ifdef max -#undef max -#endif +#include "lib/CPlayerState.h" #include "lib/UnlockGuard.h" /* diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 61280f419..f263423f4 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -37,6 +37,7 @@ #include "../lib/CStopWatch.h" #include "../lib/StartInfo.h" #include "../lib/CGameState.h" +#include "../lib/CPlayerState.h" #include "../lib/GameConstants.h" #include "gui/CGuiHandler.h" #include "windows/InfoWindows.h" diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index 2e19aae30..80891f205 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -5,7 +5,6 @@ #include "../lib/CGameInterface.h" #include "../lib/NetPacksBase.h" #include "gui/CIntObject.h" -//#include "../lib/CGameState.h" #ifdef __GNUC__ #define sprintf_s snprintf diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index eb95d44b9..b8382868f 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -25,6 +25,7 @@ #include "../lib/CGameState.h" #include "../lib/BattleState.h" #include "../lib/GameConstants.h" +#include "../lib/CPlayerState.h" #include "gui/CGuiHandler.h" #include "widgets/MiscWidgets.h" #include "widgets/AdventureMapClasses.h" diff --git a/client/gui/Geometries.h b/client/gui/Geometries.h index af67813ec..c6ee4df7a 100644 --- a/client/gui/Geometries.h +++ b/client/gui/Geometries.h @@ -13,13 +13,6 @@ * */ -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif - struct SDL_MouseMotionEvent; // A point with x/y coordinate, used mostly for graphic rendering diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index 9b030df9e..e7000ad46 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -19,6 +19,7 @@ #include "CModHandler.h" #include "spells/CSpellHandler.h" #include "mapping/CMap.h" +#include "CPlayerState.h" //TODO make clean #define ERROR_VERBOSE_OR_NOT_RET_VAL_IF(cond, verbose, txt, retVal) do {if(cond){if(verbose)logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return retVal;}} while(0) diff --git a/lib/CGameState.h b/lib/CGameState.h index 458a4b714..f2642262f 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -62,79 +62,6 @@ namespace boost class shared_mutex; } -//numbers of creatures are exact numbers if detailed else they are quantity ids (1 - a few, 2 - several and so on; additionally 0 - unknown) -struct ArmyDescriptor : public std::map -{ - bool isDetailed; - DLL_LINKAGE ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count - DLL_LINKAGE ArmyDescriptor(); - - DLL_LINKAGE int getStrength() const; -}; - -struct DLL_LINKAGE InfoAboutArmy -{ - PlayerColor owner; - std::string name; - - ArmyDescriptor army; - - InfoAboutArmy(); - InfoAboutArmy(const CArmedInstance *Army, bool detailed); - - void initFromArmy(const CArmedInstance *Army, bool detailed); -}; - -struct DLL_LINKAGE InfoAboutHero : public InfoAboutArmy -{ -private: - void assign(const InfoAboutHero & iah); -public: - struct DLL_LINKAGE Details - { - std::vector primskills; - si32 mana, luck, morale; - } *details; - - const CHeroClass *hclass; - int portrait; - - InfoAboutHero(); - InfoAboutHero(const InfoAboutHero & iah); - InfoAboutHero(const CGHeroInstance *h, bool detailed); - ~InfoAboutHero(); - - InfoAboutHero & operator=(const InfoAboutHero & iah); - - void initFromHero(const CGHeroInstance *h, bool detailed); -}; - -/// Struct which holds a int information about a town -struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy -{ - struct DLL_LINKAGE Details - { - si32 hallLevel, goldIncome; - bool customRes; - bool garrisonedHero; - - } *details; - - const CTown *tType; - - si32 built; - si32 fortLevel; //0 - none - - InfoAboutTown(); - InfoAboutTown(const CGTownInstance *t, bool detailed); - ~InfoAboutTown(); - void initFromTown(const CGTownInstance *t, bool detailed); -}; - -// typedef si32 TResourceUnit; -// typedef std::vector TResourceVector; -// typedef std::set TResourceSet; - struct DLL_LINKAGE SThievesGuildInfo { std::vector playerColors; //colors of players that are in-game @@ -154,55 +81,6 @@ struct DLL_LINKAGE SThievesGuildInfo }; -struct DLL_LINKAGE PlayerState : public CBonusSystemNode -{ -public: - PlayerColor color; - bool human; //true if human controlled player, false for AI - TeamID team; - TResources resources; - std::set visitedObjects; // as a std::set, since most accesses here will be from visited status checks - std::vector > heroes; - std::vector > towns; - std::vector > availableHeroes; //heroes available in taverns - std::vector > dwellings; //used for town growth - std::vector quests; //store info about all received quests - - bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory - EPlayerStatus::EStatus status; - boost::optional daysWithoutCastle; - - PlayerState(); - std::string nodeName() const override; - - template void serialize(Handler &h, const int version) - { - h & color & human & team & resources & status; - h & heroes & towns & availableHeroes & dwellings & quests & visitedObjects; - h & getBonusList(); //FIXME FIXME FIXME - h & status & daysWithoutCastle; - h & enteredLosingCheatCode & enteredWinningCheatCode; - h & static_cast(*this); - } -}; - -struct DLL_LINKAGE TeamState : public CBonusSystemNode -{ -public: - TeamID id; //position in gameState::teams - std::set players; // members of this team - std::vector > > fogOfWarMap; //true - visible, false - hidden - - TeamState(); - - template void serialize(Handler &h, const int version) - { - h & id & players & fogOfWarMap; - h & static_cast(*this); - } - -}; - struct UpgradeInfo { CreatureID oldID; //creature to be upgraded @@ -271,7 +149,6 @@ struct DLL_EXPORT DuelParameters } }; - struct BattleInfo; DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const EVictoryLossCheckResult & victoryLossCheckResult); diff --git a/lib/CGameStateFwd.h b/lib/CGameStateFwd.h index d676e11c2..268300e02 100644 --- a/lib/CGameStateFwd.h +++ b/lib/CGameStateFwd.h @@ -10,8 +10,81 @@ * */ +#include "CCreatureSet.h" + class CQuest; class CGObjectInstance; +class CHeroClass; +class CTown; + +//numbers of creatures are exact numbers if detailed else they are quantity ids (1 - a few, 2 - several and so on; additionally 0 - unknown) +struct ArmyDescriptor : public std::map +{ + bool isDetailed; + DLL_LINKAGE ArmyDescriptor(const CArmedInstance *army, bool detailed); //not detailed -> quantity ids as count + DLL_LINKAGE ArmyDescriptor(); + + DLL_LINKAGE int getStrength() const; +}; + +struct DLL_LINKAGE InfoAboutArmy +{ + PlayerColor owner; + std::string name; + + ArmyDescriptor army; + + InfoAboutArmy(); + InfoAboutArmy(const CArmedInstance *Army, bool detailed); + + void initFromArmy(const CArmedInstance *Army, bool detailed); +}; + +struct DLL_LINKAGE InfoAboutHero : public InfoAboutArmy +{ +private: + void assign(const InfoAboutHero & iah); +public: + struct DLL_LINKAGE Details + { + std::vector primskills; + si32 mana, luck, morale; + } *details; + + const CHeroClass *hclass; + int portrait; + + InfoAboutHero(); + InfoAboutHero(const InfoAboutHero & iah); + InfoAboutHero(const CGHeroInstance *h, bool detailed); + ~InfoAboutHero(); + + InfoAboutHero & operator=(const InfoAboutHero & iah); + + void initFromHero(const CGHeroInstance *h, bool detailed); +}; + +/// Struct which holds a int information about a town +struct DLL_LINKAGE InfoAboutTown : public InfoAboutArmy +{ + struct DLL_LINKAGE Details + { + si32 hallLevel, goldIncome; + bool customRes; + bool garrisonedHero; + + } *details; + + const CTown *tType; + + si32 built; + si32 fortLevel; //0 - none + + InfoAboutTown(); + InfoAboutTown(const CGTownInstance *t, bool detailed); + ~InfoAboutTown(); + void initFromTown(const CGTownInstance *t, bool detailed); +}; class DLL_LINKAGE EVictoryLossCheckResult { diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0faf961e7..6657e0b91 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -132,6 +132,7 @@ set(lib_HEADERS IGameEventsReceiver.h int3.h CGameStateFwd.h + CPlayerState.h Interprocess.h NetPacks.h NetPacksBase.h diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 8be71f212..8858fdc3a 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -8,6 +8,7 @@ #include "GameConstants.h" #include "CStopWatch.h" #include "CConfigHandler.h" +#include "../lib/CPlayerState.h" /* * CPathfinder.cpp, part of VCMI engine diff --git a/lib/CPlayerState.h b/lib/CPlayerState.h new file mode 100644 index 000000000..f676379a3 --- /dev/null +++ b/lib/CPlayerState.h @@ -0,0 +1,66 @@ +#pragma once + +/* + * CPlayerState.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#include "HeroBonus.h" + +class CGHeroInstance; +class CGTownInstance; +class CGDwelling; + +struct DLL_LINKAGE PlayerState : public CBonusSystemNode +{ +public: + PlayerColor color; + bool human; //true if human controlled player, false for AI + TeamID team; + TResources resources; + std::set visitedObjects; // as a std::set, since most accesses here will be from visited status checks + std::vector > heroes; + std::vector > towns; + std::vector > availableHeroes; //heroes available in taverns + std::vector > dwellings; //used for town growth + std::vector quests; //store info about all received quests + + bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory + EPlayerStatus::EStatus status; + boost::optional daysWithoutCastle; + + PlayerState(); + std::string nodeName() const override; + + template void serialize(Handler &h, const int version) + { + h & color & human & team & resources & status; + h & heroes & towns & availableHeroes & dwellings & quests & visitedObjects; + h & getBonusList(); //FIXME FIXME FIXME + h & status & daysWithoutCastle; + h & enteredLosingCheatCode & enteredWinningCheatCode; + h & static_cast(*this); + } +}; + +struct DLL_LINKAGE TeamState : public CBonusSystemNode +{ +public: + TeamID id; //position in gameState::teams + std::set players; // members of this team + std::vector > > fogOfWarMap; //true - visible, false - hidden + + TeamState(); + + template void serialize(Handler &h, const int version) + { + h & id & players & fogOfWarMap; + h & static_cast(*this); + } + +}; diff --git a/lib/Connection.cpp b/lib/Connection.cpp index 24eeb6642..7bc772093 100644 --- a/lib/Connection.cpp +++ b/lib/Connection.cpp @@ -3,6 +3,7 @@ #include "registerTypes/RegisterTypes.h" #include "mapping/CMap.h" +#include "CGameState.h" #include diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index d562c7410..561e9cd11 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -22,6 +22,7 @@ #include "StartInfo.h" #include "CGameState.h" #include "mapping/CMap.h" +#include "CPlayerState.h" void CPrivilagedInfoCallback::getFreeTiles (std::vector &tiles) const { diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 5483c2936..72b4ecff5 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -16,6 +16,7 @@ #include "CTownHandler.h" #include "mapping/CMapInfo.h" #include "StartInfo.h" +#include "CPlayerState.h" /* * NetPacksLib.cpp, part of VCMI engine diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index d6d879b7e..adc47a7a5 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -1,4 +1,4 @@ -/* +/* * CArmedInstance.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder @@ -15,6 +15,7 @@ #include "../CCreatureHandler.h" #include "../CGeneralTextHandler.h" #include "../CGameState.h" +#include "../CPlayerState.h" void CArmedInstance::randomizeArmy(int type) { diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index e640eaa0b..ba1b8baca 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -18,6 +18,7 @@ #include "../IGameCallback.h" #include "../CGameState.h" #include "../mapping/CMapDefines.h" +#include "../CPlayerState.h" std::vector CGTownInstance::merchantArtifacts; std::vector CGTownInstance::universitySkills; diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 5c6d80cbd..bb454007c 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -17,6 +17,7 @@ #include "../NetPacks.h" #include "../IGameCallback.h" #include "../CGameState.h" +#include "../CPlayerState.h" #include "CObjectClassesHandler.h" diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index eb04fd0c1..025920192 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -21,6 +21,7 @@ #include "../IGameCallback.h" #include "../CGameState.h" #include "../mapping/CMap.h" +#include "../CPlayerState.h" std::map > CGMagi::eyelist; ui8 CGObelisk::obeliskCount; //how many obelisks are on map diff --git a/lib/registerTypes/RegisterTypes.h b/lib/registerTypes/RegisterTypes.h index 173b08116..e3d3a9654 100644 --- a/lib/registerTypes/RegisterTypes.h +++ b/lib/registerTypes/RegisterTypes.h @@ -4,7 +4,7 @@ #include "../NetPacks.h" #include "../VCMI_Lib.h" #include "../CArtHandler.h" -#include "../CGameState.h" +#include "../CPlayerState.h" #include "../CHeroHandler.h" #include "../CTownHandler.h" #include "../CModHandler.h" //needed? diff --git a/lib/spells/AdventureSpellMechanics.cpp b/lib/spells/AdventureSpellMechanics.cpp index 8ba05d3b4..c8ac2f9d0 100644 --- a/lib/spells/AdventureSpellMechanics.cpp +++ b/lib/spells/AdventureSpellMechanics.cpp @@ -19,6 +19,7 @@ #include "../CGameState.h" #include "../CGameInfoCallback.h" #include "../mapping/CMap.h" +#include "../CPlayerState.h" ///SummonBoatMechanics ESpellCastResult SummonBoatMechanics::applyAdventureEffects(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const diff --git a/server/CGameHandler.h b/server/CGameHandler.h index acf1698a2..fb1fff251 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -2,7 +2,7 @@ #include "../lib/FunctionList.h" -#include "../lib/CGameState.h" +//#include "../lib/CGameState.h" #include "../lib/Connection.h" #include "../lib/IGameCallback.h" #include "../lib/BattleAction.h"