Quantcast [open] Search Box Bug - ESOUI
Thread Tools Display Modes
04/07/15, 05:57 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
[open] Search Box Bug

I have found 2 more bugs in the searchBox game code and added them to this post.

BUG 1
If you unequip an item by double clicking on it in the character window (or right clicking and selected unequip) everything works fine.

But when you double click an item to equip it & you already have an item equiped in that equip slot, they just swap slots and the searchData does not get updated and still has the cached searchData for the old item.

Steps to Reproduce:
  1. Log in or /reloadui to clear searchData.cache for all slots
  2. Do a search in the search box so that it will cache search data in to each slot.searchData.cache
  3. Double click on an item to equip it AND you must already have an item equipped in that slot so they swap slots !!
  4. The item that was unequipped was placed in the inventory slot of the item you equipped & it still contains the old searchData.cache.
  5. Try to search for the name of the item you EQUIPPED (yes its not in your inventory you equipped it, but) it will display the item that was UNEQUIPPED in the search results...because it has the searchData.cache for the old item.

Example:
  • I "HAD" the "Ironthread Jerkin" equipped
  • I double clicked on the "Robe of the Magic Furnace" (now it is equipped)
  • Then I /zgoo'd the row control for the "Ironthread Jerkin" that got unequipped.
  • We can see the slot data shows the "Ironthread Jerkin", but the searchData still has the cached data for the "Robe of the Magic Furnace"
  • When I search for "Robe of the Magic Furnace" the "Ironthread Jerkin" appears



Fix:
It looks like you need to clear the searchData.cache & set searchData.cached to false when the slots are updated with a different item, something like:

Lua Code:
  1. function ZO_SharedInventoryManager:CreateOrUpdateSlotData(existingSlotData, bagId, slotIndex, isNewItem)
  2.     ...
  3.     if not wasSameItemInSlotBefore then
  4.         slot.itemType = GetItemType(bagId, slotIndex)
  5.         slot.uniqueId = GetItemUniqueId(bagId, slotIndex)
  6.        
  7.         --------------------------------------
  8.         -- Add these to clear the old cache --
  9.         --------------------------------------
  10.         local searchData = slot.searchData
  11.        
  12.         if searchData.cached then
  13.             searchData.cache = nil
  14.             searchData.cached = false
  15.         end
  16.         --------------------------------------
  17.         --------------------------------------
  18.     end
  19.    
  20.     ...
  21. end


BUG 2
I'm not sure when this broke, but the search box does NOT work in the guild bank.

The virtual control that is inherited by all inventory search boxes comes from this control:
Lua Code:
  1. <EditBox name="ZO_InventorySearchBox" font="ZoFontWinT1" inherits="ZO_DefaultEdit ZO_EditDefaultText" virtual="true">
  2.    ...
  3.     <OnTextChanged>
  4.         ZO_EditDefaultText_OnTextChanged(self)
  5.         ZO_PlayerInventory_OnSearchTextChanged(self)
  6.     </OnTextChanged>
  7.     ...

which calls:
Lua Code:
  1. ZO_PlayerInventory_OnSearchTextChanged(self)

But it only updates the backpack or bank.
Lua Code:
  1. function ZO_PlayerInventory_OnSearchTextChanged(editBox)
  2.     if(editBox == ZO_PlayerInventorySearchBox) then
  3.         PlayerInventory:UpdateList(PlayerInventory.selectedTabType)
  4.     else
  5.         PlayerInventory:UpdateList(INVENTORY_BANK)
  6.     end
  7. end

Fix: It should be
Lua Code:
  1. function ZO_PlayerInventory_OnSearchTextChanged(editBox)
  2.     if(editBox == ZO_PlayerInventorySearchBox) then
  3.         PlayerInventory:UpdateList(PlayerInventory.selectedTabType)
  4.     elseif (editBox == ZO_PlayerBankSearchBox) then
  5.         PlayerInventory:UpdateList(INVENTORY_BANK)
  6.     else
  7.         PlayerInventory:UpdateList(INVENTORY_GUILD_BANK)
  8.     end
  9. end

