2
0

CPlayerState.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. /*
  3. * CPlayerState.h, part of VCMI engine
  4. *
  5. * Authors: listed in file AUTHORS in main folder
  6. *
  7. * License: GNU General Public License v2.0 or later
  8. * Full text of license available in license.txt file, in main folder
  9. *
  10. */
  11. #include "HeroBonus.h"
  12. class CGHeroInstance;
  13. class CGTownInstance;
  14. class CGDwelling;
  15. struct DLL_LINKAGE PlayerState : public CBonusSystemNode
  16. {
  17. public:
  18. PlayerColor color;
  19. bool human; //true if human controlled player, false for AI
  20. TeamID team;
  21. TResources resources;
  22. std::set<ObjectInstanceID> visitedObjects; // as a std::set, since most accesses here will be from visited status checks
  23. std::vector<ConstTransitivePtr<CGHeroInstance> > heroes;
  24. std::vector<ConstTransitivePtr<CGTownInstance> > towns;
  25. std::vector<ConstTransitivePtr<CGHeroInstance> > availableHeroes; //heroes available in taverns
  26. std::vector<ConstTransitivePtr<CGDwelling> > dwellings; //used for town growth
  27. std::vector<QuestInfo> quests; //store info about all received quests
  28. bool enteredWinningCheatCode, enteredLosingCheatCode; //if true, this player has entered cheat codes for loss / victory
  29. EPlayerStatus::EStatus status;
  30. boost::optional<ui8> daysWithoutCastle;
  31. PlayerState();
  32. PlayerState(PlayerState && other);
  33. std::string nodeName() const override;
  34. template <typename Handler> void serialize(Handler &h, const int version)
  35. {
  36. h & color & human & team & resources & status;
  37. h & heroes & towns & availableHeroes & dwellings & quests & visitedObjects;
  38. if(version < 760)
  39. {
  40. //was: h & getBonusList();
  41. BonusList junk;
  42. h & junk;
  43. }
  44. h & status & daysWithoutCastle;
  45. h & enteredLosingCheatCode & enteredWinningCheatCode;
  46. h & static_cast<CBonusSystemNode&>(*this);
  47. }
  48. };
  49. struct DLL_LINKAGE TeamState : public CBonusSystemNode
  50. {
  51. public:
  52. TeamID id; //position in gameState::teams
  53. std::set<PlayerColor> players; // members of this team
  54. std::vector<std::vector<std::vector<ui8> > > fogOfWarMap; //true - visible, false - hidden
  55. TeamState();
  56. TeamState(TeamState && other);
  57. template <typename Handler> void serialize(Handler &h, const int version)
  58. {
  59. h & id & players & fogOfWarMap;
  60. h & static_cast<CBonusSystemNode&>(*this);
  61. }
  62. };