1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-11 14:49:24 +02:00

Enemy boat bug fix

Changes:
- Fixed an issue where biters around enemy boat would sometimes not attack the player boat.
This commit is contained in:
Piratux 2023-02-26 22:22:31 +02:00
parent be95d7e3ce
commit 32b5cf74fa
3 changed files with 15 additions and 2 deletions

View File

@ -19,6 +19,7 @@ local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local Crew = require 'maps.pirates.crew'
-- local Quest = require 'maps.pirates.quest'
local SurfacesCommon = require 'maps.pirates.surfaces.common'
local Utils = require 'maps.pirates.utils_local'
local Public = {}
@ -895,7 +896,7 @@ function Public.try_boat_biters_attack()
Public.send_boat_biters_for_attack(eboat)
end
else
destination.dynamic_data.enemyboats[i] = nil
Utils.fast_remove(destination.dynamic_data.enemyboats, i)
end
end
end

View File

@ -873,7 +873,7 @@ function Public.boat_movement_tick(tickinterval)
do end
end
else
destination.dynamic_data.enemyboats[i] = nil
Utils.fast_remove(destination.dynamic_data.enemyboats, i)
end
end
end

View File

@ -216,6 +216,18 @@ function Public.ordered_table_with_index_removed(tbl, index)
return to_keep
end
-- Implementation of table.fast_remove
function Public.fast_remove(tbl, index)
local count = #tbl
if index > count then
return
elseif index < count then
tbl[index] = tbl[count]
end
tbl[count] = nil
end
function Public.length(tbl)
local count = 0
for k, _ in pairs(tbl) do