EntityIdentifiers.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. /*
  2. * EntityIdentifiers.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 "NumericConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class Artifact;
  14. class ArtifactService;
  15. class Creature;
  16. class CreatureService;
  17. namespace spells
  18. {
  19. class Spell;
  20. class Service;
  21. }
  22. class CArtifact;
  23. class CArtifactInstance;
  24. class CCreature;
  25. class CHero;
  26. class CSpell;
  27. class CSkill;
  28. class CGameInfoCallback;
  29. class CNonConstInfoCallback;
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. class IdentifierBase
  32. {
  33. protected:
  34. constexpr IdentifierBase():
  35. num(-1)
  36. {}
  37. explicit constexpr IdentifierBase(int32_t value):
  38. num(value)
  39. {}
  40. ~IdentifierBase() = default;
  41. public:
  42. int32_t num;
  43. constexpr int32_t getNum() const
  44. {
  45. return num;
  46. }
  47. constexpr void setNum(int32_t value)
  48. {
  49. num = value;
  50. }
  51. struct hash
  52. {
  53. size_t operator()(const IdentifierBase & id) const
  54. {
  55. return std::hash<int>()(id.num);
  56. }
  57. };
  58. template <typename Handler> void serialize(Handler &h, const int version)
  59. {
  60. h & num;
  61. }
  62. constexpr void advance(int change)
  63. {
  64. num += change;
  65. }
  66. constexpr operator int32_t () const
  67. {
  68. return num;
  69. }
  70. friend std::ostream& operator<<(std::ostream& os, const IdentifierBase& dt)
  71. {
  72. return os << dt.num;
  73. }
  74. };
  75. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. // Note: use template to force different type, blocking any Identifier<A> <=> Identifier<B> comparisons
  77. template<typename FinalClass>
  78. class Identifier : public IdentifierBase
  79. {
  80. using BaseClass = IdentifierBase;
  81. public:
  82. constexpr Identifier()
  83. {}
  84. explicit constexpr Identifier(int32_t value):
  85. IdentifierBase(value)
  86. {}
  87. constexpr bool operator == (const Identifier & b) const { return BaseClass::num == b.num; }
  88. constexpr bool operator <= (const Identifier & b) const { return BaseClass::num <= b.num; }
  89. constexpr bool operator >= (const Identifier & b) const { return BaseClass::num >= b.num; }
  90. constexpr bool operator != (const Identifier & b) const { return BaseClass::num != b.num; }
  91. constexpr bool operator < (const Identifier & b) const { return BaseClass::num < b.num; }
  92. constexpr bool operator > (const Identifier & b) const { return BaseClass::num > b.num; }
  93. constexpr FinalClass & operator++()
  94. {
  95. ++BaseClass::num;
  96. return static_cast<FinalClass&>(*this);
  97. }
  98. constexpr FinalClass & operator--()
  99. {
  100. --BaseClass::num;
  101. return static_cast<FinalClass&>(*this);
  102. }
  103. constexpr FinalClass operator--(int)
  104. {
  105. FinalClass ret(num);
  106. --BaseClass::num;
  107. return ret;
  108. }
  109. constexpr FinalClass operator++(int)
  110. {
  111. FinalClass ret(num);
  112. ++BaseClass::num;
  113. return ret;
  114. }
  115. };
  116. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  117. template<typename FinalClass, typename BaseClass>
  118. class IdentifierWithEnum : public BaseClass
  119. {
  120. using EnumType = typename BaseClass::Type;
  121. static_assert(std::is_same_v<std::underlying_type_t<EnumType>, int32_t>, "Entity Identifier must use int32_t");
  122. public:
  123. constexpr EnumType toEnum() const
  124. {
  125. return static_cast<EnumType>(BaseClass::num);
  126. }
  127. constexpr IdentifierWithEnum(const EnumType & enumValue)
  128. {
  129. BaseClass::num = static_cast<int32_t>(enumValue);
  130. }
  131. constexpr IdentifierWithEnum(int32_t _num = -1)
  132. {
  133. BaseClass::num = _num;
  134. }
  135. constexpr bool operator == (const EnumType & b) const { return BaseClass::num == static_cast<int32_t>(b); }
  136. constexpr bool operator <= (const EnumType & b) const { return BaseClass::num <= static_cast<int32_t>(b); }
  137. constexpr bool operator >= (const EnumType & b) const { return BaseClass::num >= static_cast<int32_t>(b); }
  138. constexpr bool operator != (const EnumType & b) const { return BaseClass::num != static_cast<int32_t>(b); }
  139. constexpr bool operator < (const EnumType & b) const { return BaseClass::num < static_cast<int32_t>(b); }
  140. constexpr bool operator > (const EnumType & b) const { return BaseClass::num > static_cast<int32_t>(b); }
  141. constexpr bool operator == (const IdentifierWithEnum & b) const { return BaseClass::num == b.num; }
  142. constexpr bool operator <= (const IdentifierWithEnum & b) const { return BaseClass::num <= b.num; }
  143. constexpr bool operator >= (const IdentifierWithEnum & b) const { return BaseClass::num >= b.num; }
  144. constexpr bool operator != (const IdentifierWithEnum & b) const { return BaseClass::num != b.num; }
  145. constexpr bool operator < (const IdentifierWithEnum & b) const { return BaseClass::num < b.num; }
  146. constexpr bool operator > (const IdentifierWithEnum & b) const { return BaseClass::num > b.num; }
  147. constexpr FinalClass & operator++()
  148. {
  149. ++BaseClass::num;
  150. return static_cast<FinalClass&>(*this);
  151. }
  152. constexpr FinalClass operator++(int)
  153. {
  154. FinalClass ret(BaseClass::num);
  155. ++BaseClass::num;
  156. return ret;
  157. }
  158. };
  159. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  160. class ArtifactInstanceID : public Identifier<ArtifactInstanceID>
  161. {
  162. public:
  163. using Identifier<ArtifactInstanceID>::Identifier;
  164. };
  165. class QueryID : public Identifier<QueryID>
  166. {
  167. public:
  168. using Identifier<QueryID>::Identifier;
  169. DLL_LINKAGE static const QueryID NONE;
  170. DLL_LINKAGE static const QueryID CLIENT;
  171. };
  172. class BattleID : public Identifier<BattleID>
  173. {
  174. public:
  175. using Identifier<BattleID>::Identifier;
  176. DLL_LINKAGE static const BattleID NONE;
  177. };
  178. class ObjectInstanceID : public Identifier<ObjectInstanceID>
  179. {
  180. public:
  181. using Identifier<ObjectInstanceID>::Identifier;
  182. DLL_LINKAGE static const ObjectInstanceID NONE;
  183. };
  184. class HeroClassID : public Identifier<HeroClassID>
  185. {
  186. public:
  187. using Identifier<HeroClassID>::Identifier;
  188. };
  189. class HeroTypeID : public Identifier<HeroTypeID>
  190. {
  191. public:
  192. using Identifier<HeroTypeID>::Identifier;
  193. ///json serialization helpers
  194. DLL_LINKAGE static si32 decode(const std::string & identifier);
  195. DLL_LINKAGE static std::string encode(const si32 index);
  196. static std::string entityType();
  197. DLL_LINKAGE static const HeroTypeID NONE;
  198. DLL_LINKAGE static const HeroTypeID RANDOM;
  199. bool isValid() const
  200. {
  201. return getNum() >= 0;
  202. }
  203. };
  204. class SlotID : public Identifier<SlotID>
  205. {
  206. public:
  207. using Identifier<SlotID>::Identifier;
  208. DLL_LINKAGE static const SlotID COMMANDER_SLOT_PLACEHOLDER;
  209. DLL_LINKAGE static const SlotID SUMMONED_SLOT_PLACEHOLDER; ///<for all summoned creatures, only during battle
  210. DLL_LINKAGE static const SlotID WAR_MACHINES_SLOT; ///<for all war machines during battle
  211. DLL_LINKAGE static const SlotID ARROW_TOWERS_SLOT; ///<for all arrow towers during battle
  212. bool validSlot() const
  213. {
  214. return getNum() >= 0 && getNum() < GameConstants::ARMY_SIZE;
  215. }
  216. };
  217. class DLL_LINKAGE PlayerColor : public Identifier<PlayerColor>
  218. {
  219. public:
  220. using Identifier<PlayerColor>::Identifier;
  221. enum EPlayerColor
  222. {
  223. PLAYER_LIMIT_I = 8,
  224. };
  225. static const PlayerColor SPECTATOR; //252
  226. static const PlayerColor CANNOT_DETERMINE; //253
  227. static const PlayerColor UNFLAGGABLE; //254 - neutral objects (pandora, banks)
  228. static const PlayerColor NEUTRAL; //255
  229. static const PlayerColor PLAYER_LIMIT; //player limit per map
  230. bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral)
  231. bool isSpectator() const;
  232. std::string toString() const;
  233. static si32 decode(const std::string& identifier);
  234. static std::string encode(const si32 index);
  235. static std::string entityType();
  236. };
  237. class TeamID : public Identifier<TeamID>
  238. {
  239. public:
  240. using Identifier<TeamID>::Identifier;
  241. DLL_LINKAGE static const TeamID NO_TEAM;
  242. };
  243. class TeleportChannelID : public Identifier<TeleportChannelID>
  244. {
  245. public:
  246. using Identifier<TeleportChannelID>::Identifier;
  247. };
  248. class SecondarySkillBase : public IdentifierBase
  249. {
  250. public:
  251. enum Type : int32_t
  252. {
  253. WRONG = -2,
  254. DEFAULT = -1,
  255. PATHFINDING = 0,
  256. ARCHERY,
  257. LOGISTICS,
  258. SCOUTING,
  259. DIPLOMACY,
  260. NAVIGATION,
  261. LEADERSHIP,
  262. WISDOM,
  263. MYSTICISM,
  264. LUCK,
  265. BALLISTICS,
  266. EAGLE_EYE,
  267. NECROMANCY,
  268. ESTATES,
  269. FIRE_MAGIC,
  270. AIR_MAGIC,
  271. WATER_MAGIC,
  272. EARTH_MAGIC,
  273. SCHOLAR,
  274. TACTICS,
  275. ARTILLERY,
  276. LEARNING,
  277. OFFENCE,
  278. ARMORER,
  279. INTELLIGENCE,
  280. SORCERY,
  281. RESISTANCE,
  282. FIRST_AID,
  283. SKILL_SIZE
  284. };
  285. static_assert(GameConstants::SKILL_QUANTITY == SKILL_SIZE, "Incorrect number of skills");
  286. };
  287. class SecondarySkill : public IdentifierWithEnum<SecondarySkill, SecondarySkillBase>
  288. {
  289. public:
  290. using IdentifierWithEnum<SecondarySkill, SecondarySkillBase>::IdentifierWithEnum;
  291. };
  292. class DLL_LINKAGE FactionID : public Identifier<FactionID>
  293. {
  294. public:
  295. using Identifier<FactionID>::Identifier;
  296. static const FactionID NONE;
  297. static const FactionID DEFAULT;
  298. static const FactionID RANDOM;
  299. static const FactionID ANY;
  300. static const FactionID CASTLE;
  301. static const FactionID RAMPART;
  302. static const FactionID TOWER;
  303. static const FactionID INFERNO;
  304. static const FactionID NECROPOLIS;
  305. static const FactionID DUNGEON;
  306. static const FactionID STRONGHOLD;
  307. static const FactionID FORTRESS;
  308. static const FactionID CONFLUX;
  309. static const FactionID NEUTRAL;
  310. static si32 decode(const std::string& identifier);
  311. static std::string encode(const si32 index);
  312. static std::string entityType();
  313. bool isValid() const
  314. {
  315. return getNum() >= 0;
  316. }
  317. };
  318. class BuildingIDBase : public IdentifierBase
  319. {
  320. public:
  321. //Quite useful as long as most of building mechanics hardcoded
  322. // NOTE: all building with completely configurable mechanics will be removed from list
  323. enum Type
  324. {
  325. DEFAULT = -50,
  326. HORDE_PLACEHOLDER7 = -36,
  327. HORDE_PLACEHOLDER6 = -35,
  328. HORDE_PLACEHOLDER5 = -34,
  329. HORDE_PLACEHOLDER4 = -33,
  330. HORDE_PLACEHOLDER3 = -32,
  331. HORDE_PLACEHOLDER2 = -31,
  332. HORDE_PLACEHOLDER1 = -30,
  333. NONE = -1,
  334. FIRST_REGULAR_ID = 0,
  335. MAGES_GUILD_1 = 0, MAGES_GUILD_2, MAGES_GUILD_3, MAGES_GUILD_4, MAGES_GUILD_5,
  336. TAVERN, SHIPYARD, FORT, CITADEL, CASTLE,
  337. VILLAGE_HALL, TOWN_HALL, CITY_HALL, CAPITOL, MARKETPLACE,
  338. RESOURCE_SILO, BLACKSMITH, SPECIAL_1, HORDE_1, HORDE_1_UPGR,
  339. SHIP, SPECIAL_2, SPECIAL_3, SPECIAL_4, HORDE_2,
  340. HORDE_2_UPGR, GRAIL, EXTRA_TOWN_HALL, EXTRA_CITY_HALL, EXTRA_CAPITOL,
  341. DWELL_FIRST=30, DWELL_LVL_2, DWELL_LVL_3, DWELL_LVL_4, DWELL_LVL_5, DWELL_LVL_6, DWELL_LAST=36,
  342. DWELL_UP_FIRST=37, DWELL_LVL_2_UP, DWELL_LVL_3_UP, DWELL_LVL_4_UP, DWELL_LVL_5_UP,
  343. DWELL_LVL_6_UP, DWELL_UP_LAST=43,
  344. DWELL_LVL_1 = DWELL_FIRST,
  345. DWELL_LVL_7 = DWELL_LAST,
  346. DWELL_LVL_1_UP = DWELL_UP_FIRST,
  347. DWELL_LVL_7_UP = DWELL_UP_LAST,
  348. DWELL_UP2_FIRST = DWELL_LVL_7_UP + 1,
  349. // //Special buildings for towns.
  350. CASTLE_GATE = SPECIAL_3, //Inferno
  351. FREELANCERS_GUILD = SPECIAL_2, //Stronghold
  352. ARTIFACT_MERCHANT = SPECIAL_1,
  353. };
  354. bool IsSpecialOrGrail() const
  355. {
  356. return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;
  357. }
  358. };
  359. class BuildingID : public IdentifierWithEnum<BuildingID, BuildingIDBase>
  360. {
  361. public:
  362. using IdentifierWithEnum<BuildingID, BuildingIDBase>::IdentifierWithEnum;
  363. };
  364. class ObjBase : public IdentifierBase
  365. {
  366. public:
  367. enum Type
  368. {
  369. NO_OBJ = -1,
  370. ALTAR_OF_SACRIFICE [[deprecated]] = 2,
  371. ANCHOR_POINT = 3,
  372. ARENA = 4,
  373. ARTIFACT = 5,
  374. PANDORAS_BOX = 6,
  375. BLACK_MARKET [[deprecated]] = 7,
  376. BOAT = 8,
  377. BORDERGUARD = 9,
  378. KEYMASTER = 10,
  379. BUOY = 11,
  380. CAMPFIRE = 12,
  381. CARTOGRAPHER = 13,
  382. SWAN_POND = 14,
  383. COVER_OF_DARKNESS = 15,
  384. CREATURE_BANK = 16,
  385. CREATURE_GENERATOR1 = 17,
  386. CREATURE_GENERATOR2 = 18,
  387. CREATURE_GENERATOR3 = 19,
  388. CREATURE_GENERATOR4 = 20,
  389. CURSED_GROUND1 = 21,
  390. CORPSE = 22,
  391. MARLETTO_TOWER = 23,
  392. DERELICT_SHIP = 24,
  393. DRAGON_UTOPIA = 25,
  394. EVENT = 26,
  395. EYE_OF_MAGI = 27,
  396. FAERIE_RING = 28,
  397. FLOTSAM = 29,
  398. FOUNTAIN_OF_FORTUNE = 30,
  399. FOUNTAIN_OF_YOUTH = 31,
  400. GARDEN_OF_REVELATION = 32,
  401. GARRISON = 33,
  402. HERO = 34,
  403. HILL_FORT = 35,
  404. GRAIL = 36,
  405. HUT_OF_MAGI = 37,
  406. IDOL_OF_FORTUNE = 38,
  407. LEAN_TO = 39,
  408. LIBRARY_OF_ENLIGHTENMENT = 41,
  409. LIGHTHOUSE = 42,
  410. MONOLITH_ONE_WAY_ENTRANCE = 43,
  411. MONOLITH_ONE_WAY_EXIT = 44,
  412. MONOLITH_TWO_WAY = 45,
  413. MAGIC_PLAINS1 = 46,
  414. SCHOOL_OF_MAGIC = 47,
  415. MAGIC_SPRING = 48,
  416. MAGIC_WELL = 49,
  417. MARKET_OF_TIME = 50,
  418. MERCENARY_CAMP = 51,
  419. MERMAID = 52,
  420. MINE = 53,
  421. MONSTER = 54,
  422. MYSTICAL_GARDEN = 55,
  423. OASIS = 56,
  424. OBELISK = 57,
  425. REDWOOD_OBSERVATORY = 58,
  426. OCEAN_BOTTLE = 59,
  427. PILLAR_OF_FIRE = 60,
  428. STAR_AXIS = 61,
  429. PRISON = 62,
  430. PYRAMID = 63,//subtype 0
  431. WOG_OBJECT = 63,//subtype > 0
  432. RALLY_FLAG = 64,
  433. RANDOM_ART = 65,
  434. RANDOM_TREASURE_ART = 66,
  435. RANDOM_MINOR_ART = 67,
  436. RANDOM_MAJOR_ART = 68,
  437. RANDOM_RELIC_ART = 69,
  438. RANDOM_HERO = 70,
  439. RANDOM_MONSTER = 71,
  440. RANDOM_MONSTER_L1 = 72,
  441. RANDOM_MONSTER_L2 = 73,
  442. RANDOM_MONSTER_L3 = 74,
  443. RANDOM_MONSTER_L4 = 75,
  444. RANDOM_RESOURCE = 76,
  445. RANDOM_TOWN = 77,
  446. REFUGEE_CAMP = 78,
  447. RESOURCE = 79,
  448. SANCTUARY = 80,
  449. SCHOLAR = 81,
  450. SEA_CHEST = 82,
  451. SEER_HUT = 83,
  452. CRYPT = 84,
  453. SHIPWRECK = 85,
  454. SHIPWRECK_SURVIVOR = 86,
  455. SHIPYARD = 87,
  456. SHRINE_OF_MAGIC_INCANTATION = 88,
  457. SHRINE_OF_MAGIC_GESTURE = 89,
  458. SHRINE_OF_MAGIC_THOUGHT = 90,
  459. SIGN = 91,
  460. SIRENS = 92,
  461. SPELL_SCROLL = 93,
  462. STABLES = 94,
  463. TAVERN = 95,
  464. TEMPLE = 96,
  465. DEN_OF_THIEVES = 97,
  466. TOWN = 98,
  467. TRADING_POST [[deprecated]] = 99,
  468. LEARNING_STONE = 100,
  469. TREASURE_CHEST = 101,
  470. TREE_OF_KNOWLEDGE = 102,
  471. SUBTERRANEAN_GATE = 103,
  472. UNIVERSITY [[deprecated]] = 104,
  473. WAGON = 105,
  474. WAR_MACHINE_FACTORY = 106,
  475. SCHOOL_OF_WAR = 107,
  476. WARRIORS_TOMB = 108,
  477. WATER_WHEEL = 109,
  478. WATERING_HOLE = 110,
  479. WHIRLPOOL = 111,
  480. WINDMILL = 112,
  481. WITCH_HUT = 113,
  482. HOLE = 124,
  483. RANDOM_MONSTER_L5 = 162,
  484. RANDOM_MONSTER_L6 = 163,
  485. RANDOM_MONSTER_L7 = 164,
  486. BORDER_GATE = 212,
  487. FREELANCERS_GUILD [[deprecated]] = 213,
  488. HERO_PLACEHOLDER = 214,
  489. QUEST_GUARD = 215,
  490. RANDOM_DWELLING = 216,
  491. RANDOM_DWELLING_LVL = 217, //subtype = creature level
  492. RANDOM_DWELLING_FACTION = 218, //subtype = faction
  493. GARRISON2 = 219,
  494. ABANDONED_MINE = 220,
  495. TRADING_POST_SNOW [[deprecated]] = 221,
  496. CLOVER_FIELD = 222,
  497. CURSED_GROUND2 = 223,
  498. EVIL_FOG = 224,
  499. FAVORABLE_WINDS = 225,
  500. FIERY_FIELDS = 226,
  501. HOLY_GROUNDS = 227,
  502. LUCID_POOLS = 228,
  503. MAGIC_CLOUDS = 229,
  504. MAGIC_PLAINS2 = 230,
  505. ROCKLANDS = 231,
  506. };
  507. };
  508. class Obj : public IdentifierWithEnum<Obj, ObjBase>
  509. {
  510. public:
  511. using IdentifierWithEnum<Obj, ObjBase>::IdentifierWithEnum;
  512. };
  513. class DLL_LINKAGE RoadId : public Identifier<RoadId>
  514. {
  515. public:
  516. using Identifier<RoadId>::Identifier;
  517. static const RoadId NO_ROAD;
  518. static const RoadId DIRT_ROAD;
  519. static const RoadId GRAVEL_ROAD;
  520. static const RoadId COBBLESTONE_ROAD;
  521. };
  522. class DLL_LINKAGE RiverId : public Identifier<RiverId>
  523. {
  524. public:
  525. using Identifier<RiverId>::Identifier;
  526. static const RiverId NO_RIVER;
  527. static const RiverId WATER_RIVER;
  528. static const RiverId ICY_RIVER;
  529. static const RiverId MUD_RIVER;
  530. static const RiverId LAVA_RIVER;
  531. };
  532. class DLL_LINKAGE EPathfindingLayerBase : public IdentifierBase
  533. {
  534. public:
  535. enum Type : int32_t
  536. {
  537. LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS, WRONG, AUTO
  538. };
  539. };
  540. class EPathfindingLayer : public IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>
  541. {
  542. public:
  543. using IdentifierWithEnum<EPathfindingLayer, EPathfindingLayerBase>::IdentifierWithEnum;
  544. };
  545. class ArtifactPositionBase : public IdentifierBase
  546. {
  547. public:
  548. enum Type
  549. {
  550. TRANSITION_POS = -3,
  551. FIRST_AVAILABLE = -2,
  552. PRE_FIRST = -1, //sometimes used as error, sometimes as first free in backpack
  553. HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, //5
  554. RIGHT_RING, LEFT_RING, FEET, //8
  555. MISC1, MISC2, MISC3, MISC4, //12
  556. MACH1, MACH2, MACH3, MACH4, //16
  557. SPELLBOOK, MISC5, //18
  558. AFTER_LAST,
  559. //cres
  560. CREATURE_SLOT = 0,
  561. COMMANDER1 = 0, COMMANDER2, COMMANDER3, COMMANDER4, COMMANDER5, COMMANDER6, COMMANDER_AFTER_LAST,
  562. BACKPACK_START = 19
  563. };
  564. static_assert (AFTER_LAST == BACKPACK_START, "incorrect number of artifact slots");
  565. DLL_LINKAGE static si32 decode(const std::string & identifier);
  566. DLL_LINKAGE static std::string encode(const si32 index);
  567. };
  568. class ArtifactPosition : public IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>
  569. {
  570. public:
  571. using IdentifierWithEnum<ArtifactPosition, ArtifactPositionBase>::IdentifierWithEnum;
  572. };
  573. class ArtifactIDBase : public IdentifierBase
  574. {
  575. public:
  576. enum Type
  577. {
  578. NONE = -1,
  579. SPELLBOOK = 0,
  580. SPELL_SCROLL = 1,
  581. GRAIL = 2,
  582. CATAPULT = 3,
  583. BALLISTA = 4,
  584. AMMO_CART = 5,
  585. FIRST_AID_TENT = 6,
  586. VIAL_OF_DRAGON_BLOOD = 127,
  587. ARMAGEDDONS_BLADE = 128,
  588. TITANS_THUNDER = 135,
  589. ART_SELECTION = 144,
  590. ART_LOCK = 145, // FIXME: We must get rid of this one since it's conflict with artifact from mods. See issue 2455
  591. };
  592. DLL_LINKAGE const CArtifact * toArtifact() const;
  593. DLL_LINKAGE const Artifact * toArtifact(const ArtifactService * service) const;
  594. };
  595. class ArtifactID : public IdentifierWithEnum<ArtifactID, ArtifactIDBase>
  596. {
  597. public:
  598. using IdentifierWithEnum<ArtifactID, ArtifactIDBase>::IdentifierWithEnum;
  599. ///json serialization helpers
  600. DLL_LINKAGE static si32 decode(const std::string & identifier);
  601. DLL_LINKAGE static std::string encode(const si32 index);
  602. static std::string entityType();
  603. };
  604. class CreatureIDBase : public IdentifierBase
  605. {
  606. public:
  607. enum Type
  608. {
  609. NONE = -1,
  610. ARCHER = 2, // for debug / fallback
  611. IMP = 42, // for Deity of Fire
  612. SKELETON = 56, // for Skeleton Transformer
  613. BONE_DRAGON = 68, // for Skeleton Transformer
  614. TROGLODYTES = 70, // for Abandoned Mine
  615. MEDUSA = 76, // for Siege UI workaround
  616. HYDRA = 110, // for Skeleton Transformer
  617. CHAOS_HYDRA = 111, // for Skeleton Transformer
  618. AIR_ELEMENTAL = 112, // for tests
  619. FIRE_ELEMENTAL = 114, // for tests
  620. PSYCHIC_ELEMENTAL = 120, // for hardcoded ability
  621. MAGIC_ELEMENTAL = 121, // for hardcoded ability
  622. CATAPULT = 145,
  623. BALLISTA = 146,
  624. FIRST_AID_TENT = 147,
  625. AMMO_CART = 148,
  626. ARROW_TOWERS = 149
  627. };
  628. DLL_LINKAGE const CCreature * toCreature() const;
  629. DLL_LINKAGE const Creature * toCreature(const CreatureService * creatures) const;
  630. };
  631. class CreatureID : public IdentifierWithEnum<CreatureID, CreatureIDBase>
  632. {
  633. public:
  634. using IdentifierWithEnum<CreatureID, CreatureIDBase>::IdentifierWithEnum;
  635. ///json serialization helpers
  636. DLL_LINKAGE static si32 decode(const std::string & identifier);
  637. DLL_LINKAGE static std::string encode(const si32 index);
  638. static std::string entityType();
  639. };
  640. class SpellIDBase : public IdentifierBase
  641. {
  642. public:
  643. enum Type
  644. {
  645. // Special ID's
  646. SPELLBOOK_PRESET = -3,
  647. PRESET = -2,
  648. NONE = -1,
  649. // Adventure map spells
  650. SUMMON_BOAT = 0,
  651. SCUTTLE_BOAT = 1,
  652. VISIONS = 2,
  653. VIEW_EARTH = 3,
  654. DISGUISE = 4,
  655. VIEW_AIR = 5,
  656. FLY = 6,
  657. WATER_WALK = 7,
  658. DIMENSION_DOOR = 8,
  659. TOWN_PORTAL = 9,
  660. // Combar spells
  661. QUICKSAND = 10,
  662. LAND_MINE = 11,
  663. FORCE_FIELD = 12,
  664. FIRE_WALL = 13,
  665. EARTHQUAKE = 14,
  666. MAGIC_ARROW = 15,
  667. ICE_BOLT = 16,
  668. LIGHTNING_BOLT = 17,
  669. IMPLOSION = 18,
  670. CHAIN_LIGHTNING = 19,
  671. FROST_RING = 20,
  672. FIREBALL = 21,
  673. INFERNO = 22,
  674. METEOR_SHOWER = 23,
  675. DEATH_RIPPLE = 24,
  676. DESTROY_UNDEAD = 25,
  677. ARMAGEDDON = 26,
  678. SHIELD = 27,
  679. AIR_SHIELD = 28,
  680. FIRE_SHIELD = 29,
  681. PROTECTION_FROM_AIR = 30,
  682. PROTECTION_FROM_FIRE = 31,
  683. PROTECTION_FROM_WATER = 32,
  684. PROTECTION_FROM_EARTH = 33,
  685. ANTI_MAGIC = 34,
  686. DISPEL = 35,
  687. MAGIC_MIRROR = 36,
  688. CURE = 37,
  689. RESURRECTION = 38,
  690. ANIMATE_DEAD = 39,
  691. SACRIFICE = 40,
  692. BLESS = 41,
  693. CURSE = 42,
  694. BLOODLUST = 43,
  695. PRECISION = 44,
  696. WEAKNESS = 45,
  697. STONE_SKIN = 46,
  698. DISRUPTING_RAY = 47,
  699. PRAYER = 48,
  700. MIRTH = 49,
  701. SORROW = 50,
  702. FORTUNE = 51,
  703. MISFORTUNE = 52,
  704. HASTE = 53,
  705. SLOW = 54,
  706. SLAYER = 55,
  707. FRENZY = 56,
  708. TITANS_LIGHTNING_BOLT = 57,
  709. COUNTERSTRIKE = 58,
  710. BERSERK = 59,
  711. HYPNOTIZE = 60,
  712. FORGETFULNESS = 61,
  713. BLIND = 62,
  714. TELEPORT = 63,
  715. REMOVE_OBSTACLE = 64,
  716. CLONE = 65,
  717. SUMMON_FIRE_ELEMENTAL = 66,
  718. SUMMON_EARTH_ELEMENTAL = 67,
  719. SUMMON_WATER_ELEMENTAL = 68,
  720. SUMMON_AIR_ELEMENTAL = 69,
  721. // Creature abilities
  722. STONE_GAZE = 70,
  723. POISON = 71,
  724. BIND = 72,
  725. DISEASE = 73,
  726. PARALYZE = 74,
  727. AGE = 75,
  728. DEATH_CLOUD = 76,
  729. THUNDERBOLT = 77,
  730. DISPEL_HELPFUL_SPELLS = 78,
  731. DEATH_STARE = 79,
  732. ACID_BREATH_DEFENSE = 80,
  733. ACID_BREATH_DAMAGE = 81,
  734. // Special ID's
  735. FIRST_NON_SPELL = 70,
  736. AFTER_LAST = 82
  737. };
  738. DLL_LINKAGE const CSpell * toSpell() const; //deprecated
  739. DLL_LINKAGE const spells::Spell * toSpell(const spells::Service * service) const;
  740. };
  741. class SpellID : public IdentifierWithEnum<SpellID, SpellIDBase>
  742. {
  743. public:
  744. using IdentifierWithEnum<SpellID, SpellIDBase>::IdentifierWithEnum;
  745. ///json serialization helpers
  746. DLL_LINKAGE static si32 decode(const std::string & identifier);
  747. DLL_LINKAGE static std::string encode(const si32 index);
  748. static std::string entityType();
  749. };
  750. class BattleFieldInfo;
  751. class BattleField : public Identifier<BattleField>
  752. {
  753. public:
  754. using Identifier<BattleField>::Identifier;
  755. DLL_LINKAGE static const BattleField NONE;
  756. DLL_LINKAGE const BattleFieldInfo * getInfo() const;
  757. };
  758. class DLL_LINKAGE BoatId : public Identifier<BoatId>
  759. {
  760. public:
  761. using Identifier<BoatId>::Identifier;
  762. static const BoatId NONE;
  763. static const BoatId NECROPOLIS;
  764. static const BoatId CASTLE;
  765. static const BoatId FORTRESS;
  766. };
  767. class TerrainIdBase : public IdentifierBase
  768. {
  769. public:
  770. enum Type : int32_t
  771. {
  772. NATIVE_TERRAIN = -4,
  773. ANY_TERRAIN = -3,
  774. NONE = -1,
  775. FIRST_REGULAR_TERRAIN = 0,
  776. DIRT = 0,
  777. SAND,
  778. GRASS,
  779. SNOW,
  780. SWAMP,
  781. ROUGH,
  782. SUBTERRANEAN,
  783. LAVA,
  784. WATER,
  785. ROCK,
  786. ORIGINAL_REGULAR_TERRAIN_COUNT = ROCK
  787. };
  788. };
  789. class TerrainId : public IdentifierWithEnum<TerrainId, TerrainIdBase>
  790. {
  791. public:
  792. using IdentifierWithEnum<TerrainId, TerrainIdBase>::IdentifierWithEnum;
  793. DLL_LINKAGE static si32 decode(const std::string & identifier);
  794. DLL_LINKAGE static std::string encode(const si32 index);
  795. static std::string entityType();
  796. };
  797. class ObstacleInfo;
  798. class Obstacle : public Identifier<Obstacle>
  799. {
  800. public:
  801. using Identifier<Obstacle>::Identifier;
  802. DLL_LINKAGE const ObstacleInfo * getInfo() const;
  803. };
  804. class DLL_LINKAGE SpellSchool : public Identifier<SpellSchool>
  805. {
  806. public:
  807. using Identifier<SpellSchool>::Identifier;
  808. static const SpellSchool ANY;
  809. static const SpellSchool AIR;
  810. static const SpellSchool FIRE;
  811. static const SpellSchool WATER;
  812. static const SpellSchool EARTH;
  813. };
  814. class GameResIDBase : public IdentifierBase
  815. {
  816. public:
  817. enum Type : int32_t
  818. {
  819. WOOD = 0,
  820. MERCURY,
  821. ORE,
  822. SULFUR,
  823. CRYSTAL,
  824. GEMS,
  825. GOLD,
  826. MITHRIL,
  827. COUNT,
  828. WOOD_AND_ORE = 127, // special case for town bonus resource
  829. INVALID = -1
  830. };
  831. };
  832. class GameResID : public IdentifierWithEnum<GameResID, GameResIDBase>
  833. {
  834. public:
  835. using IdentifierWithEnum<GameResID, GameResIDBase>::IdentifierWithEnum;
  836. };
  837. // Deprecated
  838. // TODO: remove
  839. using ESpellSchool = SpellSchool;
  840. using ETownType = FactionID;
  841. using EGameResID = GameResID;
  842. using River = RiverId;
  843. using Road = RoadId;
  844. using ETerrainId = TerrainId;
  845. VCMI_LIB_NAMESPACE_END