Skip to content

Commit

Permalink
MapSchema: delete_by_index fix. closes #57
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jun 15, 2024
1 parent d10df2c commit 8fe817b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion colyseus/serialization/schema/types/array_schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function array_schema:delete_by_index(index)

self.items[dynamic_index] = nil
end

self.indexes[index] = nil
end

Expand Down
15 changes: 9 additions & 6 deletions colyseus/serialization/schema/types/map_schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ end
function map_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

self.items[dynamic_index] = nil
end

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

Expand Down

0 comments on commit 8fe817b

Please sign in to comment.