diff --git a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp index 01dfa0a82..4310e31af 100644 --- a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp +++ b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp @@ -212,7 +212,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite( int creatureLevel = -1; int creatureUpgrade = 0; - if(BuildingID::DWELL_FIRST <= toBuild && toBuild <= BuildingID::DWELL_UP_LAST) + if(toBuild.IsDwelling()) { creatureLevel = BuildingID::getLevelFromDwelling(toBuild); creatureUpgrade = BuildingID::getUpgradedFromDwelling(toBuild); @@ -271,7 +271,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite( auto otherDwelling = [](const BuildingID & id) -> bool { - return BuildingID::DWELL_FIRST <= id && id <= BuildingID::DWELL_UP_LAST; + return id.IsDwelling(); }; if(vstd::contains_if(missingBuildings, otherDwelling)) @@ -420,7 +420,7 @@ BuildingInfo::BuildingInfo( } else { - if(BuildingID::DWELL_FIRST <= id && id <= BuildingID::DWELL_UP_LAST) + if(id.IsDwelling()) { creatureGrows = creature->getGrowth(); diff --git a/lib/constants/EntityIdentifiers.h b/lib/constants/EntityIdentifiers.h index 3bc547247..8637d9182 100644 --- a/lib/constants/EntityIdentifiers.h +++ b/lib/constants/EntityIdentifiers.h @@ -366,6 +366,11 @@ public: dwelling.advance(GameConstants::CREATURES_PER_TOWN - 1); } + bool IsDwelling() const + { + return (DWELL_FIRST <= num && num <= DWELL_UP_LAST) || (DWELL_LVL_8 <= num && num <= DWELL_LVL_8_UP) || num == DWELL_UP2_FIRST; + } + bool IsSpecialOrGrail() const { return num == SPECIAL_1 || num == SPECIAL_2 || num == SPECIAL_3 || num == SPECIAL_4 || num == GRAIL;