2
0

CMapDefines.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * CMapDefines.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. VCMI_LIB_NAMESPACE_BEGIN
  12. class TerrainType;
  13. class RiverType;
  14. class RoadType;
  15. /// The map event is an event which e.g. gives or takes resources of a specific
  16. /// amount to/from players and can appear regularly or once a time.
  17. class DLL_LINKAGE CMapEvent
  18. {
  19. public:
  20. CMapEvent();
  21. bool earlierThan(const CMapEvent & other) const;
  22. bool earlierThanOrEqual(const CMapEvent & other) const;
  23. std::string name;
  24. std::string message;
  25. TResources resources;
  26. ui8 players; // affected players, bit field?
  27. ui8 humanAffected;
  28. ui8 computerAffected;
  29. ui32 firstOccurence;
  30. ui32 nextOccurence; /// specifies after how many days the event will occur the next time; 0 if event occurs only one time
  31. template <typename Handler>
  32. void serialize(Handler & h, const int version)
  33. {
  34. h & name;
  35. h & message;
  36. h & resources;
  37. h & players;
  38. h & humanAffected;
  39. h & computerAffected;
  40. h & firstOccurence;
  41. h & nextOccurence;
  42. }
  43. };
  44. /// The castle event builds/adds buildings/creatures for a specific town.
  45. class DLL_LINKAGE CCastleEvent: public CMapEvent
  46. {
  47. public:
  48. CCastleEvent();
  49. std::set<BuildingID> buildings;
  50. std::vector<si32> creatures;
  51. CGTownInstance * town;
  52. template <typename Handler>
  53. void serialize(Handler & h, const int version)
  54. {
  55. h & static_cast<CMapEvent &>(*this);
  56. h & buildings;
  57. h & creatures;
  58. }
  59. };
  60. /// The terrain tile describes the terrain type and the visual representation of the terrain.
  61. /// Furthermore the struct defines whether the tile is visitable or/and blocked and which objects reside in it.
  62. struct DLL_LINKAGE TerrainTile
  63. {
  64. TerrainTile();
  65. /// Gets true if the terrain is not a rock. If from is water/land, same type is also required.
  66. bool entrableTerrain(const TerrainTile * from = nullptr) const;
  67. bool entrableTerrain(bool allowLand, bool allowSea) const;
  68. /// Checks for blocking objects and terraint type (water / land).
  69. bool isClear(const TerrainTile * from = nullptr) const;
  70. /// Gets the ID of the top visitable object or -1 if there is none.
  71. Obj topVisitableId(bool excludeTop = false) const;
  72. CGObjectInstance * topVisitableObj(bool excludeTop = false) const;
  73. bool isWater() const;
  74. EDiggingStatus getDiggingStatus(const bool excludeTop = true) const;
  75. bool hasFavorableWinds() const;
  76. const TerrainType * terType;
  77. ui8 terView;
  78. const RiverType * riverType;
  79. ui8 riverDir;
  80. const RoadType * roadType;
  81. ui8 roadDir;
  82. /// first two bits - how to rotate terrain graphic (next two - river graphic, next two - road);
  83. /// 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favorable Winds effect
  84. ui8 extTileFlags;
  85. bool visitable;
  86. bool blocked;
  87. std::vector<CGObjectInstance *> visitableObjects;
  88. std::vector<CGObjectInstance *> blockingObjects;
  89. template <typename Handler>
  90. void serialize(Handler & h, const int version)
  91. {
  92. h & terType;
  93. h & terView;
  94. h & riverType;
  95. h & riverDir;
  96. h & roadType;
  97. h & roadDir;
  98. h & extTileFlags;
  99. h & visitable;
  100. h & blocked;
  101. h & visitableObjects;
  102. h & blockingObjects;
  103. }
  104. };
  105. VCMI_LIB_NAMESPACE_END