Skip to content
Snippets Groups Projects
Commit 1a1a1593 authored by dg's avatar dg
Browse files

Picking up items will not make weird movements in the list

git-svn-id: http://svn.net-core.org/repos/t-engine4@1287 51575b47-30f0-44d4-a5cc-537603b46e54
parent 6afb50cf
No related branches found
No related tags found
No related merge requests found
......@@ -456,9 +456,11 @@ end
-- @param pos what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR)
function _M:remove(x, y, pos)
if self.map[x + y * self.w] then
self.map[x + y * self.w][pos] = nil
local e = self.map[x + y * self.w][pos]
self.map[x + y * self.w][pos]= nil
self:updateMap(x, y)
self.changed = true
return e
end
end
......@@ -881,15 +883,11 @@ function _M:removeObject(x, y, i)
if not self(x, y, i) then return false end
-- Remove it
self:remove(x, y, i)
-- Move the last one to its position, to never get a "hole"
local j = i + 1
while self(x, y, j) do j = j + 1 end
j = j - 1
-- If the removed one was not the last
if j > i then
local o = self(x, y, j)
self:remove(x, y, j)
self(x, y, i, o)
i = i + 1
while self(x, y, i) do
self(x, y, i - 1, self:remove(x, y, i))
i = i + 1
end
return true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment