Fix for battle list sorting

All creatures were being removed and re-added, only add ones we don't
have, and then remove ones we shouldn't have.
This commit is contained in:
Jeffrey 2013-01-13 20:02:00 -06:00
parent 709fdb9e38
commit 47d5e1d5e6
1 changed files with 13 additions and 8 deletions

View File

@ -97,21 +97,26 @@ function onMiniWindowClose()
end end
function checkCreatures() function checkCreatures()
removeAllCreatures()
local spectators = {}
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if g_game.isOnline() then if g_game.isOnline() then
creatures = g_map.getSpectators(player:getPosition(), false) creatures = g_map.getSpectators(player:getPosition(), false)
for i, creature in ipairs(creatures) do for i, creature in ipairs(creatures) do
if creature ~= player and doCreatureFitFilters(creature) then if creature ~= player and doCreatureFitFilters(creature) then
table.insert(spectators, creature) if not hasCreature(creature) then
addCreature(creature)
end
end
end
local toRemove = {}
for i, b in pairs(battleButtonsByCreaturesList) do
if (not table.contains(creatures, b.creature)) or (not doCreatureFitFilters(b.creature)) then
table.insert(toRemove, b.creature)
end end
end end
end
for i, v in pairs(spectators) do for i, creature in pairs(toRemove) do
addCreature(v) removeCreature(creature)
end
end end
end end