CMapDefines.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 & message & resources
  31. & players & humanAffected & computerAffected & firstOccurence & nextOccurence;
  32. }
  33. };
  34. /// The castle event builds/adds buildings/creatures for a specific town.
  35. class DLL_LINKAGE CCastleEvent: public CMapEvent
  36. {
  37. public:
  38. CCastleEvent();
  39. std::set<BuildingID> buildings;
  40. std::vector<si32> creatures;
  41. CGTownInstance * town;
  42. template <typename Handler>
  43. void serialize(Handler & h, const int version)
  44. {
  45. h & static_cast<CMapEvent &>(*this);
  46. h & buildings & creatures;
  47. }
  48. };
  49. /// The terrain tile describes the terrain type and the visual representation of the terrain.
  50. /// Furthermore the struct defines whether the tile is visitable or/and blocked and which objects reside in it.
  51. struct DLL_LINKAGE TerrainTile
  52. {
  53. TerrainTile();
  54. /// Gets true if the terrain is not a rock. If from is water/land, same type is also required.
  55. bool entrableTerrain(const TerrainTile * from = nullptr) const;
  56. bool entrableTerrain(bool allowLand, bool allowSea) const;
  57. /// Checks for blocking objects and terraint type (water / land).
  58. bool isClear(const TerrainTile * from = nullptr) const;
  59. /// Gets the ID of the top visitable object or -1 if there is none.
  60. Obj topVisitableId(bool excludeTop = false) const;
  61. CGObjectInstance * topVisitableObj(bool excludeTop = false) const;
  62. bool isWater() const;
  63. bool isCoastal() const;
  64. EDiggingStatus getDiggingStatus(const bool excludeTop = true) const;
  65. bool hasFavourableWinds() const;
  66. ETerrainType terType;
  67. ui8 terView;
  68. ERiverType::ERiverType riverType;
  69. ui8 riverDir;
  70. ERoadType::ERoadType roadType;
  71. ui8 roadDir;
  72. /// first two bits - how to rotate terrain graphic (next two - river graphic, next two - road);
  73. /// 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favourable Winds effect
  74. ui8 extTileFlags;
  75. bool visitable;
  76. bool blocked;
  77. std::vector<CGObjectInstance *> visitableObjects;
  78. std::vector<CGObjectInstance *> blockingObjects;
  79. template <typename Handler>
  80. void serialize(Handler & h, const int version)
  81. {
  82. h & terType & terView & riverType & riverDir & roadType &roadDir & extTileFlags;
  83. h & visitable & blocked;
  84. h & visitableObjects & blockingObjects;
  85. }
  86. };