Bagnon

Bagnon

122M Downloads

Sorting of stackable items clunky

killkrog opened this issue ยท 1 comments

commented

Running Software:

  • Addon version: 9.0.6
  • Server patch: 1.3.17.38475

Have you read the changelog?
Yarp.

Describe the bug
Video says more than a thousand words...

2021-04-30.00-09-41.mp4

Expected behaviour
Only swap first and last item stack.

commented

This solution is for TBC-Classic. I think I fixed the problem by replacing the stack count sorting method, though I haven't tested it extensively to see if it results in other problems but seems to work.

You only need to change this file (too lazy to fork and do a pull-request):

AddOns\Bagnon\common\Wildpants\api\sorting.lua

Comment out the stack count property like below so that it no longer sorts it using this method (near the top of the file):

Sort.Proprieties = {
  'set',
  'class', 'subclass', 'equip',
  'quality',
  'icon',
  'level', 'name', 'id',
  -- 'count' -- comment this out
}

Add in the stack-count-sorting code block below at the bottom of the Sort:Iterate function:
(Note: it looks almost like the block of code at the top of the same function, don't touch that one)

function Sort:Iterate()

  ...
  ...
  ...

  -- Add this new block of code
  -- Sort by count after everything else is done
  if not self:Delaying('Run') then
    for k, target in pairs(spaces) do
      local item = target.item
      if item.id and item.count then
        for j = #spaces, k+1, -1 do
          local from = spaces[j]
          local other = from.item

          if item.id == other.id and item.count < other.count then
            self:Move(from, target)
            self:Delay(0.05, 'Run')
            break
          end
        end
      end
    end
  end

  -- Existing code
  if not self:Delaying('Run') then
    self:Stop()
  end
end