2
0

GameConstants.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * GameConstants.cpp, 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. #include "StdInc.h"
  11. #include "VCMI_Lib.h"
  12. #include "CDefObjInfoHandler.h"
  13. #include "CArtHandler.h"
  14. #include "CCreatureHandler.h"
  15. #include "CSpellHandler.h"
  16. #define ID_LIKE_OPERATORS_INTERNAL(A, B, AN, BN) \
  17. bool operator==(const A & a, const B & b) \
  18. { \
  19. return AN == BN ; \
  20. } \
  21. bool operator!=(const A & a, const B & b) \
  22. { \
  23. return AN != BN ; \
  24. } \
  25. bool operator<(const A & a, const B & b) \
  26. { \
  27. return AN < BN ; \
  28. } \
  29. bool operator<=(const A & a, const B & b) \
  30. { \
  31. return AN <= BN ; \
  32. } \
  33. bool operator>(const A & a, const B & b) \
  34. { \
  35. return AN > BN ; \
  36. } \
  37. bool operator>=(const A & a, const B & b) \
  38. { \
  39. return AN >= BN ; \
  40. }
  41. #define ID_LIKE_OPERATORS(CLASS_NAME, ENUM_NAME) \
  42. ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, CLASS_NAME, a.num, b.num) \
  43. ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, ENUM_NAME, a.num, b) \
  44. ID_LIKE_OPERATORS_INTERNAL(ENUM_NAME, CLASS_NAME, a, b.num)
  45. ID_LIKE_OPERATORS(SecondarySkill, SecondarySkill::ESecondarySkill)
  46. ID_LIKE_OPERATORS(Obj, Obj::EObj)
  47. ID_LIKE_OPERATORS(ETerrainType, ETerrainType::EETerrainType)
  48. ID_LIKE_OPERATORS(ArtifactID, ArtifactID::EArtifactID)
  49. ID_LIKE_OPERATORS(ArtifactPosition, ArtifactPosition::EArtifactPosition)
  50. ID_LIKE_OPERATORS(CreatureID, CreatureID::ECreatureID)
  51. ID_LIKE_OPERATORS(SpellID, SpellID::ESpellID)
  52. ID_LIKE_OPERATORS(BuildingID, BuildingID::EBuildingID)
  53. ID_LIKE_OPERATORS(BFieldType, BFieldType::EBFieldType)
  54. bmap<int, ConstTransitivePtr<CGDefInfo> > & Obj::toDefObjInfo() const
  55. {
  56. return VLC->dobjinfo->gobjs[*this];
  57. }
  58. CArtifact * ArtifactID::toArtifact() const
  59. {
  60. return VLC->arth->artifacts[*this];
  61. }
  62. CCreature * CreatureID::toCreature() const
  63. {
  64. return VLC->creh->creatures[*this];
  65. }
  66. CSpell * SpellID::toSpell() const
  67. {
  68. return VLC->spellh->spells[*this];
  69. }