From b04711206926f2f56ea8098e2f559ec3a811da71 Mon Sep 17 00:00:00 2001 From: Junior Date: Sun, 6 Sep 2026 01:12:39 +0200 Subject: [PATCH] Fix placeBuildingAt future-worker lookup to use the finished type num placeBuildingAt computed the finished-building default-assign row as getDefaultAssignedUnits(typeNum+1). The +1 relies on the buildingsTypes table being laid out as consecutive [site, finished] pairs, which holds by accident for normal buildings but breaks for flags: flags have no site variant, so the placeable typeNum is already the finished entry and +1 walks into the next building's row (e.g. an exploration flag reads the war flag's default assign). Look the finished type up by name instead, matching the other call sites in this file. No-op for normal buildings; corrects the flag case. Ported from PR #129 (feat/ai-trainer-support), original commit 5993b37a287b06cb6e556fd7e0416902971da411 by kylelutze, adapted to master's BuildingsTypes API (getTypeNum(name, level, isBuildingSite) instead of the branch's getFinishedTypeNum(name) helper, which doesn't exist yet on master). --- src/GameGUIToolManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GameGUIToolManager.cpp b/src/GameGUIToolManager.cpp index 6cea268ba..2653b59da 100644 --- a/src/GameGUIToolManager.cpp +++ b/src/GameGUIToolManager.cpp @@ -376,7 +376,7 @@ void GameGUIToolManager::placeBuildingAt(int mapX, int mapY, int localteam) isRoom = false; int unitWorking = defaultAssign.getDefaultAssignedUnits(typeNum); - int unitWorkingFuture = defaultAssign.getDefaultAssignedUnits(typeNum+1); + int unitWorkingFuture = defaultAssign.getDefaultAssignedUnits(globalContainer->buildingsTypes.getTypeNum(building, 0, false)); if (isRoom) {