CMapDefines.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. EDiggingStatus getDiggingStatus(const bool excludeTop = true) const;
  64. bool hasFavorableWinds() const;
  65. ETerrainType terType;
  66. ui8 terView;
  67. ERiverType::ERiverType riverType;
  68. ui8 riverDir;
  69. ERoadType::ERoadType roadType;
  70. ui8 roadDir;
  71. /// first two bits - how to rotate terrain graphic (next two - river graphic, next two - road);
  72. /// 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favorable Winds effect
  73. ui8 extTileFlags;
  74. bool visitable;
  75. bool blocked;
  76. std::vector<CGObjectInstance *> visitableObjects;
  77. std::vector<CGObjectInstance *> blockingObjects;
  78. template <typename Handler>
  79. void serialize(Handler & h, const int version)
  80. {
  81. h & terType & terView & riverType & riverDir & roadType &roadDir & extTileFlags;
  82. h & visitable & blocked;
  83. h & visitableObjects & blockingObjects;
  84. }
  85. };