mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
GameConstants: move operators into header and always inline them
This commit is contained in:
@@ -25,58 +25,6 @@ const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255);
|
||||
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
||||
const TeamID TeamID::NO_TEAM = TeamID(255);
|
||||
|
||||
#define ID_LIKE_OPERATORS_INTERNAL(A, B, AN, BN) \
|
||||
bool operator==(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN == BN ; \
|
||||
} \
|
||||
bool operator!=(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN != BN ; \
|
||||
} \
|
||||
bool operator<(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN < BN ; \
|
||||
} \
|
||||
bool operator<=(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN <= BN ; \
|
||||
} \
|
||||
bool operator>(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN > BN ; \
|
||||
} \
|
||||
bool operator>=(const A & a, const B & b) \
|
||||
{ \
|
||||
return AN >= BN ; \
|
||||
}
|
||||
|
||||
#define ID_LIKE_OPERATORS(CLASS_NAME, ENUM_NAME) \
|
||||
ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, CLASS_NAME, a.num, b.num) \
|
||||
ID_LIKE_OPERATORS_INTERNAL(CLASS_NAME, ENUM_NAME, a.num, b) \
|
||||
ID_LIKE_OPERATORS_INTERNAL(ENUM_NAME, CLASS_NAME, a, b.num)
|
||||
|
||||
|
||||
ID_LIKE_OPERATORS(SecondarySkill, SecondarySkill::ESecondarySkill)
|
||||
|
||||
ID_LIKE_OPERATORS(Obj, Obj::EObj)
|
||||
|
||||
ID_LIKE_OPERATORS(ETerrainType, ETerrainType::EETerrainType)
|
||||
|
||||
ID_LIKE_OPERATORS(EPathfindingLayer, EPathfindingLayer::EEPathfindingLayer)
|
||||
|
||||
ID_LIKE_OPERATORS(ArtifactID, ArtifactID::EArtifactID)
|
||||
|
||||
ID_LIKE_OPERATORS(ArtifactPosition, ArtifactPosition::EArtifactPosition)
|
||||
|
||||
ID_LIKE_OPERATORS(CreatureID, CreatureID::ECreatureID)
|
||||
|
||||
ID_LIKE_OPERATORS(SpellID, SpellID::ESpellID)
|
||||
|
||||
ID_LIKE_OPERATORS(BuildingID, BuildingID::EBuildingID)
|
||||
|
||||
ID_LIKE_OPERATORS(BFieldType, BFieldType::EBFieldType)
|
||||
|
||||
CArtifact * ArtifactID::toArtifact() const
|
||||
{
|
||||
return VLC->arth->artifacts[*this];
|
||||
|
||||
Reference in New Issue
Block a user