diff --git a/changelog.txt b/changelog.txt index e52935a..323749b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -17,6 +17,7 @@ Date: 23. 11. 2021 - Fixed new enemy building upgrade could replace an entity with the same entity (Thank you Dimm2101) - Fixed new enemy regional base recycling would only process half the bases - Fixed new enemy adaptation due to damage type not correctly calculating probability for adaptation + - Fixed squad cleanup would periodically skip a squad when cleaning up dead unit groups --------------------------------------------------------------------------------------------------- Version: 1.1.4 diff --git a/libs/SquadAttack.lua b/libs/SquadAttack.lua index 9f31861..19f16cf 100644 --- a/libs/SquadAttack.lua +++ b/libs/SquadAttack.lua @@ -322,15 +322,21 @@ end function squadAttack.cleanSquads(map) local squads = map.groupNumberToSquad - local iterator = map.squadIterator - - local k, squad = next(squads, iterator) + local k = map.squadIterator + local squad if not k then + k, squad = next(squads, k) + else + squad = squads[k] + end + if not k then + map.squadIterator = nil if (table_size(squads) == 0) then -- this is needed as the next command remembers the max length a table has been map.groupNumberToSquad = {} end else + map.squadIterator = next(squads, k) local group = squad.group if not group.valid then addDeathGenerator(map, squad.chunk, FIVE_DEATH_PHEROMONE_GENERATOR_AMOUNT) @@ -344,15 +350,11 @@ function squadAttack.cleanSquads(map) else universe.squadCount = universe.squadCount - 1 end - local nextK - nextK = next(squads, k) squads[k] = nil - k = nextK elseif (group.state == 4) then squadAttack.squadDispatch(map, squad) end end - map.squadIterator = k end function squadAttack.squadDispatch(map, squad)