Thread Tools Display Modes
Prev Previous Post   Next Post Next
08/30/15, 08:36 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
PTS: Stack All Items Bug

The new "Stack All Items" is calling
Lua Code:
  1. PLAYER_INVENTORY:UpdateList(...)
way to often. It needs to loop through the inventory, stack all of the items, & only call UpdateList(...) once. At the very least StackBag(...) looks like it needs a check to see if a slot is already at max stack size before attempting to stack it with another stack of the same type of item. As it is now its attempting to stack slots, even if they are at max stack size, with every other stack of the same type of item and calling UpdateList(...) each time.

If you have, for example (it could be any stackable item in any slot, this is just an example)
slotIndex, item, stackSize
1, Sanded Nightwood, 200
2, Sanded Nightwood, 200
3, Sanded Nightwood, 200
4, Sanded Nightwood, 200
5, Sanded Nightwood, 45
and you hit the "Stack All Item" keybind PLAYER_INVENTORY:UpdateList(...) will get called 20 times. Even if that's all you have in that inventory.

Each slot/stack attempts to stack with every other slot/stack (of the same type of item), even if they are at max stack size, causing
Lua Code:
  1. #NumOfStacks * (#NumOfStacks-1)
calls to:
Lua Code:
  1. PLAYER_INVENTORY:UpdateList(...)

Reproduction Steps:
1) Empty the inventory to be tested on (this is just so we can see the exact update count caused by the stacks we add and don't have to worry about other stacks throwing off the count).
2) Place 2 stacks of the same type of item into the inventory. Must have over 200 (max stack size) items of the same type so you still have 2 slot/stacks after it stacks the items. Both stacks can be max stack size it does not matter.
3) Use the following code and watch how many times the UpdateList gets called. It will get called 2 times.

Lua Code:
  1. local iCount = 0
  2. local function OnUpdateList(self, iInventoryType)
  3.     iCount = iCount + 1
  4.     d("OnUpdateList Count: "..iCount..", "..iInventoryType)end
  5. ZO_PreHook(PLAYER_INVENTORY, "UpdateList", OnUpdateList)

4) Now add a 3rd stack (must have a total of over 400 of the same type of item, 2 slots at max stack size) and run the "Stack All Items" again. This time it will call UpdateList(...) 6 times.
5) With 4 stacks (over 600 of the same type of item) it will call UpdateList(...) 12 times
6) With 5 stacks (over 800 of the same type of item) it will call UpdateList(...) 20 times
Exc...exc....


A user was having a problem with my addon crashing & after great help from the users I managed to figure this out. He had a LOT of stacked items & lots of them were full stacks. UpdateList(...) was getting called nearly 200 times in a single use of "Stack All Items" which in turn was causing way to much of my code to run and it was crashing the game. I think I need to optimize something, but StackBag(...) needs some work too.

Last edited by circonian : 08/30/15 at 08:39 PM.
  Reply With Quote
 

ESOUI » Developer Discussions » General Authoring Discussion » PTS: Stack All Items Bug


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