GameConstants.cpp 2.8 KB

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