Mercurial > wow > breuesk
comparison Lists.lua @ 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 |
comparison
equal
deleted
inserted
replaced
| 28:eb3a3f69559e | 29:731182d55b6c |
|---|---|
| 423 return false | 423 return false |
| 424 end | 424 end |
| 425 local listsTheyreOn = {} | 425 local listsTheyreOn = {} |
| 426 -- check if they're active on any loot list | 426 -- check if they're active on any loot list |
| 427 for i,v in pairs(bsk.lists) do | 427 for i,v in pairs(bsk.lists) do |
| 428 for x,y in ipairs(v) do | 428 if bsk:IdIsInList(id,v) then |
| 429 if y.id == id then | 429 tinsert(listsTheyreOn,v.name) |
| 430 tinsert(listsTheyreOn,v.name) | 430 break |
| 431 break | |
| 432 end | |
| 433 end | 431 end |
| 434 end | 432 end |
| 435 if getn(listsTheyreOn) > 0 then | 433 if getn(listsTheyreOn) > 0 then |
| 436 self:Print(sformat("Cannot remove person %s because they are on one or more lists (%s)",name,table.concat(listsTheyreOn,", "))) | 434 self:Print(sformat("Cannot remove person %s because they are on one or more lists (%s)",name,table.concat(listsTheyreOn,", "))) |
| 437 return false | 435 return false |
| 503 end | 501 end |
| 504 end--}}} | 502 end--}}} |
| 505 function bsk:DoRemovePersonFromList(change)--{{{ | 503 function bsk:DoRemovePersonFromList(change)--{{{ |
| 506 local list = bsk.lists[change.arg.listIndex] | 504 local list = bsk.lists[change.arg.listIndex] |
| 507 | 505 |
| 508 for i,v in pairs(list) do | 506 for i,v in ipairs(list) do |
| 509 if v.id == change.arg.id then | 507 if v.id == change.arg.id then |
| 510 table.remove(list,i) | 508 table.remove(list,i) |
| 511 break | 509 break |
| 512 end | 510 end |
| 513 end | 511 end |
| 516 return true | 514 return true |
| 517 end--}}} | 515 end--}}} |
| 518 function bsk:RemovePersonFromList(name,listName)--{{{ | 516 function bsk:RemovePersonFromList(name,listName)--{{{ |
| 519 local listIndex = bsk:GetListIndex(listName) | 517 local listIndex = bsk:GetListIndex(listName) |
| 520 local pid = personName2id[name] | 518 local pid = personName2id[name] |
| 519 -- todo: check that they're on the list in the first place | |
| 521 local change = {action="RemovePersonFromList",arg={id=pid,listIndex=listIndex}} | 520 local change = {action="RemovePersonFromList",arg={id=pid,listIndex=listIndex}} |
| 522 bsk:StartChange(change) | 521 bsk:StartChange(change) |
| 523 if bsk:DoRemovePersonFromList(change) then | 522 if bsk:DoRemovePersonFromList(change) then |
| 524 bsk:CommitChange(change) | 523 bsk:CommitChange(change) |
| 525 end | 524 end |
| 574 bsk:AddPerson(name) | 573 bsk:AddPerson(name) |
| 575 end | 574 end |
| 576 end | 575 end |
| 577 -- TODO: batch into a single op - no need to spam 25 messages in a row | 576 -- TODO: batch into a single op - no need to spam 25 messages in a row |
| 578 end | 577 end |
| 578 | |
| 579 function bsk:PopulateListRandom(listIndex) | 579 function bsk:PopulateListRandom(listIndex) |
| 580 -- difference (raid+reserve)-list, then random shuffle that, then add | 580 -- difference (raid+reserve)-list, then random shuffle that, then add |
| 581 bsk:PopulateRaidList() | 581 bsk:PopulateRaidList() |
| 582 local list = bsk.lists[listIndex] | 582 local list = bsk.lists[listIndex] |
| 583 | 583 |
