Skip to content

Commit

Permalink
ArraySchema - delete_by_index: prevent error when 'dynamic_index' is …
Browse files Browse the repository at this point in the history
…nil.
  • Loading branch information
endel committed May 23, 2024
1 parent d4454e0 commit d10df2c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions colyseus/serialization/schema/types/array_schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,19 @@ end
function array_schema:delete_by_index(index)
local dynamic_index = self.indexes[index]

-- delete key
for i, k in pairs(self.dynamic_indexes) do
if k == dynamic_index then
table.remove(self.dynamic_indexes, i)
break
if dynamic_index ~= nil then
-- delete key
for i, k in pairs(self.dynamic_indexes) do
if k == dynamic_index then
table.remove(self.dynamic_indexes, i)
break
end
end
end

self.items[dynamic_index] = nil
self.indexes[dynamic_index] = nil
self.items[dynamic_index] = nil
end

self.indexes[index] = nil
end

function array_schema:clear(changes, refs)
Expand Down

0 comments on commit d10df2c

Please sign in to comment.