changeset 29:731182d55b6c

Bug fix (iterate list by ipairs) Cleanup to RemovePerson
author John@Yosemite-PC
date Sun, 11 Mar 2012 17:47:26 -0400
parents eb3a3f69559e
children 7b01c9b2b411
files Lists.lua
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Lists.lua	Sun Mar 11 17:27:31 2012 -0400
+++ b/Lists.lua	Sun Mar 11 17:47:26 2012 -0400
@@ -425,11 +425,9 @@
     local listsTheyreOn = {}
     -- check if they're active on any loot list
     for i,v in pairs(bsk.lists) do
-        for x,y in ipairs(v) do
-            if y.id == id then
-                tinsert(listsTheyreOn,v.name)
-                break
-            end
+        if bsk:IdIsInList(id,v) then
+            tinsert(listsTheyreOn,v.name)
+            break
         end
     end
     if getn(listsTheyreOn) > 0 then
@@ -505,7 +503,7 @@
 function bsk:DoRemovePersonFromList(change)--{{{
     local list = bsk.lists[change.arg.listIndex]
 
-    for i,v in pairs(list) do
+    for i,v in ipairs(list) do
         if v.id == change.arg.id then
             table.remove(list,i)
             break
@@ -518,6 +516,7 @@
 function bsk:RemovePersonFromList(name,listName)--{{{
     local listIndex = bsk:GetListIndex(listName)
     local pid = personName2id[name]
+    -- todo: check that they're on the list in the first place
     local change = {action="RemovePersonFromList",arg={id=pid,listIndex=listIndex}}
     bsk:StartChange(change)
     if bsk:DoRemovePersonFromList(change) then
@@ -576,6 +575,7 @@
     end
     -- TODO: batch into a single op - no need to spam 25 messages in a row
 end
+
 function bsk:PopulateListRandom(listIndex)
     -- difference (raid+reserve)-list, then random shuffle that, then add
     bsk:PopulateRaidList()