Skip to content

Commit

Permalink
Fix error when full share transfers units to a dead player (#6432)
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 authored Sep 10, 2024
1 parent 0a94e1c commit d3145bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6432.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6432) Fix units failing to transfer after defeat if the player that is being transferred to is defeated during the transfer process.
8 changes: 4 additions & 4 deletions lua/aibrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ AIBrain = Class(FactoryManagerBrainComponent, StatManagerBrainComponent, JammerM
units = self:GetListOfUnits(categories.ALLUNITS - categories.WALL - categories.COMMAND, false)
end
if units and not table.empty(units) then
local givenUnitCount = table.getn(TransferUnitsOwnership(units, brain.index))
local givenUnits = TransferUnitsOwnership(units, brain.index)

-- only show message when we actually gift that player some units
if givenUnitCount > 0 then
if not table.empty(givenUnits) then
Sync.ArmyTransfer = { { from = selfIndex, to = brain.index, reason = "fullshare" } }
end

Expand Down Expand Up @@ -808,10 +808,10 @@ AIBrain = Class(FactoryManagerBrainComponent, StatManagerBrainComponent, JammerM
for _, brain in brains do
local units = self:GetListOfUnits(cat, false)
if units and units[1] then
local givenUnitCount = table.getn(TransferUnitsOwnership(units, brain.index))
local givenUnits = TransferUnitsOwnership(units, brain.index)

-- only show message when we actually gift that player some units
if givenUnitCount > 0 then
if not table.empty(givenUnits) then
Sync.ArmyTransfer = { {
from = army,
to = brain.index,
Expand Down

0 comments on commit d3145bc

Please sign in to comment.