CGameState.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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 "StackFeature.h"
  14. #include "HeroBonus.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 CLuaCallback;
  33. class CCPPObjectScript;
  34. class CCreatureSet;
  35. class CStack;
  36. class CGHeroInstance;
  37. class CGTownInstance;
  38. class CArmedInstance;
  39. class CGDwelling;
  40. class CGDefInfo;
  41. class CObjectScript;
  42. class CGObjectInstance;
  43. class CCreature;
  44. struct Mapa;
  45. struct StartInfo;
  46. struct SDL_Surface;
  47. class CMapHandler;
  48. class CPathfinder;
  49. struct SetObjectProperty;
  50. struct MetaString;
  51. struct CPack;
  52. class CSpell;
  53. struct TerrainTile;
  54. class CHeroClass;
  55. namespace boost
  56. {
  57. class shared_mutex;
  58. }
  59. struct DLL_EXPORT InfoAboutHero
  60. {
  61. private:
  62. void assign(const InfoAboutHero & iah);
  63. public:
  64. struct DLL_EXPORT Details
  65. {
  66. std::vector<int> primskills;
  67. int mana, luck, morale;
  68. } *details;
  69. char owner;
  70. const CHeroClass *hclass;
  71. std::string name;
  72. int portrait;
  73. CCreatureSet army; //numbers of creatures are exact numbers if detailed else they are quantity ids (0 - a few, 1 - several and so on)
  74. InfoAboutHero();
  75. InfoAboutHero(const InfoAboutHero & iah);
  76. InfoAboutHero & operator=(const InfoAboutHero & iah);
  77. ~InfoAboutHero();
  78. void initFromHero(const CGHeroInstance *h, bool detailed);
  79. };
  80. struct DLL_EXPORT SThievesGuildInfo
  81. {
  82. std::vector<ui8> playerColors; //colors of players that are in-game
  83. std::vector< std::list< ui8 > > numOfTowns, numOfHeroes, gold, woodOre, mercSulfCrystGems, obelisks, artifacts, army, income; // [place] -> [colours of players]
  84. std::map<ui8, InfoAboutHero> colorToBestHero; //maps player's color to his best heros'
  85. std::map<ui8, si8> personality; // color to personality // -1 - human, AI -> (00 - random, 01 - warrior, 02 - builder, 03 - explorer)
  86. std::map<ui8, si32> bestCreature; // color to ID // id or -1 if not known
  87. // template <typename Handler> void serialize(Handler &h, const int version)
  88. // {
  89. // h & playerColors & numOfTowns & numOfHeroes & gold & woodOre & mercSulfCrystGems & obelisks & artifacts & army & income;
  90. // h & colorToBestHero & personality & bestCreature;
  91. // }
  92. };
  93. struct DLL_EXPORT PlayerState
  94. {
  95. public:
  96. enum EStatus {INGAME, LOSER, WINNER};
  97. ui8 color, serial;
  98. ui8 human; //true if human controlled player, false for AI
  99. ui32 currentSelection; //id of hero/town, 0xffffffff if none
  100. std::vector<std::vector<std::vector<ui8> > > fogOfWarMap; //true - visible, false - hidden
  101. std::vector<si32> resources;
  102. std::vector<CGHeroInstance *> heroes;
  103. std::vector<CGTownInstance *> towns;
  104. std::vector<CGHeroInstance *> availableHeroes; //heroes available in taverns
  105. std::vector<CGDwelling *> dwellings; //used for town growth
  106. BonusList bonuses; //player bonuses
  107. ui8 status; //0 - in game, 1 - loser, 2 - winner <- uses EStatus enum
  108. ui8 daysWithoutCastle;
  109. PlayerState();
  110. template <typename Handler> void serialize(Handler &h, const int version)
  111. {
  112. h & color & serial & human & currentSelection & fogOfWarMap & resources & status;
  113. h & heroes & towns & availableHeroes & dwellings & bonuses & status & daysWithoutCastle;
  114. // ui32 size;
  115. // if(h.saving) //write subids of available heroes
  116. // {
  117. // size = availableHeroes.size();
  118. // h & size;
  119. // for(size_t i=0; i < size; i++)
  120. // {
  121. // if(availableHeroes[i])
  122. // {
  123. // h & availableHeroes[i]->subID;
  124. // }
  125. // else
  126. // {
  127. // ui32 none = 0xffffffff;
  128. // h & none;
  129. // }
  130. // }
  131. // }
  132. // else
  133. // {
  134. // ui32 hid;
  135. // h & size;
  136. // for(size_t i=0; i < size; i++)
  137. // {
  138. // //fill availableHeroes with dummy hero instances, holding subids
  139. // h & hid;
  140. // availableHeroes.push_back(new CGHeroInstance);
  141. // availableHeroes[availableHeroes.size()-1]->subID = hid;
  142. // }
  143. // }
  144. }
  145. };
  146. struct DLL_EXPORT CObstacleInstance
  147. {
  148. int uniqueID;
  149. int ID; //ID of obstacle (defines type of it)
  150. int pos; //position on battlefield
  151. template <typename Handler> void serialize(Handler &h, const int version)
  152. {
  153. h & ID & pos & uniqueID;
  154. }
  155. };
  156. //only for use in BattleInfo
  157. struct DLL_EXPORT SiegeInfo
  158. {
  159. 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
  160. template <typename Handler> void serialize(Handler &h, const int version)
  161. {
  162. h & wallState;
  163. }
  164. };
  165. struct DLL_EXPORT BattleInfo
  166. {
  167. ui8 side1, side2; //side1 - attacker, side2 - defender
  168. si32 round, activeStack;
  169. ui8 siege; // = 0 ordinary battle = 1 a siege with a Fort = 2 a siege with a Citadel = 3 a siege with a Castle
  170. si32 tid; //used during town siege - id of attacked town; -1 if not town defence
  171. int3 tile; //for background and bonuses
  172. CGHeroInstance *heroes[2];
  173. CCreatureSet army1, army2;
  174. std::vector<CStack*> stacks;
  175. std::vector<CObstacleInstance> obstacles;
  176. ui8 castSpells[2]; //[0] - attacker, [1] - defender
  177. SiegeInfo si;
  178. template <typename Handler> void serialize(Handler &h, const int version)
  179. {
  180. h & side1 & side2 & round & activeStack & siege & tid & tile & stacks & army1 & army2 & obstacles
  181. & castSpells & si;
  182. h & heroes;
  183. }
  184. const CStack * getNextStack() const; //which stack will have turn after current one
  185. void getStackQueue(std::vector<const CStack *> &out, int howMany, int turn = 0, int lastMoved = -1) const; //returns stack in order of their movement action
  186. CStack * getStack(int stackID, bool onlyAlive = true);
  187. const CStack * getStack(int stackID, bool onlyAlive = true) const;
  188. CStack * getStackT(int tileID, bool onlyAlive = true);
  189. const CStack * getStackT(int tileID, bool onlyAlive = true) const;
  190. 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
  191. static bool isAccessible(int hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS
  192. 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
  193. 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
  194. std::vector<int> getAccessibility(int stackID, bool addOccupiable) const; //returns vector of accessible tiles (taking into account the creature range)
  195. bool isStackBlocked(int ID); //returns true if there is neighbouring enemy stack
  196. 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)
  197. static std::vector<int> neighbouringTiles(int hex);
  198. static ui32 calculateDmg(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge); //charge - number of hexes travelled before attack (for champion's jousting)
  199. static std::pair<ui32, ui32> calculateDmgRange(const CStack* attacker, const CStack* defender, const CGHeroInstance * attackerHero, const CGHeroInstance * defendingHero, bool shooting, ui8 charge); //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
  200. void calculateCasualties(std::map<ui32,si32> *casualties) const; //casualties are array of maps size 2 (attacker, defeneder), maps are (crid => amount)
  201. std::set<CStack*> getAttackedCreatures(const CSpell * s, const CGHeroInstance * caster, int destinationTile); //calculates stack affected by given spell
  202. static int calculateSpellDuration(const CSpell * spell, const CGHeroInstance * caster);
  203. CStack * generateNewStack(const CGHeroInstance * owner, int creatureID, int amount, 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
  204. ui32 getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //returns cost of given spell
  205. int hexToWallPart(int hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
  206. 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)
  207. ui32 calculateSpellDmg(const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const; //calculates damage inflicted by spell
  208. };
  209. class DLL_EXPORT CStack
  210. {
  211. public:
  212. ui32 ID; //unique ID of stack
  213. CCreature * creature;
  214. ui32 amount, baseAmount;
  215. ui32 firstHPleft; //HP of first creature in stack
  216. ui8 owner, slot; //owner - player colour (255 for neutrals), slot - position in garrison (may be 255 for neutrals/called creatures)
  217. ui8 attackerOwned; //if true, this stack is owned by attakcer (this one from left hand side of battle)
  218. si16 position; //position on battlefield; -2 - keep, -3 - lower tower, -4 - upper tower
  219. ui8 counterAttacks; //how many counter attacks can be performed more in this turn (by default set at the beginning of the round to 1)
  220. si16 shots; //how many shots left
  221. si8 morale, luck; //base stack luck/morale
  222. std::vector<StackFeature> features;
  223. std::set<ECombatInfo> state;
  224. struct StackEffect
  225. {
  226. ui16 id; //spell id
  227. ui8 level; //skill level
  228. ui16 turnsRemain;
  229. template <typename Handler> void serialize(Handler &h, const int version)
  230. {
  231. h & id & level & turnsRemain;
  232. }
  233. };
  234. std::vector<StackEffect> effects;
  235. int valOfFeatures(StackFeature::ECombatFeatures type, int subtype = -1024, int turn = 0) const;//subtype -> subtype of bonus, if -1024 then any
  236. bool hasFeatureOfType(StackFeature::ECombatFeatures type, int subtype = -1024, int turn = 0) const; //determines if stack has a bonus of given type (and optionally subtype)
  237. CStack(CCreature * C, int A, int O, int I, bool AO, int S); //c-tor
  238. CStack() : ID(-1), creature(NULL), amount(-1), baseAmount(-1), firstHPleft(-1), owner(255), slot(255), attackerOwned(true), position(-1), counterAttacks(1) {} //c-tor
  239. const StackEffect * getEffect(ui16 id, int turn = 0) const; //effect id (SP)
  240. ui8 howManyEffectsSet(ui16 id) const; //returns amount of effects with given id set for this stack
  241. bool willMove(int turn = 0) const; //if stack has remaining move this turn
  242. bool moved(int turn = 0) const; //if stack was already moved this turn
  243. bool canMove(int turn = 0) const; //if stack can move
  244. ui32 Speed(int turn = 0) const; //get speed of creature with all modificators
  245. si8 Morale() const; //get morale of stack with all modificators
  246. si8 Luck() const; //get luck of stack with all modificators
  247. si32 Attack() const; //get attack of stack with all modificators
  248. si32 Defense(bool withFrenzy = true) const; //get defense of stack with all modificators
  249. ui16 MaxHealth() const; //get max HP of stack with all modifiers
  250. template <typename Handler> void save(Handler &h, const int version)
  251. {
  252. h & creature->idNumber;
  253. }
  254. template <typename Handler> void load(Handler &h, const int version)
  255. {
  256. ui32 id;
  257. h & id;
  258. creature = &VLC->creh->creatures[id];
  259. //features = creature->abilities;
  260. }
  261. template <typename Handler> void serialize(Handler &h, const int version)
  262. {
  263. h & ID & amount & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks
  264. & shots & morale & luck & features;
  265. if(h.saving)
  266. save(h,version);
  267. else
  268. load(h,version);
  269. }
  270. bool alive() const //determines if stack is alive
  271. {
  272. return vstd::contains(state,ALIVE);
  273. }
  274. };
  275. class DLL_EXPORT CMP_stack
  276. {
  277. int phase; //rules of which phase will be used
  278. int turn;
  279. public:
  280. bool operator ()(const CStack* a, const CStack* b);
  281. CMP_stack(int Phase = 1, int Turn = 0);
  282. };
  283. struct UpgradeInfo
  284. {
  285. int oldID; //creature to be upgraded
  286. std::vector<int> newID; //possible upgrades
  287. std::vector<std::set<std::pair<int,int> > > cost; // cost[upgrade_serial] -> set of pairs<resource_ID,resource_amount>
  288. UpgradeInfo(){oldID = -1;};
  289. };
  290. struct CPathNode
  291. {
  292. bool accessible; //true if a hero can be on this node
  293. int dist; //distance from the first node of searching; -1 is infinity
  294. CPathNode * theNodeBefore;
  295. int3 coord; //coordiantes
  296. bool visited;
  297. };
  298. struct CGPathNode
  299. {
  300. enum
  301. {
  302. ACCESSIBLE=1, //tile can be entered and passed
  303. VISITABLE, //tile can be entered as the last tile in path
  304. BLOCKVIS, //visitable from neighbouring tile but not passable
  305. BLOCKED //tile can't be entered nor visited
  306. };
  307. ui8 accessible; //the enum above
  308. ui8 land;
  309. ui8 turns;
  310. ui32 moveRemains;
  311. CGPathNode * theNodeBefore;
  312. int3 coord; //coordinates
  313. CGPathNode();
  314. };
  315. struct DLL_EXPORT CPath
  316. {
  317. std::vector<CPathNode> nodes; //just get node by node
  318. int3 startPos() const; // start point
  319. int3 endPos() const; //destination point
  320. void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object'
  321. };
  322. struct DLL_EXPORT CGPath
  323. {
  324. std::vector<CGPathNode> nodes; //just get node by node
  325. int3 startPos() const; // start point
  326. int3 endPos() const; //destination point
  327. void convert(ui8 mode); //mode=0 -> from 'manifest' to 'object'
  328. };
  329. struct DLL_EXPORT CPathsInfo
  330. {
  331. const CGHeroInstance *hero;
  332. int3 hpos;
  333. int3 sizes;
  334. CGPathNode ***nodes; //[w][h][level]
  335. bool getPath(const int3 &dst, CGPath &out);
  336. CPathsInfo(const int3 &Sizes);
  337. ~CPathsInfo();
  338. };
  339. class DLL_EXPORT CGameState
  340. {
  341. public:
  342. StartInfo* scenarioOps;
  343. ui32 seed;
  344. ui8 currentPlayer; //ID of player currently having turn
  345. BattleInfo *curB; //current battle
  346. ui32 day; //total number of days in game
  347. Mapa * map;
  348. std::map<ui8, PlayerState> players; //ID <-> player state
  349. std::map<int, CGDefInfo*> villages, forts, capitols; //def-info for town graphics
  350. std::vector<ui32> resVals; //default values of resources in gold
  351. struct DLL_EXPORT HeroesPool
  352. {
  353. std::map<ui32,CGHeroInstance *> heroesPool; //[subID] - heroes available to buy; NULL if not available
  354. std::map<ui32,ui8> pavailable; // [subid] -> which players can recruit hero (binary flags)
  355. CGHeroInstance * pickHeroFor(bool native, int player, const CTown *town, std::map<ui32,CGHeroInstance *> &available) const;
  356. template <typename Handler> void serialize(Handler &h, const int version)
  357. {
  358. h & heroesPool & pavailable;
  359. }
  360. } hpool; //we have here all heroes available on this map that are not hired
  361. boost::shared_mutex *mx;
  362. PlayerState *getPlayer(ui8 color, bool verbose = true);
  363. const PlayerState *getPlayer(ui8 color, bool verbose = true) const;
  364. void init(StartInfo * si, Mapa * map, int Seed);
  365. void loadTownDInfos();
  366. void randomizeObject(CGObjectInstance *cur);
  367. std::pair<int,int> pickObject(CGObjectInstance *obj); //chooses type of object to be randomized, returns <type, subtype>
  368. int pickHero(int owner);
  369. void apply(CPack *pack);
  370. CGHeroInstance *getHero(int objid);
  371. CGTownInstance *getTown(int objid);
  372. const CGHeroInstance *getHero(int objid) const;
  373. const CGTownInstance *getTown(int objid) const;
  374. bool battleMoveCreatureStack(int ID, int dest);
  375. bool battleAttackCreatureStack(int ID, int dest);
  376. bool battleShootCreatureStack(int ID, int dest);
  377. bool battleCanFlee(int player); //returns true if player can flee from the battle
  378. int battleGetStack(int pos, bool onlyAlive); //returns ID of stack at given tile
  379. 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
  380. const CGHeroInstance * battleGetOwner(int stackID); //returns hero that owns given stack; NULL if none
  381. 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
  382. bool battleCanShoot(int ID, int dest); //determines if stack with given ID shoot at the selected destination
  383. UpgradeInfo getUpgradeInfo(const CArmedInstance *obj, int stackPos);
  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. int victoryCheck(ui8 player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else
  392. int lossCheck(ui8 player) const; //checks if given player is loser; -1 if std loss, 1 if special, 0 else
  393. ui8 checkForStandardWin() const; //returns color of player that accomplished standard victory conditions or 255 if no winner
  394. bool checkForStandardLoss(ui8 player) const; //checks if given player lost the game
  395. void obtainPlayersStats(SThievesGuildInfo & tgi, int level); //fills tgi with info about other players that is available at given level of thieves' guild
  396. bool isVisible(int3 pos, int player);
  397. bool isVisible(const CGObjectInstance *obj, int player);
  398. CGameState(); //c-tor
  399. ~CGameState(); //d-tor
  400. void getNeighbours(const TerrainTile &srct, int3 tile, std::vector<int3> &vec, const boost::logic::tribool &onLand);
  401. int getMovementCost(const CGHeroInstance *h, const int3 &src, const int3 &dest, int remainingMovePoints=-1, bool checkLast=true);
  402. 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
  403. template <typename Handler> void serialize(Handler &h, const int version)
  404. {
  405. h & scenarioOps & seed & currentPlayer & day & map & players & resVals & hpool;
  406. if(!h.saving)
  407. {
  408. loadTownDInfos();
  409. // //recreating towns/heroes vectors in players entries
  410. // for(int i=0; i<map->towns.size(); i++)
  411. // if(map->towns[i]->tempOwner < PLAYER_LIMIT)
  412. // getPlayer(map->towns[i]->tempOwner)->towns.push_back(map->towns[i]);
  413. // for(int i=0; i<map->heroes.size(); i++)
  414. // if(map->heroes[i]->tempOwner < PLAYER_LIMIT)
  415. // getPlayer(map->heroes[i]->tempOwner)->heroes.push_back(map->heroes[i]);
  416. // //recreating available heroes
  417. // for(std::map<ui8,PlayerState>::iterator i=players.begin(); i!=players.end(); i++)
  418. // {
  419. // for(size_t j=0; j < i->second.availableHeroes.size(); j++)
  420. // {
  421. // ui32 hlp = i->second.availableHeroes[j]->subID;
  422. // delete i->second.availableHeroes[j];
  423. // if(hlp != 0xffffffff)
  424. // {
  425. // assert(vstd::contains(hpool.heroesPool, hlp));
  426. // i->second.availableHeroes[j] = hpool.heroesPool[hlp];
  427. // }
  428. // else
  429. // {
  430. // i->second.availableHeroes[j] = NULL;
  431. // }
  432. // }
  433. // }
  434. }
  435. }
  436. friend class CCallback;
  437. friend class CLuaCallback;
  438. friend class CClient;
  439. friend void initGameState(Mapa * map, CGameInfo * cgi);
  440. friend class IGameCallback;
  441. friend class CMapHandler;
  442. friend class CGameHandler;
  443. };
  444. #endif // __CGAMESTATE_H__