diff --git a/changelog/snippets/fix.6404.md b/changelog/snippets/fix.6404.md new file mode 100644 index 0000000000..437e2ea35f --- /dev/null +++ b/changelog/snippets/fix.6404.md @@ -0,0 +1 @@ +- (#6404) Fix upgrading units being duplicated when transferred after death. diff --git a/lua/SimUtils.lua b/lua/SimUtils.lua index c144ac2534..558206ece8 100644 --- a/lua/SimUtils.lua +++ b/lua/SimUtils.lua @@ -371,14 +371,14 @@ function UpgradeTransferredKennels(kennels) end --- Takes the units and tries to rebuild them for each army (in order). ---- The transfer procedure is fairly expensive, so it is filtered to important units (EXPs and T3 arty). ---@param units Unit[] ---@param armies Army[] function TransferUnfinishedUnitsAfterDeath(units, armies) local unbuiltUnits = {} local unbuiltUnitCount = 0 for _, unit in EntityCategoryFilterDown(transferUnbuiltCategory, units) do - if unit:IsBeingBuilt() then + -- Check if a unit is an upgrade to prevent duplicating it along with `UpgradeUnits` + if unit:IsBeingBuilt() and not unit.IsUpgrade then unbuiltUnitCount = unbuiltUnitCount + 1 unbuiltUnits[unbuiltUnitCount] = unit end