CGameState.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. #ifndef __CGAMESTATE_H__
  2. #define __CGAMESTATE_H__
  3. #include "../global.h"
  4. #include <cassert>
  5. #ifndef _MSC_VER
  6. #include "../hch/CCreatureHandler.h"
  7. #include "VCMI_Lib.h"
  8. #include "map.h"
  9. #endif
  10. #include <set>
  11. #include <vector>
  12. #include <list>
  13. #include "HeroBonus.h"
  14. #include "CCreatureSet.h"
  15. #ifdef _WIN32
  16. #include <tchar.h>
  17. #else
  18. #include "../tchar_amigaos4.h"
  19. #endif
  20. /*
  21. * CGameState.h, part of VCMI engine
  22. *
  23. * Authors: listed in file AUTHORS in main folder
  24. *
  25. * License: GNU General Public License v2.0 or later
  26. * Full text of license available in license.txt file, in main folder
  27. *
  28. */
  29. class CTown;
  30. class CScriptCallback;
  31. class CCallback;
  32. class IGameCallback;
  33. class CLuaCallback;
  34. class CCPPObjectScript;
  35. class CCreatureSet;
  36. class CStack;
  37. class CGHeroInstance;
  38. class CGTownInstance;
  39. class CArmedInstance;
  40. class CGDwelling;
  41. class CGDefInfo;
  42. class CObjectScript;
  43. class CGObjectInstance;
  44. class CCreature;
  45. struct Mapa;
  46. struct StartInfo;
  47. struct SDL_Surface;
  48. class CMapHandler;
  49. class CPathfinder;
  50. struct SetObjectProperty;
  51. struct MetaString;
  52. struct CPack;
  53. class CSpell;
  54. struct TerrainTile;
  55. class CHeroClass;
  56. class CCampaign;
  57. class CCampaignState;
  58. class IModableArt;
  59. namespace boost
  60. {
  61. class shared_mutex;
  62. }
  63. struct DLL_EXPORT InfoAboutHero
  64. {
  65. private:
  66. void assign(const InfoAboutHero & iah);
  67. public:
  68. struct DLL_EXPORT Details
  69. {
  70. std::vector<int> primskills;
  71. int mana, luck, morale;
  72. } *details;
  73. char owner;
  74. const CHeroClass *hclass;
  75. std::string name;
  76. int portrait;
  77. CCreatureSet army; //numbers of creatures are exact numbers if detailed else they are quantity ids (0 - a few, 1 - several and so on)
  78. InfoAboutHero();
  79. InfoAboutHero(const InfoAboutHero & iah);
  80. InfoAboutHero & operator=(const InfoAboutHero & iah);
  81. ~InfoAboutHero();
  82. void initFromHero(const CGHeroInstance *h, bool detailed);
  83. };
  84. // typedef si32 TResourceUnit;
  85. // typedef std::vector<si32> TResourceVector;
  86. // typedef std::set<si32> TResourceSet;
  87. struct DLL_EXPORT SThievesGuildInfo
  88. {
  89. std::vector<ui8> playerColors; //colors of players that are in-game
  90. std::vector< std::list< ui8 > > numOfTowns, numOfHeroes, gold, woodOre, mercSulfCrystGems, obelisks, artifacts, army, income; // [place] -> [colours of players]
  91. std::map<ui8, InfoAboutHero> colorToBestHero; //maps player's color to his best heros'
  92. std::map<ui8, si8> personality; // color to personality // -1 - human, AI -> (00 - random, 01 - warrior, 02 - builder, 03 - explorer)
  93. std::map<ui8, si32> bestCreature; // color to ID // id or -1 if not known
  94. // template <typename Handler> void serialize(Handler &h, const int version)
  95. // {
  96. // h & playerColors & numOfTowns & numOfHeroes & gold & woodOre & mercSulfCrystGems & obelisks & artifacts & army & income;
  97. // h & colorToBestHero & personality & bestCreature;
  98. // }
  99. };
  100. struct DLL_EXPORT PlayerState : public CBonusSystemNode
  101. {
  102. public:
  103. enum EStatus {INGAME, LOSER, WINNER};
  104. ui8 color;
  105. ui8 human; //true if human controlled player, false for AI
  106. ui32 currentSelection; //id of hero/town, 0xffffffff if none
  107. ui8 team;
  108. //std::vector<std::vector<std::vector<ui8> > > * fogOfWarMap; //pointer to team's fog of war
  109. std::vector<si32> resources;
  110. std::vector<CGHeroInstance *> heroes;
  111. std::vector<CGTownInstance *> towns;
  112. std::vector<CGHeroInstance *> availableHeroes; //heroes available in taverns
  113. std::vector<CGDwelling *> dwellings; //used for town growth
  114. ui8 enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
  115. ui8 status; //0 - in game, 1 - loser, 2 - winner <- uses EStatus enum
  116. ui8 daysWithoutCastle;
  117. PlayerState();
  118. //override
  119. void getParents(TCNodes &out, const CBonusSystemNode *root = NULL) const;
  120. void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
  121. template <typename Handler> void serialize(Handler &h, const int version)
  122. {
  123. h & color & human & currentSelection & team & resources & status;
  124. h & heroes & towns & availableHeroes & dwellings & bonuses;
  125. h & status & daysWithoutCastle;
  126. h & enteredLosingCheatCode & enteredWinningCheatCode;
  127. h & static_cast<CBonusSystemNode&>(*this);
  128. }
  129. };
  130. struct DLL_EXPORT TeamState : public CBonusSystemNode
  131. {
  132. public:
  133. ui8 id; //position in gameState::teams
  134. std::set<ui8> players; // members of this team
  135. std::vector<std::vector<std::vector<ui8> > > fogOfWarMap; //true - visible, false - hidden
  136. //TeamState();
  137. template <typename Handler> void serialize(Handler &h, const int version)
  138. {
  139. h & players & fogOfWarMap;
  140. h & static_cast<CBonusSystemNode&>(*this);
  141. }
  142. };
  143. struct DLL_EXPORT CObstacleInstance
  144. {
  145. int uniqueID;
  146. int ID; //ID of obstacle (defines type of it)
  147. int pos; //position on battlefield
  148. template <typename Handler> void serialize(Handler &h, const int version)
  149. {
  150. h & ID & pos & uniqueID;
  151. }
  152. };
  153. //only for use in BattleInfo
  154. struct DLL_EXPORT SiegeInfo
  155. {
  156. ui8 wallState[8]; //[0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; 1 - intact, 2 - damaged, 3 - destroyed
  157. template <typename Handler> void serialize(Handler &h, const int version)
  158. {
  159. h & wallState;
  160. }
  161. };
  162. struct DLL_EXPORT BattleInfo : public CBonusSystemNode
  163. {
  164. ui8 side1, side2; //side1 - attacker, side2 - defender
  165. si32 round, activeStack;
  166. ui8 siege; // = 0 ordinary battle = 1 a siege with a Fort = 2 a siege with a Citadel = 3 a siege with a Castle
  167. si32 tid; //used during town siege - id of attacked town; -1 if not town defence
  168. int3 tile; //for background and bonuses
  169. CGHeroInstance *heroes[2];
  170. CArmedInstance *belligerents[2]; //may be same as heroes
  171. std::vector<CStack*> stacks;
  172. std::vector<CObstacleInstance> obstacles;
  173. ui8 castSpells[2]; //[0] - attacker, [1] - defender
  174. SiegeInfo si;
  175. template <typename Handler> void serialize(Handler &h, const int version)
  176. {
  177. h & side1 & side2 & round & activeStack & siege & tid & tile & stacks & belligerents & obstacles
  178. & castSpells & si;
  179. h & heroes;
  180. h & static_cast<CBonusSystemNode&>(*this);
  181. }
  182. //////////////////////////////////////////////////////////////////////////
  183. void getBonuses(BonusList &out, const CSelector &selector, const CBonusSystemNode *root = NULL) const;
  184. //////////////////////////////////////////////////////////////////////////
  185. const CStack * getNextStack() const; //which stack will have turn after current one
  186. void getStackQueue(std::vector<const CStack *> &out, int howMany, int turn = 0, int lastMoved = -1) const; //returns stack in order of their movement action
  187. CStack * getStack(int stackID, bool onlyAlive = true);
  188. const CStack * getStack(int stackID, bool onlyAlive = true) const;
  189. CStack * getStackT(int tileID, bool onlyAlive = true);
  190. const CStack * getStackT(int tileID, bool onlyAlive = true) const;
  191. void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set<int> & occupyable, bool flying, int stackToOmmit=-1) const; //send pointer to at least 187 allocated bytes
  192. static bool isAccessible(int hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS
  193. void makeBFS(int start, bool*accessibility, int *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result
  194. std::pair< std::vector<int>, int > getPath(int start, int dest, bool*accessibility, bool flyingCreature, bool twoHex, bool attackerOwned); //returned value: pair<path, length>; length may be different than number of elements in path since flying vreatures jump between distant hexes
  195. std::vector<int> getAccessibility(int stackID, bool addOccupiable) const; //returns vector of accessible tiles (taking into account the creature range)
  196. bool isStackBlocked(int ID); //returns true if there is neighboring enemy stack
  197. static signed char mutualPosition(int hex1, int hex2); //returns info about mutual position of given hexes (-1 - they're distant, 0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left)
  198. static std::vector<int> neighbouringTiles(int hex);
  199. static si8 getDistance(int hex1, int hex2); //returns distance between given hexes
  200. ui32 calculateDmg(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky); //charge - number of hexes travelled before attack (for champion's jousting)
  201. std::pair<ui32, ui32> calculateDmgRange(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge, bool lucky); //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
  202. void calculateCasualties(std::map<ui32,si32> *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount)
  203. std::set<CStack*> getAttackedCreatures(const CSpell * s, int skillLevel, ui8 attackerOwner, int destinationTile); //calculates stack affected by given spell
  204. static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster, int usedSpellPower);
  205. CStack * generateNewStack(const CStackInstance &base, int stackID, bool attackerOwned, int slot, int /*TerrainTile::EterrainType*/ terrain, int position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
  206. ui32 getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell
  207. int hexToWallPart(int hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
  208. int lineToWallHex(int line) const; //returns hex with wall in given line
  209. std::pair<const CStack *, int> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex)
  210. ui32 calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const;
  211. ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature, int spellSchoolLevel, int usedSpellPower) const; //calculates damage inflicted by spell
  212. ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack) const;
  213. si8 hasDistancePenalty(int stackID, int destHex); //determines if given stack has distance penalty shooting given pos
  214. si8 sameSideOfWall(int pos1, int pos2); //determines if given positions are on the same side of wall
  215. si8 hasWallPenalty(int stackID, int destHex); //determines if given stack has wall penalty shooting given pos
  216. si8 canTeleportTo(int stackID, int destHex, int telportLevel); //determines if given stack can teleport to given place
  217. };
  218. class DLL_EXPORT CStack : public CStackInstance
  219. {
  220. public:
  221. ui32 ID; //unique ID of stack
  222. ui32 baseAmount;
  223. ui32 firstHPleft; //HP of first creature in stack
  224. ui8 owner, slot; //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures)
  225. ui8 attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle)
  226. si16 position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower
  227. ui8 counterAttacks; //how many counter attacks can be performed more in this turn (by default set at the beginning of the round to 1)
  228. si16 shots; //how many shots left
  229. std::set<ECombatInfo> state;
  230. //overrides
  231. const CCreature* getCreature() const {return type;}
  232. CStack(const CStackInstance *base, int O, int I, bool AO, int S); //c-tor
  233. CStack() : ID(-1), baseAmount(-1), firstHPleft(-1), owner(255), slot(255), attackerOwned(true), position(-1), counterAttacks(1) {} //c-tor
  234. const Bonus * getEffect(ui16 id, int turn = 0) const; //effect id (SP)
  235. ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack
  236. bool willMove(int turn = 0) const; //if stack has remaining move this turn
  237. bool moved(int turn = 0) const; //if stack was already moved this turn
  238. bool canMove(int turn = 0) const; //if stack can move
  239. ui32 Speed(int turn = 0) const; //get speed of creature with all modificators
  240. BonusList getSpellBonuses() const;
  241. void stackEffectToFeature(BonusList & sf, const Bonus & sse);
  242. std::vector<si32> activeSpells() const; //returns vector of active spell IDs sorted by time of cast
  243. static inline Bonus featureGenerator(Bonus::BonusType type, si16 subtype, si32 value, ui16 turnsRemain, si32 additionalInfo = 0, si32 limit = Bonus::NO_LIMIT)
  244. {
  245. Bonus hb(makeFeature(type, Bonus::N_TURNS, subtype, value, Bonus::SPELL_EFFECT, turnsRemain, additionalInfo));
  246. hb.effectRange = limit;
  247. hb.source = Bonus::CASTED_SPELL; //right?
  248. return hb;
  249. }
  250. static inline Bonus featureGeneratorVT(Bonus::BonusType type, si16 subtype, si32 value, ui16 turnsRemain, ui8 valType)
  251. {
  252. Bonus ret(makeFeature(type, Bonus::N_TURNS, subtype, value, Bonus::SPELL_EFFECT, turnsRemain));
  253. ret.valType = valType;
  254. ret.source = Bonus::CASTED_SPELL; //right?
  255. return ret;
  256. }
  257. bool doubleWide() const;
  258. int occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1
  259. template <typename Handler> void serialize(Handler &h, const int version)
  260. {
  261. h & static_cast<CStackInstance&>(*this);
  262. h & ID & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks
  263. & shots;
  264. }
  265. bool alive() const //determines if stack is alive
  266. {
  267. return vstd::contains(state,ALIVE);
  268. }
  269. };
  270. class DLL_EXPORT CMP_stack
  271. {
  272. int phase; //rules of which phase will be used
  273. int turn;
  274. public:
  275. bool operator ()(const CStack* a, const CStack* b);
  276. CMP_stack(int Phase = 1, int Turn = 0);
  277. };
  278. struct UpgradeInfo
  279. {
  280. int oldID; //creature to be upgraded
  281. std::vector<int> newID; //possible upgrades
  282. std::vector<std::set<std::pair<int,int> > > cost; // cost[upgrade_serial] -> set of pairs<resource_ID,resource_amount>
  283. UpgradeInfo(){oldID = -1;};
  284. };
  285. struct CPathNode
  286. {
  287. bool accessible; //true if a hero can be on this node
  288. int dist; //distance from the first node of searching; -1 is infinity
  289. CPathNode * theNodeBefore;
  290. int3 coord; //coordiantes
  291. bool visited;
  292. };
  293. struct CGPathNode
  294. {
  295. enum
  296. {
  297. ACCESSIBLE=1, //tile can be entered and passed
  298. VISITABLE, //tile can be entered as the last tile in path
  299. BLOCKVIS, //visitable from neighbouring tile but not passable
  300. BLOCKED, //tile can't be entered nor visited
  301. FLYABLE //if hero flies, he can pass this tile
  302. };
  303. ui8 accessible; //the enum above
  304. ui8 land;
  305. ui8 turns;
  306. ui32 moveRemains;
  307. CGPathNode * theNodeBefore;
  308. int3 coord; //coordinates
  309. CGPathNode();
  310. };
  311. struct DLL_EXPORT CPath
  312. {
  313. std::vector<CPathNode> nodes; //just get node by node
  314. int3 startPos() const; // start point
  315. int3 endPos() const; //destination point
  316. void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object'
  317. };
  318. struct DLL_EXPORT CGPath
  319. {
  320. std::vector<CGPathNode> nodes; //just get node by node
  321. int3 startPos() const; // start point
  322. int3 endPos() const; //destination point
  323. void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object'
  324. };
  325. struct DLL_EXPORT CPathsInfo
  326. {
  327. const CGHeroInstance *hero;
  328. int3 hpos;
  329. int3 sizes;
  330. CGPathNode ***nodes; //[w][h][level]
  331. bool getPath(const int3 &dst, CGPath &out);
  332. CPathsInfo(const int3 &Sizes);
  333. ~CPathsInfo();
  334. };
  335. class DLL_EXPORT CGameState
  336. {
  337. public:
  338. StartInfo* scenarioOps;
  339. CCampaignState *campaign;
  340. ui32 seed;
  341. ui8 currentPlayer; //ID of player currently having turn
  342. BattleInfo *curB; //current battle
  343. ui32 day; //total number of days in game
  344. Mapa * map;
  345. std::map<ui8, PlayerState> players; //ID <-> player state
  346. std::map<ui8, TeamState> teams; //ID <-> team state
  347. std::map<int, CGDefInfo*> villages, forts, capitols; //def-info for town graphics
  348. CBonusSystemNode globalEffects;
  349. struct DLL_EXPORT HeroesPool
  350. {
  351. std::map<ui32,CGHeroInstance *> heroesPool; //[subID] - heroes available to buy; NULL if not available
  352. std::map<ui32,ui8> pavailable; // [subid] -> which players can recruit hero (binary flags)
  353. CGHeroInstance * pickHeroFor(bool native, int player, const CTown *town, std::map<ui32,CGHeroInstance *> &available, const CHeroClass *bannedClass = NULL) const;
  354. template <typename Handler> void serialize(Handler &h, const int version)
  355. {
  356. h & heroesPool & pavailable;
  357. }
  358. } hpool; //we have here all heroes available on this map that are not hired
  359. boost::shared_mutex *mx;
  360. PlayerState *getPlayer(ui8 color, bool verbose = true);
  361. TeamState *getTeam(ui8 teamID);//get team by team ID
  362. TeamState *getPlayerTeam(ui8 color);// get team by player color
  363. const PlayerState *getPlayer(ui8 color, bool verbose = true) const;
  364. const TeamState *getTeam(ui8 teamID) const;
  365. const TeamState *getPlayerTeam(ui8 color) const;
  366. void init(StartInfo * si, ui32 checksum, int Seed);
  367. void loadTownDInfos();
  368. void randomizeObject(CGObjectInstance *cur);
  369. std::pair<int,int> pickObject(CGObjectInstance *obj); //chooses type of object to be randomized, returns <type, subtype>
  370. int pickHero(int owner);
  371. void apply(CPack *pack);
  372. CGHeroInstance *getHero(int objid);
  373. CGTownInstance *getTown(int objid);
  374. const CGHeroInstance *getHero(int objid) const;
  375. const CGTownInstance *getTown(int objid) const;
  376. bool battleCanFlee(int player); //returns true if player can flee from the battle
  377. int battleGetStack(int pos, bool onlyAlive); //returns ID of stack at given tile
  378. int battleGetBattlefieldType(int3 tile = int3());// 1. sand/shore 2. sand/mesas 3. dirt/birches 4. dirt/hills 5. dirt/pines 6. grass/hills 7. grass/pines 8. lava 9. magic plains 10. snow/mountains 11. snow/trees 12. subterranean 13. swamp/trees 14. fiery fields 15. rock lands 16. magic clouds 17. lucid pools 18. holy ground 19. clover field 20. evil fog 21. "favourable winds" text on magic plains background 22. cursed ground 23. rough 24. ship to ship 25. ship
  379. const CGHeroInstance * battleGetOwner(int stackID); //returns hero that owns given stack; NULL if none
  380. si8 battleMaxSpellLevel(); //calculates maximum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, SPELL_LEVELS is returned
  381. bool battleCanShoot(int ID, int dest); //determines if stack with given ID shoot at the selected destination
  382. UpgradeInfo getUpgradeInfo(const CStackInstance &stack);
  383. int getPlayerRelations(ui8 color1, ui8 color2);// 0 = enemy, 1 = ally, 2 = same player
  384. //float getMarketEfficiency(int player, int mode=0);
  385. std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID);
  386. int canBuildStructure(const CGTownInstance *t, int ID);// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
  387. bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile
  388. bool checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst) const; //check if src tile is visitable from dst tile
  389. bool getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath &ret); //calculates path between src and dest; returns pointer to newly allocated CPath or NULL if path does not exists
  390. void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or NULL if path does not exists
  391. int3 guardingCreaturePosition (int3 pos) const;
  392. int victoryCheck(ui8 player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else
  393. int lossCheck(ui8 player) const; //checks if given player is loser; -1 if std loss, 1 if special, 0 else
  394. ui8 checkForStandardWin() const; //returns color of player that accomplished standard victory conditions or 255 if no winner
  395. bool checkForStandardLoss(ui8 player) const; //checks if given player lost the game
  396. void obtainPlayersStats(SThievesGuildInfo & tgi, int level); //fills tgi with info about other players that is available at given level of thieves' guild
  397. std::map<ui32,CGHeroInstance *> unusedHeroesFromPool(); //heroes pool without heroes that are available in taverns
  398. bool isVisible(int3 pos, int player);
  399. bool isVisible(const CGObjectInstance *obj, int player);
  400. CGameState(); //c-tor
  401. ~CGameState(); //d-tor
  402. void getNeighbours(const TerrainTile &srct, int3 tile, std::vector<int3> &vec, const boost::logic::tribool &onLand, bool limitCoastSailing);
  403. int getMovementCost(const CGHeroInstance *h, const int3 &src, const int3 &dest, int remainingMovePoints=-1, bool checkLast=true);
  404. int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
  405. template <typename Handler> void serialize(Handler &h, const int version)
  406. {
  407. h & scenarioOps & seed & currentPlayer & day & map & players & teams & hpool & globalEffects & campaign;
  408. h & villages & forts & capitols;
  409. if(!h.saving)
  410. {
  411. loadTownDInfos();
  412. }
  413. }
  414. friend class CCallback;
  415. friend class CLuaCallback;
  416. friend class CClient;
  417. friend void initGameState(Mapa * map, CGameInfo * cgi);
  418. friend class IGameCallback;
  419. friend class CMapHandler;
  420. friend class CGameHandler;
  421. };
  422. #endif // __CGAMESTATE_H__