From b33b680e99b26fd2c50b5936e739bd66befe2fcf Mon Sep 17 00:00:00 2001 From: mohamedelabbas1996 Date: Sun, 28 Jun 2026 04:14:22 -0400 Subject: [PATCH] Fix AISkirmishPlayer::processBaseBuilding buildability check (#2407) In processBaseBuilding's build-list scan, canMakeUnit() was passed the accumulated candidate template 'bldgPlan' (still null at that point in the loop) instead of the current entry's template 'curPlan'. This made the buildability gate fail for build-list entries that rely on AutomaticallyBuild=Yes (or the default value when the field is omitted), so the skirmish AI never selected those structures. Pass curPlan instead. Applies to both Generals and Zero Hour. Fixes #2407 --- .../GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 7 ++++++- .../GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index afb876af064..731c0684fca 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -215,7 +215,12 @@ void AISkirmishPlayer::processBaseBuilding() } continue; } - if (TheBuildAssistant->canMakeUnit(dozer, bldgPlan)!=CANMAKE_OK) { + // TheSuperHackers @bugfix mohamedelabbas1996 Pass the current build-list + // entry (curPlan) to canMakeUnit, not the accumulated candidate (bldgPlan, + // which is still null here). Using bldgPlan made the buildability check fail + // for entries relying on AutomaticallyBuild=Yes (or the default when the + // field is omitted), so the AI never selected them. Fixes issue #2407. + if (TheBuildAssistant->canMakeUnit(dozer, curPlan)!=CANMAKE_OK) { if (info->isBuildable()) { AsciiString bldgName = info->getTemplateName(); bldgName.concat(" - Dozer unable to build - money or technology missing."); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp index 0a1a7ea64da..e67c4990590 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp @@ -222,7 +222,12 @@ void AISkirmishPlayer::processBaseBuilding() } continue; } - if (TheBuildAssistant->canMakeUnit(dozer, bldgPlan)!=CANMAKE_OK) { + // TheSuperHackers @bugfix mohamedelabbas1996 Pass the current build-list + // entry (curPlan) to canMakeUnit, not the accumulated candidate (bldgPlan, + // which is still null here). Using bldgPlan made the buildability check fail + // for entries relying on AutomaticallyBuild=Yes (or the default when the + // field is omitted), so the AI never selected them. Fixes issue #2407. + if (TheBuildAssistant->canMakeUnit(dozer, curPlan)!=CANMAKE_OK) { if (info->isBuildable()) { AsciiString bldgName = info->getTemplateName(); bldgName.concat(" - Dozer unable to build - money or technology missing.");