BUG 3
In inventory.lua, when the "guildbank" scene is registered for the "StateChange" callback it Ends the search for the wrong searchBox. Which means the searchBox for the guild bank does not get cleared properly.
Lua Code:
  1. local guildBankScene = ZO_InteractScene:New("guildBank", SCENE_MANAGER, GUILD_BANKING_INTERACTION)
  2. guildBankScene:RegisterCallback("StateChange",  function(oldState, newState)
  3.     if(newState == SCENE_SHOWING) then
  4.         self:RefreshMoney(GetCurrentMoney())
  5.         self:RefreshAlliancePoints(GetAlliancePoints())
  6.         guildBankFragmentBar:SelectFragment(SI_BANK_WITHDRAW)
  7.         ZO_SharedInventory_SelectAccessibleGuildBank(self.lastSuccessfulGuildBankId)
  8.     elseif(newState == SCENE_HIDDEN) then
  9.         guildBankFragmentBar:Clear()
  10.         ZO_InventorySlot_RemoveMouseOverKeybinds()
  11.        
  12.         --============================================================--
  13.         -- This line is incorrect.
  14.         --ZO_PlayerInventory_EndSearch(ZO_PlayerBankSearchBox)
  15.         -- It should be:
  16.         ZO_PlayerInventory_EndSearch(ZO_GuildBankSearchBox)
  17.         --============================================================--
  18.     end
  19. end)

For anyone interested I have added a fix for the two new bugs I found to my SearchBox Bug Fix addon, you can find it here: SearchBox Bug Fix V3.0
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox

Last edited by circonian : 04/10/15 at 05:42 PM.
  Reply With Quote
04/08/15, 01:12 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 512
Does this fix it for you? For me it does.

Lua Code:
  1. local function OnSlotUpdated(bagId, slotIndex, slotData)
  2.   if slotData and slotData.searchData and slotData.searchData.cached and slotData.searchData.cache then
  3.     slotData.searchData.cached = slotData.rawName:lower() == slotData.searchData.cache[1]
  4.   end
  5. end
  6.  
  7. SHARED_INVENTORY:RegisterCallback("SlotUpdated", OnSlotUpdated)
__________________
@votan73 (EU - megaserver)
  Reply With Quote
04/08/15, 10:03 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
Although the equipType would be the same since both items go in the same equip slot the itemStyles might not be the same, so that really needs to be updated also. You could just nil out the cache & set cached = false, like I did in my example above, but if you want to fix the cache instead of nilling it out the itemStyle needs to be updated as well:

Lua Code:
  1. local function OnSlotUpdated(bagId, slotIndex, slotData)
  2.   if slotData and slotData.searchData and slotData.searchData.cached and slotData.searchData.cache then
  3.     local name = GetItemName(bagId, slotIndex)
  4.     name = name:lower()
  5.    
  6.     if name ~= slotData.searchData.cache[1] then
  7.         local _, _, _, _, _, equipType, itemStyle = GetItemInfo(bagId, slotIndex)
  8.        
  9.         slotData.searchData.cache = {name, equipType, itemStyle}
  10.     end
  11.   end
  12. end
  13.  
  14. SHARED_INVENTORY:RegisterCallback("SlotUpdated", OnSlotUpdated)

Nilling it out would probably be the best solution though. Whenever a search is started it checks to see if data is cached and if its not it grabs that data on its own. That way it would only have to mess with those calls to update the cache if a search is being run instead of every time they don't match in the OnSlotUpdate.
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox

Last edited by circonian : 04/08/15 at 10:06 PM.
  Reply With Quote
04/08/15, 11:20 PM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 512
Originally Posted by circonian View Post
You could just nil out the cache & set cached = false, like I did in my example above
That's what it does. By setting cached to false (not updating cache), if the names do not match, a second slotUpdated occurs with corrected data. This way, you do not re-implement something but invalidating the cache. No need to change the hashtable by nilling something.

Nethertheless, if a small code snippet like that would fix it, it maybe something for Mer Band-Aid ZO-UI Fixes
__________________
@votan73 (EU - megaserver)
  Reply With Quote
04/08/15, 11:28 PM   #5
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
Originally Posted by votan View Post
That's what it does.
Oh, my bad your right. I guess I read it wrong. For some reason I looked at this:
Lua Code:
  1. slotData.rawName:lower() == slotData.searchData.cache[1]

