Merge pull request #197 from Quintinon/master

Fix for Issue #188 - Battle list ordering
This commit is contained in:
Ben Dol 2013-01-13 19:35:44 -08:00
commit 4305b9e8f4
1 changed files with 13 additions and 8 deletions

View File

@ -97,21 +97,26 @@ function onMiniWindowClose()
end
function checkCreatures()
removeAllCreatures()
local spectators = {}
local player = g_game.getLocalPlayer()
if g_game.isOnline() then
creatures = g_map.getSpectators(player:getPosition(), false)
for i, creature in ipairs(creatures) do
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
for i, v in pairs(spectators) do
addCreature(v)
for i, creature in pairs(toRemove) do
removeCreature(creature)
end
end
end