EntityIdentifiers.h 24 KB

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