and thought it said:
Lua Code:
  1. slotData.searchData.cache[1] = slotData.rawName:lower()
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox
  Reply With Quote
04/10/15, 05:44 PM   #6
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
2 MORE SearchBox Bugs

I have found 2 more bugs in the inventory searchBoxes.

I have edited the original post to reflect all three bugs (scroll up to first post to read).
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox
  Reply With Quote
07/21/15, 01:24 PM   #7
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 679
I have a question regarding bug #1 fix. You set .cached to false if .rawName doesn't match. Is that condition sufficient? I mean, I noticed the search also includes item style, e.g. "breton" finds all items in Breton style. Hopefully I can find a pair of identically named items in different styles to test. Just wanted to ask how much "wrong" it would be to clear the .cached flag unconditionally.
  Reply With Quote
07/21/15, 01:30 PM   #8
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 679
One more question: I can't find the fix to #1 in FilterIt. Has it been fixed by ZOS already?
  Reply With Quote
07/21/15, 02:26 PM   #9
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
Originally Posted by merlight View Post
I have a question regarding bug #1 fix. You set .cached to false if .rawName doesn't match. Is that condition sufficient? ... Just wanted to ask how much "wrong" it would be to clear the .cached flag unconditionally.
EDIT: Nevermind, I missunderstood. I thought you were talking about the code posted in this thread. You meant in that fix I posted. I'll look at it.
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox

Last edited by circonian : 07/21/15 at 02:31 PM.
  Reply With Quote
07/21/15, 02:55 PM   #10
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
Originally Posted by merlight View Post
I have a question regarding bug #1 fix. You set .cached to false if .rawName doesn't match. Is that condition sufficient? I mean, I noticed the search also includes item style, e.g. "breton" finds all items in Breton style. Hopefully I can find a pair of identically named items in different styles to test. Just wanted to ask how much "wrong" it would be to clear the .cached flag unconditionally.
At the time I assumed two items with the same name would be the same style, but now that you mention it your probably right.

(untested) Probably the easiest way I can think of to fix that would be to copy the itemInstanceId and check it instead to see if its changed:
Lua Code:
  1. local function OnSlotUpdated(bagId, slotIndex, slotData)
  2.     if not slotData then return end
  3.     local searchData = slotData.searchData
  4.     if not (searchData and searchData.cached) then return end
  5.     if not (searchData.cache) then return end
  6.    
  7.     local newItemInstanceId = slotData.itemInstanceId
  8.     local oldItemInstaceId  = slotData.itemInstanceIdOLD
  9.    
  10.     -- if its the same item, nothing to do return.
  11.     -- if there is no item in the slot newItemInstanceId will be nil
  12.     if newItemInstanceId == oldItemInstaceId then return end
  13.    
  14.     searchData.cache = nil
  15.     searchData.cached = false
  16.    
  17.     -- if there is no item in the slot this will
  18.     -- nil out the old Id for us:
  19.     slotData.itemInstanceIdOLD = newItemInstanceId
  20. end
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox
  Reply With Quote
07/21/15, 03:01 PM   #11
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 648
Originally Posted by merlight View Post
One more question: I can't find the fix to #1 in FilterIt. Has it been fixed by ZOS already?
I guess not, I just tested it and those bugs are all still there. I don't see any of the fixes in FilterIt. I think what happened was I added a fix for the first bug, then I found the other two & I didn't want to keep adding code to fix bugs and posted that SearchBox Bug Fix instead.
__________________
My Addons: JunkIt, FilterIt, WaypointIt, LootIt, TweakIt, ChatIt, SortIt
My Libs & Other Developer Stuff: Click4Info, LibNeed4Research, LibMsgWin, LibFilterIt, LibItemInfo
Other Files & Works In Progress can be found on my Dropbox: ESO Dropbox
  Reply With Quote
04/15/20, 02:01 AM   #12
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 289
there is a ticket # 200415-001514
__________________
EU Server - SŁĄuGhTerHĜuSe
  Reply With Quote

ESOUI » Developer Discussions » Bug Reports » [open] Search Box Bug

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off