CMapDefines.h 3.2 KB

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