CPlayerState.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * CPlayerState.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  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;
  37. h & human;
  38. h & team;
  39. h & resources;
  40. h & status;
  41. h & heroes;
  42. h & towns;
  43. h & availableHeroes;
  44. h & dwellings;
  45. h & quests;
  46. h & visitedObjects;
  47. if(version < 760)
  48. {
  49. //was: h & getBonusList();
  50. BonusList junk;
  51. h & junk;
  52. }
  53. h & status;
  54. h & daysWithoutCastle;
  55. h & enteredLosingCheatCode;
  56. h & enteredWinningCheatCode;
  57. h & static_cast<CBonusSystemNode&>(*this);
  58. }
  59. };
  60. struct DLL_LINKAGE TeamState : public CBonusSystemNode
  61. {
  62. public:
  63. TeamID id; //position in gameState::teams
  64. std::set<PlayerColor> players; // members of this team
  65. //TODO: boost::array, bool if possible
  66. std::vector<std::vector<std::vector<ui8> > > fogOfWarMap; //true - visible, false - hidden
  67. TeamState();
  68. TeamState(TeamState && other);
  69. template <typename Handler> void serialize(Handler &h, const int version)
  70. {
  71. h & id;
  72. h & players;
  73. h & fogOfWarMap;
  74. h & static_cast<CBonusSystemNode&>(*this);
  75. }
  76. };