Thread Tools Display Modes
04/07/15, 05:57 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
[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

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: 577
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)
  Reply With Quote
04/08/15, 10:03 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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.

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: 577
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
  Reply With Quote
04/08/15, 11:28 PM   #5
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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()
  Reply With Quote
04/10/15, 05:44 PM   #6
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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).
  Reply With Quote
04/15/20, 02:01 AM   #7
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 312
there is a ticket # 200415-001514
  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