From 4c0c6e635e87d907e7aacc188953e309cb1ceebf Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Jan 2013 19:38:23 -0600 Subject: [PATCH] Fix Vip List sorting Fixes Vip list sorting issues for both alphabetical sorting and online/offline sorting. Fixes Issue #169 Tested in 8.61 --- modules/game_viplist/viplist.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/game_viplist/viplist.lua b/modules/game_viplist/viplist.lua index 911180f6..68fe4c4b 100644 --- a/modules/game_viplist/viplist.lua +++ b/modules/game_viplist/viplist.lua @@ -94,16 +94,17 @@ function onAddVip(id, name, state) local nameLower = name:lower() local childrenCount = vipList:getChildCount() - + for i=1,childrenCount do local child = vipList:getChildByIndex(i) - if state == VipState.Online and not child.vipState == VipState.Online then + if state == VipState.Online and child.vipState ~= VipState.Online then vipList:insertChild(i, label) return end - if (not state == VipState.Online and not child.vipState == VipState.Online) + if (state ~= VipState.Online and child.vipState ~= VipState.Online) or (state == VipState.Online and child.vipState == VipState.Online) then + local childText = child:getText():lower() local length = math.min(childText:len(), nameLower:len()) @@ -113,6 +114,8 @@ function onAddVip(id, name, state) return elseif nameLower:byte(j) > childText:byte(j) then break + elseif j == nameLower:len() then -- We are at the end of nameLower, and its shorter than childText, thus insert before + vipList:insertChild(i, label) end end end