From 9012560e38934191fb9d64398c94432f1f013c71 Mon Sep 17 00:00:00 2001 From: Xilmi Date: Mon, 16 Dec 2024 17:19:07 +0100 Subject: [PATCH] Fix for AI not recognizing 2nd T7-building of Factory as dwelling This lead to it being built dead-last in the build-order instead of the AI trying to go for it quite early. --- AI/Nullkiller/Analyzers/BuildAnalyzer.cpp | 6 +++--- lib/constants/EntityIdentifiers.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) 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;