Thread Tools Display Modes
04/01/15, 05:30 AM   #1
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Alchemist (Seeking Help) @Garkin?

Hello Everyone, Maybe Garkin? You're one of the top I've seen in the forums

I've been debugging Alchemist Addon Escape bug for like 5 days now, I've lost so much sleep.


I read Garkin said the Unicorn "List" with "self" was causing the "escape or keyboard bug"... I removed that library and used a simple chat for display.. This didn't help.

I've gone line for line in the code and commenting out each line, crafting an item in game.. and then testing the lockup... it's locking up no matter what???


As far as I can tell...
Its locking up on
local combinations = Alchemist.Algorithm.get_optimal_combinations(inventory, num_reagent_slots)

if I have num_reagent_slots return 1 instead of 2... it doesn't lock up after crafting.
Inside get_optimal_combinations it locks up if we provide "2"

Full function below (please see under this function)_
Lua Code:
  1. function Alchemist.print_combinations()
  2.     local inventory = Alchemist.Inventory.new()
  3.     inventory:populate_from_control(ALCHEMY["inventory"])
  4.  
  5.     local num_reagent_slots = Alchemist.get_num_reagent_slots()
  6.     local combinations = Alchemist.Algorithm.get_optimal_combinations(inventory, num_reagent_slots)
  7.     --
  8.     local mw = Alchemist.listview
  9.     local SI = Alchemist.SI
  10.  
  11.     mw:clear()
  12.     mw.control:SetHidden(false)
  13.  
  14.     if #combinations == 0 then
  15.         mw:add_message(SI.get(SI.NO_DISCOVERIES_AVAILABLE))
  16.     else
  17.         mw:add_message(string.format(SI.get(SI.COMBINATIONS_AVAILABLE), #combinations))
  18.         mw:add_message("")
  19.         for _, combination in pairs(combinations) do
  20.             mw:add_message(SI.get(SI.COMBINE_THE_FOLLOWING))
  21.  
  22.             table.sort(combination.reagents, function(a, b) return a.name < b.name end)
  23.             for _, reagent in pairs(combination.reagents) do
  24.                 mw:add_message("- |c00ff00" .. reagent.name)
  25.             end
  26.  
  27.             mw:add_message(SI.get(SI.TO_GET_THE_FOLLOWING_DISCOVERIES))
  28.  
  29.             table.sort(combination.discoveries, function(a, b) return a.reagent.name < b.reagent.name end)
  30.             for _, discovery in pairs(combination.discoveries) do
  31.                 mw:add_message("- |c9999ff" .. discovery.reagent.name .. ": " .. discovery.trait)
  32.             end
  33.             mw:add_message("")
  34.         end
  35.     end
  36. end



Here are the combinations
.. I've stepped through each code and it either hands the UI in game (force close) or nothing.... commenting out doesn't help.

Lua Code:
  1. local function get_optimal_combinations(inventory, max_reagents)
  2.  
  3.     -- returns a list of combinations that can be done in order, to maximize discovery of traits.
  4.     local ret = {}
  5.  
  6.     local combination
  7.     repeat
  8.         combination = get_best_combination(inventory, max_reagents)
  9.         if combination then
  10.             table.insert(ret, combination)
  11.             for _, reagent in pairs(combination.reagents) do
  12.                 inventory:decrement_reagent_qty(reagent)
  13.             end
  14.  
  15.             for _, discovery in pairs(combination.discoveries) do
  16.                 discovery.reagent:discover(discovery.trait)
  17.             end
  18.         end
  19.     until not combination
  20.  
  21.     return ret
  22. end


To be honest, I only have a few more days of testing this.. attempting fixes before I get completely burnt out on this Addon.
I'm out of herbs to test with....so its really annoying, lol


If anyone has time.. please feel free to debug this, I'm more than happy to add additional devs to the Addon.


Thanks,
AB

Last edited by awesomebilly : 04/01/15 at 10:35 AM.
  Reply With Quote
04/01/15, 05:49 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,973
I've tested it too several times and tried to fix it but no chance so far.

@Awesomebilly
You should format the code inside your posting using the LUA (small blue bubble above the chat text window) so one can better read it.If youe dit your post you need to use the "Go advanced" button to see the extra formatting functions like CODE and LUA
  Reply With Quote
04/01/15, 06:35 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
My absolut sorry. I misunderstood the type of lock up. sorry sorry sorry
But the good news is, I have the lock up even without craftng.

Edit 1000:
Ok. First lock up found. It was big, empty and unused: Alchemist.xml
But not I know what you mean. Finally. I'm still sorry.

Edit 1001:
I found something:

local config = {
addonName = "Alchemist",
anchorTargetControl = nil,
width = 450,
height = 400,
}

local alchemistControl = LL:init(config)


Alchemist = {
version = "1.6.5.0",
}

LL:Init calls WINDOW_MANAGER:CreateTopLevelWindow(self.config.addonName)

Afterwards this window is replaced with a table.

I have not issue now (After changing the name in the config), but no unknown traits also.

Last edited by votan : 04/01/15 at 11:50 AM. Reason: Found something
  Reply With Quote
04/01/15, 10:55 AM   #4
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Narrowed down better steps to reproduce

I'll be posted what I've tested so far .. after I get to work:

Steps to reproduce:

Open the Alchemy crafting table (don't need to craft anything)
Have the addon show your available traits to learn
Press escape (It currently works)
Open Inventory with I
Split any item into two stacks

Result:
Escape bug


Few things I've tested (I'll post more)
1. Its not the UI (I have it completely disabled)
2. Its for sure inside:
local combinations = Alchemist.Algorithm.get_optimal_combinations(inventory, num_reagent_slots)
--- I've debugged in the Algorithm quite a bit, but I need to dig deeper.

I believe the bug happens with Alchemist once you've crafted and the item is being removed from your inventory (Hence the stack split bug).

I'll update more when I have time,

Thanks so much guys!
  Reply With Quote
04/01/15, 12:32 PM   #5
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Confirmed.

Try to change
Code:
local function combinations(lst, n)
    local a, number, select, newlist
    newlist = {}
    number = #lst
    select = n
    a = {}
    for i = 1, select do
        a[#a + 1] = i
    end

    while (1) do
        local newrow = {}
        for i = 1, select do
            newrow[#newrow + 1] = lst[a[i]]
        end
        newlist[#newlist + 1] = newrow
        local i = select
        while (a[i] == (number - select + i)) do
            i = i - 1
        end
        if (i < 1) then break end
        a[i] = a[i] + 1
        for j = i, select do
            a[j] = a[i] + j - i
        end
    end
    return newlist
end
  Reply With Quote
04/01/15, 01:32 PM   #6
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Originally Posted by votan View Post
Confirmed.

Try to change
Code:
local function combinations(lst, n)
    local a, number, select, newlist
    newlist = {}
    number = #lst
    select = n
    a = {}
    for i = 1, select do
        a[#a + 1] = i
    end

    while (1) do
        local newrow = {}
        for i = 1, select do
            newrow[#newrow + 1] = lst[a[i]]
        end
        newlist[#newlist + 1] = newrow
        local i = select
        while (a[i] == (number - select + i)) do
            i = i - 1
        end
        if (i < 1) then break end
        a[i] = a[i] + 1
        for j = i, select do
            a[j] = a[i] + j - i
        end
    end
    return newlist
end
I'm headed home for lunch to try this. Oh my god if it works. TYVM.
I seen the global newthing = {} and changed that to local earlier, I can't believe I have a global 'i' that is so lame.

I'll report back after I update it.


TYVM again!
  Reply With Quote
04/01/15, 02:36 PM   #7
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Originally Posted by awesomebilly View Post
I'm headed home for lunch to try this. Oh my god if it works. TYVM.
I seen the global newthing = {} and changed that to local earlier, I can't believe I have a global 'i' that is so lame.

I'll report back after I update it.


TYVM again!
I updated

Lua Code:
  1. local i = select
  2.         while (a[i] == (number - select + i)) do
  3.             i = i - 1
  4.         end

but still able to reproduce, I'll keep looking later tonight... ill refactor this area.
  Reply With Quote
04/01/15, 02:43 PM   #8
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Well, I did more. Maybe that was important, too.
Alchmist.xml is unused and I removed it from manifest.
I used "AlchemistWindow" for LL config.
I made setupAdditionalUI and combinations local and I removed unused global variable newthing.

Afterwards the ESC lock you descripted was reproducable by adding/removing the local keyword.
  Reply With Quote
04/01/15, 06:36 PM   #9
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
I tried this, but I don't get it, what is the "escape bug" that your trying to find?
What does it do?
  Reply With Quote
04/01/15, 07:14 PM   #10
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Originally Posted by circonian View Post
I tried this, but I don't get it, what is the "escape bug" that your trying to find?
What does it do?
Hey circonian,

Load up Alchemist Addon
Have a low level toon (Or something that can discover new traits from alchemy)
Put a bunch of herbs and flasks into your inventory.
Open up the alchemy crafting table
Craft 1 new item (Something that will discover a new trait)
After a few seconds (Wait for the animations to complete) e.g. the tooltips/popups
Close the "New trait popup alert"
BAM... your keyboard is broken... you can press escape.. can't access the main escape options menu.. etc etc.

Another Scenario:
Load up Alchemist Addon
Have a low level toon (Or something that can discover new traits from alchemy)
Put a bunch of herbs and flasks into your inventory.
Open up the alchemy crafting table
DONT Craft anything
Close the Alchemy table
Open your inventory
split any stack
BAM
Escape bug.


This only happens once my above method is run.

I'm off work, at the park with my girl... after we're done and I put them to bed I'm going to try the fixes mentioned above.

-AB
  Reply With Quote
04/01/15, 07:58 PM   #11
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Originally Posted by votan View Post
Well, I did more. Maybe that was important, too.
Alchmist.xml is unused and I removed it from manifest.
I used "AlchemistWindow" for LL config.
I made setupAdditionalUI and combinations local and I removed unused global variable newthing.

Afterwards the ESC lock you descripted was reproducable by adding/removing the local keyword.

You're fricken awesome... THANK YOU VERY MUCH!!!

It's a combination of the globals, and the local i.

Changing to local i alone didn't fix it, but once I moved all the external classes into 1 file and took it out of the global scope it DID FIX IT.

So tonight, I'm grabbing the old build (Before the chat window implementation, with unicorn/list) and going to refactor.

After I get the build stable again... I'll re-introduce removing unicorn and having a more stable scroll menu with better UI.


Thank you everyone for the support, this was driving me nuts!!!
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Alchemist (Seeking Help) @Garkin?


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