Skip to content

Commit 19e87fb

Browse files
committed
Fix field factory blocking regular build options
The check in line 265 treated field build options like a map, but it was actually an array. There are ~120 units there so anything with a unitDefID below 120 was not buildable by Support Comms. The only way this worked is that the engine happens to assign defs IDs alphabetically, and all vanilla buildings happen to have names above 120 (mostly thanks to the many dynamic commander def clones).
1 parent 021d4a9 commit 19e87fb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

LuaRules/Gadgets/unit_field_factory.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ do
103103
for j = 1, #buildList do
104104
local buildDefID = buildList[j]
105105
if not alreadyAdded[buildDefID] then
106-
fieldBuildOpts[#fieldBuildOpts + 1] = buildDefID
106+
fieldBuildOpts[buildDefID] = true
107107
alreadyAdded[buildDefID] = true
108108
end
109109
end
@@ -271,8 +271,8 @@ function gadget:UnitCreated(unitID, unitDefID)
271271
end
272272
isFieldFac[unitID] = true
273273
local previousUnit = Spring.GetUnitRulesParam(unitID, "fieldFactoryUnit")
274-
for i = 1, #fieldBuildOpts do
275-
RemoveUnit(unitID, fieldBuildOpts[i])
274+
for unitDefID in pairs(fieldBuildOpts) do
275+
RemoveUnit(unitID, unitDefID)
276276
end
277277
if previousUnit then
278278
AddUnit(unitID, previousUnit)

0 commit comments

Comments
 (0)