Skip to content

Commit

Permalink
Filter out upgrade units from being rebuilt on transfer (FAForever#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 authored Aug 10, 2024
1 parent 7f5ce74 commit 819ec5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6404) Fix upgrading units being duplicated when transferred after death.
4 changes: 2 additions & 2 deletions lua/SimUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 819ec5f

Please sign in to comment.