Sfoglia il codice sorgente

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.
Xilmi 10 mesi fa
parent
commit
9012560e38

+ 3 - 3
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();
 

+ 5 - 0
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;