EntityIdentifiers.h 24 KB

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