BagSync

BagSync

3M Downloads

New Currency Sort doesn't work for expansions with "The " in the title

Protuhj opened this issue ยท 5 comments

commented

I modified the code in currency.lua to see what was happening as follows:

	--lets get an expansion list so we can sort the top part by expansion release
	for i=0, GetNumExpansions() do
		local eTmp = _G['EXPANSION_NAME'..i]
		if eTmp then
            print("Expansion: EXPANSION_NAME" .. tostring(i) .. " is: " .. eTmp)
			expansionList[eTmp] = i
        else
            print("Unknown expansion: EXPANSION_NAME" .. i)
		end
	end

	for unitObj in Data:IterateUnits() do
		if not unitObj.isGuild and unitObj.data.currency then
			for k, v in pairs(unitObj.data.currency) do
				local header = v.header or L.Currency

				--only do the entry once per currencyID
				if not tempList[k]  then
                    print("sort index for " .. header .. " is: " .. tostring(BSYC.options.sortCurrencyByExpansion and expansionList[header] or -100))
    
    ..... snip here .....

The first print out I added shows that the _G['EXPANSION_NAME .. i] results in the full expansion name, including "The" -- e.g. "The Burning Crusade" and "The War Within".

The second print out I added shows that the header field doesn't include "The" for those same expansions, resulting in TBC and TWW to be sorted with -100 instead of their appropriate value.

(You can see these header value names in the "real" currency window.)

commented

I modified the upper loop as follows to fix it temporarily, you might have your own way to solve it:

	--lets get an expansion list so we can sort the top part by expansion release
	for i=0, GetNumExpansions() do
		local eTmp = _G['EXPANSION_NAME'..i]
		if eTmp then
			eTmp = eTmp:gsub("^The ", "")
			expansionList[eTmp] = i
		end
	end
commented

So blizzard doesn't actually have any API calls for me to sort things in the currency window. That is done by the server and then sent to the client in a structured table/array. Which the Blizzard client then does a for/loop to iterate through. Meaning the list has already been ordered by the server. The only identifiers are the numbered sequence of 1 to max in table.

Now that you understand this, you can see how incredibly difficult it is for me to sort it. Why? Because each character has a different list of currency based on what they have ever picked up or acquired. BagSync on the other hand stores EVERY currency across all the characters and displays it in one giant list.

So think of it this way.

Character A has:
Dragonflight
Legion
Dungeons
Misc

Character B has:
Shadowlands
Battle For Azeroth
Legion
Cataclysm
Dungeons
Misc

BagSync:
Has everything from both.

For character A, Dragonflight is returned as 1 in the table array but for Character B it doesn't have that and instead has Shadowlands as 1. In this instance, how is BagSync supposed to know which expansion is to go to the top? Since all that is returned is a numbered list.

This is just a simple explanation but it gets more complicated when you start to realize that not everyone character has logged in or gained stuff over the course of several expansions. That not all currencies are shared across characters.

The only two things I can think of is to do a tier match using their category labels. Which is what I've done already. The other method would be extremely inaccurate, and that would be to store the table index location of each entry and then do a comparison with other characters based on their location. Using a > scenario. Like is Character A position for Dragonflight greater than Charcater B. Oh wait Character B doesn't have Dragonflight but it's number 1 is the same as Shadowlands. Hmm... what to do here? Which one is actually the correct number 1? See the issue?

For Character A, Legion is 2, but for Character B it's 3. So forth and so on...

commented

In addition even the built in LE constants have the word "The" in the name as opposed to that which is returned from the server on the Currency/Token Window for Blizzards UI.

https://warcraft.wiki.gg/wiki/API_GetExpansionDisplayInfo

Which adds even more complexity on how to combat that.

Even grabbing any currency info by CurrencyID doesn't returned the expansionLevel for it. So no real way to tie the currency by expansion either individually.

https://wowpedia.fandom.com/wiki/API_C_CurrencyInfo.GetCurrencyInfo

commented

I decided to use a more refined comparison with the header titles using filters. It's not perfect but it's flexible enough for me to modify in the future for additional words. This also makes it compatible with other localizations that may have the same issue.

commented

Thanks for the quick response and fix!