BagSync

BagSync

3M Downloads

Guild Gold disappears on exit client

jsutan opened this issue · 19 comments

commented

Guild gold keeps disappearing every time I exit the client, not sure why only on exit and not logout or /console reloadui but there are repro steps below.

Initial login:

image

After opening the Guild Bank:

image

After exiting WoW and logging back in:

image

Recreation steps:

  • Login to a character that has a Guild Bank and gold in the guild bank
  • /bgs gold on login to verify there is no guild gold listed
  • Open Guild Bank to rescan guild bank, including gold
  • /bgs gold to verify there is now guild gold listed
  • Exit game (Log out and switching characters does not reproduce the effect)
  • Relaunch game
  • Login to same character that has a Guild Bank with gold in the guild bank
  • /bgs gold and verify there is no gold listed.
commented

It's almost like your guild is being written and deleted each time you login. So it keeps overwriting your guild stuff. Lets try something first.

Ignore the gold money entirely. Lets determine if it's JUST the gold money and nothing else.

After scanning the guild bank. Logout and login again. WITHOUT visiting the guild bank again, can you view any items in the guild bank within BagSync? Does the item counts from the guild bank show up in the Tooltips? Basically I want to make sure that the guild bank data is still there and that the only thing being affected is the money.

If nothing in your guild bank shows after logging in, then somehow your guild data is being wiped out and rewritten every time.

commented

It's definitely just the gold. Items and item counts show up in both tooltips and /bgs search. I use those regularly. I did your repro steps as requested.

  • Logged in, identified an item that is both in my bags and my bank.
  • Verified tooltip shows both bag and bank count:
    image
  • Rescanned guild bank
image
  • Verified count stayed the same

  • Verified tooltip is the same in both bags and bank

  • Verified the bank count is accurate
    image

  • Verified /bgs search works correctly

image
  • Exited client
  • Logged back in
  • Re-verified previous verifications: bank count is correctly displayed in tooltip, /bgs search works, etc.
  • Also looked at various other item tooltips for items that are in my bags as well as bank and those display and are accurate.

Also, for sanity's sake this test was done with only the following addons loaded:

  • BagBrother
  • Bagnon
  • Bagnon Config
  • BagSync

I can test with only BagSync enabled if you think it is related.

It is definitely being wiped in the .lua, here is the relevant line in the .lua file from C:\Program Files (x86)\World of Warcraft\_retail\WTF\Account\%AccountName%\SavedVariables\BagSync.lua (tabs array collapsed for display purposes)

image

commented

Additional testing:

  • I diffed core.lua and modules\gold.lua on my PC versus what is in the repo and they are the same.
  • I also completely reinstalled from the CurseForge client

Note: There was a time (MANY years ago) I was manually updating the code each update to blacklist my "real" guild. This was before you implemented Guild blacklist support and I haven't done that since. But in the interest of making sure my code is not changed I completely reinstalled.

commented

Some more testing:

  • It's not being overwritten on exit, it's not being initialized on login properly. The correct value exists in BagSync.lua after logout but it's being set to 0 when the addon loads, which results in it being set to 0 on next logout. Repro steps:

  • Login (no guild gold)

  • /bgs gold (no guild gold listed)

  • Open Guild Bank, recache

  • /bgs gold (guild gold listed)

  • Exit client

  • BagSync.lua is written with correct guild gold value

  • Login

  • /bgs gold (no gold)

  • obj.data.money = 0 for guild gold

  • BagSync.lua still has correct guild gold listed from previous login and won't be rewritten until exit client, but will be rewritten as 0 since that what it was loaded in the session as.

Something weird is happening when the BagSyncDB is being loaded but I don't really know where that happens in the addon.

I threw in a Debug(BSYC_DL.INFO, "in not skipReturn", argKey, k, v.money, isGuild, isConnectedRealm, isXRGuild) line in Data:Iterate function() just to see what it was doing and v.money (BagSyncDB.data.money) is 0 but only for the guild, but it is correct in the lua so it isn't loading that table correctly.

image

I don't know if I'll be able to do any more debugging on my own. I am only familiar with programming and some basic functions of Lua. Hopefully this helps you. If you need anything else, feel free to reach out.

commented

Hey this is fantastic investigative work! I haven't had a chance to sit down and review everything just yet. Been doing a lot of house repairs lol. I should be able to sit down sometime tomorrow to review everything. I will definitely get to the bottom of this if it's the last thing I do lol ;)

commented

Before I forget it is possible that the server is returning 0 value on login for GetGuildBankMoney() function. If that's the case then it would trigger BagSync to store GetGuildBankMoney() at zero.

The only other possibility which makes NO SENSE at all. Is that somehow your guild is be rewritten each time you login. But that's not entirely possible as you still have item data. So it could be something else.

If you want to test if the Guild Functions are broken. You can go to the guild bank, view it, make sure that gold is tracked and logged in the gold window. Then go to BagSync config and under tracking turn off Guild. Exit the game then login again. Guild functions shouldn't be working, BUT the value in the LUA should be still correct and not zero, because we turned off the guild functions. If it's still accurate. Then go ahead and turn on tracking for guilds again and check the guild bank. Confirm the gold and then exit. Login again and see if it resets. If it does then it's definitely something to do with the server guild functions by Blizzard.

commented

The guildDB.money = GetGuildBankMoney() line in SaveGuildBank() function in scanner.lua is working correctly (added debug lines there). Both guildDB.money value and the value of GetGuildBankMoney() are correct.

image

I still feel like it's something to do with the Data:Iterate function. On login, I DevTools_Dump()'d the table and I can see the money value there correctly on login, but when Data:Iterate() iterates over the keys and tables, for some reason v.money is 0 for guild only.

image

Some more ad-hoc data logging:

[09:14:49]: [Data]: IterateUnits, nil, nil
[09:14:49]: [Data]: argKey, argValue, options§, table: 000001C21D1DE830
[09:14:49]: [Data]: argKey while, options§
[09:14:49]: [Data]: argKey while, blacklist§
[09:14:49]: [Data]: argKey while, whitelist§
[09:14:49]: [Data]: argKey while, forceDBReset§
[09:14:49]: [Data]: argKey while, savedsearch§
[09:14:49]: [Data]: argKey while, _realmName_
[09:14:49]: [Data]: elseif argKey
[09:14:49]: [Data]: isConnectedRealm, true
[09:14:49]: [Data]: vars, false, true, _guildName_©, true, false, _realmName_, true
[09:14:49]: [Data]: k,v, _guildName_©, table: 000001C21D1DEE70
[09:14:49]: [Data]: v.money inside, 0
[09:14:49]: [Data]: skipReturn, false
[09:14:49]: [Data]: v.faction, Alliance
[09:14:49]: [Data]: v.money, 0
[09:14:49]: [Data]: argKey while, _realmName_
[09:14:49]: [Data]: elseif argKey
[09:14:49]: [Data]: isConnectedRealm, true
[09:14:49]: [Data]: vars, false, true, _guildName_©, true, false, _realmName_, true
[09:14:49]: [Data]: k,v, _playerName_, table: 000001C21D1DF0F0
[09:14:49]: [Data]: v.money inside, 26336220281
[09:14:49]: [Data]: skipReturn, false
[09:14:49]: [Data]: v.faction, Alliance
[09:14:49]: [Data]: v.money, 26336220281
[09:14:49]: [Data]: argKey while, _realmName_
[09:14:49]: [Data]: elseif argKey
[09:14:49]: [Data]: isConnectedRealm, true
[09:14:49]: [Data]: vars, false, true, _guildName_©, true, false, _realmName_, true

No rush on resolution, just trying to help. Whenever you can get to it is fine, appreciate the work!

commented

Okay so I need to rule out a few things.

  • It's not being overwritten on exit, it's not being initialized on login properly. The correct value exists in BagSync.lua after logout but it's being set to 0 when the addon loads, which results in it being set to 0 on next logout. Repro steps:

If it's not being overwritten on exit, then it's clearly something on the initial login scan that is overwriting it. Which means somewhere the value is being returned as zero.

I threw in a Debug(BSYC_DL.INFO, "in not skipReturn", argKey, k, v.money, isGuild, isConnectedRealm, isXRGuild) line in Data:Iterate function() just to see what it was doing and v.money (BagSyncDB.data.money) is 0 but only for the guild, but it is correct in the lua so it isn't loading that table correctly.

If the data is being written as zero, then the value will return as zero when parsed through the IterateUnits function.

The guildDB.money = GetGuildBankMoney() line in SaveGuildBank() function in scanner.lua is working correctly (added debug lines there). Both guildDB.money value and the value of GetGuildBankMoney() are correct.

Hmmm then it could be a server return value. We may have to rule that out! :)

Data:Iterate function

You keep calling it that, but I think you are referring to the Data:IterateUnits() function. 😄. Since it's used in a lot of places, you need to specify in which module you are referring to. The core Data:IterateUnits() or the call to it found in Gold Module. Either way you have done a remarkable job and have provided probably the best breakdown for debugging I've seen in awhile by anyone filing a ticket. You are a good investigator and I give you mad props for adding your own debug lines!

So on a side note. The Data:IterateUnits() function does not write data, it only reads it. In fact there are only 3 or 4 places that the money value is actually written. The Scanner module is usually where all the data writes occur. All other modules just read what is written in the DB. So we have to basically narrow it down to where the money value is actually written. The other possibility is a logic error. Meaning the "if nothing found, then zero" situations. So if it can't read the value it will automatically assign a zero as a return value. Which COULD possibly be written by accident in the money storing locations.

Lets try a few things first :)

  • Type /bgs debug
  • Make sure Enable Debug is checked.
  • Enable ONLY "DEBUG" and "INFO"

The value in the Debug log we are looking for is "SaveGuildBankMoney"

  • Open your guild bank and see if it writes it in the Debug with correct value.
  • Open your Gold Window and verify it's the correct value.
  • Exit the game
  • Login and check the Debug log immediately.
  • See if SaveGuildBankMoney is being written as zero on login check if it even fires at all. (it may not)
  • Open the Gold Window.

Basically I want to rule out the SaveGuildBankMoney function. Verify if it's zero or what not.

If it's zero then lets try something.

  • Open Scanner.lua and find the function "Scanner:SaveGuildBankMoney()"
  • comment out using "--" or remove the line guildDB.money = GetGuildBankMoney()
  • save it and now go to your guild bank, open it. Save and exit and relogin.

We need to figure out where it's being overwritten. There is only a few places this happens.

commented

Alrighty! Lets see if I can track down this bug today! :) Going to review everything here and see if I can reproduce or at least figure out the cause.

commented

hehehe :) you see I told you it was a writing/reading situation with the server. Data:IterateUnits() only reads database entries and then allows it to be called via a table array. It doesn't overwrite anything or write back to the DB. It had to be somewhere where the DB was bring written. I had a feeling it was GetGuildBankMoney(). Since that's the only locations where the money variable was being written.

Now that question we should be asking ourselves, is how to fix this bug caused by Blizzard. LOL XD Hmmm.... would have to see when exactly GetGuildBankMoney() returns a value. To check for that variable first before calling that function. Basically I need some sort of check that tells me data for GetGuildBankMoney() is available before calling it. The question is... what. LOL

I mean I can sort of delay the scan for a few seconds before login, but I doubt that will make it work. I also can't really check for if GetGuildBankMoney() is zero then ignore. Because, well... what if you REALLY do have 0 money in the guild bank. That would defeat the logic check.

Tricky tricky...... Especially when doing repairs outside the guild bank that uses the guild money. I need to see what events fire so I can make an appropriate check to adjust for the value. In these situations obviously the Guild frame won't be open, so it would return zero for GetGuildBankMoney().

Very tricky indeed.... UPDATE_INVENTORY_DURABILITY is possible but even then the guild bank window won't be open.

commented

I may save myself the headache and only save the guild money when doing stuff with the guild bank open. Solving for guild repairs is just annoying. I suppose I can also check for any merchant window.

Lets try something. Go to a merchant window that can repair. Then type the following in chat.

/print GetGuildBankMoney()

See if you get an output while visiting a Merchant window. I'm hoping Blizzard was smart enough to return a value when you at least have the merchant window up.

commented

Let me post my comments and replies before I try your steps.

I think we need to move away from thinking it's a writing/saving issue. It is being written as 0 but that is because it's being returned as 0 in Data:IterateUnits(), so when you exit it is written as 0 because it initialized as 0. Let me try to explain.

Assume you are starting from no data at all, i.e., just installed the addon.

  • Launch client/login = 0, because the addon has never loaded or written anything
  • Open Guild Bank = value returned from GetGuildBankMoney() function. This is correct
  • Exit client, the correct value will be written
  • Launch client, the correct value is seen if you DevTools_Dump(BagSyncDB), so the value is correct in BagSyncDB and BagSync.lua
  • When you type /bgs gold, 0 is returned for the guild money key/value pair
  • If you exit, the 0 is written because I think it initialized as 0 somewhere?

If it's not being overwritten on exit, then it's clearly something on the initial login scan that is overwriting it. Which means somewhere the value is being returned as zero.

I believe this is what I suspect is happening. In the Data:IterateUnits() function, when the key/value pair gets to the guild key (using the next() function), v.money is 0 but only for guild entry, not player entries.

If the data is being written as zero, then the value will return as zero when parsed through the IterateUnits function.

I would expect that but as noted above I think we need to move away from thinking it's being written as 0. It will write as 0 if it initializes/loads as 0 so that is expected behavior. The unexpected behavior is it loading as 0 after you login with a valid and valued money entry for a guild.

Hmmm then it could be a server return value. We may have to rule that out! :)

I am not sure this is possible since the places I've checked server return values, they have been accurate. I don't think Data:IterateUnits() uses any server return values and is just iterating over key/value pairs in BagSyncDB.

You keep calling it that, but I think you are referring to the Data:IterateUnits() function. 😄. Since it's used in a lot of places, you need to specify in which module you are referring to. The core Data:IterateUnits() or the call to it found in Gold Module. Either way you have done a remarkable job and have provided probably the best breakdown for debugging I've seen in awhile by anyone filing a ticket. You are a good investigator and I give you mad props for adding your own debug lines!

Yes, apologies on mislabeling the function name. You are correct, it is Data:IterateUnits(). I am not sure the full function call trace but I believe when you type /bgs gold, it will execute Gold:CreateList, which executes Data:IterateUnits() to iterate over the key/value pairs in BagSyncDB. I believe this is where the issue is, as iterating over the key/value pairs, when you get to a guild it is returning 0 for v.money (line 668 "k, v = next(argValue, k)" in wireframe/data.lua).

Thanks for the kind words. My background is programming and support but I primarily work in SQL. Most of the foundational concepts of programming are the same so while I can debug and read the code fine, I'm not intimately familiar with Lua as a language.

I will do you test scenarios now and post back when complete. If you need to do a live session with screenshare or would prefer a quicker method of communication while you're able to look at it, I can message you my contact information. I'm not sure if you have a WoW subscription or not, I know a lot of addon developers don't always have active subs.

commented

Lets try a few things first :)

Type /bgs debug
Make sure Enable Debug is checked.
Enable ONLY "DEBUG" and "INFO"
The value in the Debug log we are looking for is "SaveGuildBankMoney"

Open your guild bank and see if it writes it in the Debug with correct value.

It writes with the correct value

image

Open your Gold Window and verify it's the correct value.

Gold window displays the correct value:

image

Exit the game
Login and check the Debug log immediately.
See if SaveGuildBankMoney is being written as zero on login check if it even fires at all. (it may not)

It is not and it does not fire, here is the full debug log ON LOAD (identifiable information changed to %% descriptive values). Also note that my debugging in Data:IterateUnits() is still there

[09:33:36]: [Data]: OnEnable
[09:33:36]: [Data]: UnitInfo-1, %%thisIsMyCharacterName%%, %%thisIsMyRealmName%%
[09:33:36]: [Data]: UnitInfo-2, WARLOCK, Human, 3, Alliance
[09:33:36]: [Data]: UnitInfo-3, nil, nil
[09:33:36]: [Data]: RealmKey, %%thisIsMyConnectedRealmName%%
[09:33:36]: [Data]: RealmKey_RWS, %%thisIsMyConnectedRealmName%%
[09:33:36]: [Data]: RealmKey_LC, %%thisIsMyConnectedRealmName%%
[09:33:36]: [Data]: LoadSlashCommand
[09:33:36]: [Events]: OnEnable
[09:33:36]: [Scanner]: StartupScans, nil
[09:33:36]: [Scanner]: SaveEquipment, true
[09:33:36]: [Scanner]: SaveBag, bag, 0, true
[09:33:36]: [Scanner]: SaveBag, bag, 1, true
[09:33:36]: [Scanner]: SaveBag, bag, 2, true
[09:33:36]: [Scanner]: SaveBag, bag, 3, true
[09:33:36]: [Scanner]: SaveBag, bag, 4, true
[09:33:36]: [CORE]: CreateFakeID, [Amaranthine Stinger], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:36]: [CORE]: CreateFakeID, [Bound Lightspawn], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:36]: [CORE]: CreateFakeID, [Irongrasp], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:36]: [Scanner]: SaveBag, bag, 5, true
[09:33:36]: [Scanner]: SaveCurrency, true
[09:33:36]: [Data]: CheckExpiredAuctions, true
[09:33:36]: [Data]: IterateUnits, true, nil
[09:33:36]: [Data]: argKey, argValue, options§, table: 0000027B9DA4F5A0
[09:33:36]: [Data]: argKey while, options§
[09:33:36]: [Data]: argKey while, blacklist§
[09:33:36]: [Data]: argKey while, whitelist§
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyOtherCharacterName2%%, table: 0000027B9DA4FC30
[09:33:36]: [Data]: v.money inside, 15292462735
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyOtherCharacterName1%%, table: 0000027B9DA51260
[09:33:36]: [Data]: v.money inside, 34675676181
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyGuildName%%©, table: 0000027B9DA6D3B0
[09:33:36]: [Data]: v.money inside, 99999999999
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyOtherCharactersGuildName%%©, table: 0000027B9DA6D630
[09:33:36]: [Data]: v.money inside, 10314300611
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyCharacterName%%, table: 0000027B9DA6D680
[09:33:36]: [Data]: v.money inside, 26336220281
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: argKey while, savedsearch§
[09:33:36]: [Data]: argKey while, forceDBReset§
[09:33:36]: [Scanner]: CleanupProfessions, true
[09:33:36]: [Data]: IterateUnits, true, nil
[09:33:36]: [Data]: argKey, argValue, options§, table: 0000027B9DA4F5A0
[09:33:36]: [Data]: argKey while, options§
[09:33:36]: [Data]: argKey while, blacklist§
[09:33:36]: [Data]: argKey while, whitelist§
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyOtherCharacterName2%%, table: 0000027B9DA4FC30
[09:33:36]: [Data]: v.money inside, 15292462735
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyOtherCharacterName1%%, table: 0000027B9DA51260
[09:33:36]: [Data]: v.money inside, 34675676181
[09:33:36]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:36]: [Data]: elseif argKey
[09:33:36]: [Data]: isConnectedRealm, true
[09:33:36]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:36]: [Data]: k,v, %%thisIsMyGuildName%%©, table: 0000027B9DA6D3B0
[09:33:36]: [Data]: v.money inside, 99999999999
[09:33:37]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:37]: [Data]: elseif argKey
[09:33:37]: [Data]: isConnectedRealm, true
[09:33:37]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:37]: [Data]: k,v, %%thisIsMyOtherCharactersGuildName%%©, table: 0000027B9DA6D630
[09:33:37]: [Data]: v.money inside, 10314300611
[09:33:37]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:37]: [Data]: elseif argKey
[09:33:37]: [Data]: isConnectedRealm, true
[09:33:37]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:37]: [Data]: k,v, %%thisIsMyCharacterName%%, table: 0000027B9DA6D680
[09:33:37]: [Data]: v.money inside, 26336220281
[09:33:37]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:33:37]: [Data]: elseif argKey
[09:33:37]: [Data]: isConnectedRealm, true
[09:33:37]: [Data]: vars, false, true, nil, true, false, nil, true
[09:33:37]: [Data]: argKey while, savedsearch§
[09:33:37]: [Data]: argKey while, forceDBReset§
[09:33:37]: [Tooltip]: OnEnable
[09:33:37]: [Tooltip]: HookTooltip, table: 0000027AD5DA6BE0
[09:33:37]: [Tooltip]: HookTooltip, table: 0000027B995DB550
[09:33:37]: [Tooltip]: HookTooltip, table: 0000027AD5DAA6A0
[09:33:37]: [Tooltip]: HookTooltip, table: 0000027B977825E0
[09:33:37]: [Tooltip]: HookTooltip, table: 0000027B9777D4A0
[09:33:37]: [Data]: CheckGuildDB, %%thisIsMyCharacterName%%, %%thisIsMyRealmName%%, %%thisIsMyGuildName%%©, %%thisIsMyRealmName%%, %%thisIsMyConnectedRealmName%%
[09:33:37]: [Scanner]: SaveGuildBankMoney, 0
[09:33:38]: [Events]: SpamBagQueue, 0
[09:33:38]: [Events]: SpamBagQueue, totalProcessed, 0
[09:33:39]: [Events]: SpamBagQueue, 404
[09:33:39]: [Scanner]: SaveBag, bag, 1, true
[09:33:39]: [Scanner]: SaveBag, bag, 2, true
[09:33:39]: [Scanner]: SaveBag, bag, 3, true
[09:33:39]: [Scanner]: SaveBag, bag, 4, true
[09:33:39]: [CORE]: CreateFakeID, [Amaranthine Stinger], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:39]: [CORE]: CreateFakeID, [Bound Lightspawn], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:39]: [CORE]: CreateFakeID, [Irongrasp], 1, nil, nil, nil, nil, nil, nil, nil
[09:33:39]: [Scanner]: SaveBag, bag, 0, true
[09:33:39]: [Events]: SpamBagQueue, totalProcessed, 5
[09:33:39]: [Data]: PopulateItemCache, 732, 0
[09:33:39]: [Data]: PopulateItemCache, 1, 1
[09:33:39]: [Data]: PopulateItemCache, 1, 2
[09:33:40]: [Data]: PopulateItemCache, 1, 3
[09:33:40]: [Data]: PopulateItemCache, 1, 4
[09:33:40]: [Data]: PopulateItemCache, 1, 5
[09:33:41]: [Data]: PopulateItemCache, 0, -1

If you notice above, the guild money here IS correct! I didn't notice this part because I think with all the debug options I had selected it probably erased some of the early stuff in the scroll buffer.

Open the Gold Window.

[09:34:08]: [Data]: IterateUnits, nil, nil
[09:34:08]: [Data]: argKey, argValue, options§, table: 0000027B9DA4F5A0
[09:34:08]: [Data]: argKey while, options§
[09:34:08]: [Data]: argKey while, blacklist§
[09:34:08]: [Data]: argKey while, whitelist§
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: k,v, %%thisIsMyOtherCharacterName2%%, table: 0000027B9DA4FC30
[09:34:08]: [Data]: v.money inside, 15292462735
[09:34:08]: [Data]: skipReturn, false
[09:34:08]: [Data]: v.faction, Alliance
[09:34:08]: [Data]: v.money, 15292462735
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: k,v, %%thisIsMyOtherCharacterName1%%, table: 0000027B9DA51260
[09:34:08]: [Data]: v.money inside, 34675676181
[09:34:08]: [Data]: skipReturn, false
[09:34:08]: [Data]: v.faction, Alliance
[09:34:08]: [Data]: v.money, 34675676181
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: k,v, %%thisIsMyGuildName%%©, table: 0000027B9DA6D3B0
[09:34:08]: [Data]: v.money inside, 0
[09:34:08]: [Data]: skipReturn, false
[09:34:08]: [Data]: v.faction, Alliance
[09:34:08]: [Data]: v.money, 0
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: k,v, %%thisIsMyOtherCharactersGuildName%%©, table: 0000027B9DA6D630
[09:34:08]: [Data]: v.money inside, 10314300611
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: k,v, %%thisIsMyCharacterName%%, table: 0000027B9DA6D680
[09:34:08]: [Data]: v.money inside, 26336220281
[09:34:08]: [Data]: skipReturn, false
[09:34:08]: [Data]: v.faction, Alliance
[09:34:08]: [Data]: v.money, 26336220281
[09:34:08]: [Data]: argKey while, %%thisIsMyRealmName%%
[09:34:08]: [Data]: elseif argKey
[09:34:08]: [Data]: isConnectedRealm, true
[09:34:08]: [Data]: vars, false, true, %%thisIsMyGuildName%%©, true, false, %%thisIsMyRealmName%%, true
[09:34:08]: [Data]: argKey while, savedsearch§
[09:34:08]: [Data]: argKey while, forceDBReset§

Notice how v.money for guilds only is 0 here. So it is exclusively when using /bgs gold and not when it's initially loaded.

Basically I want to rule out the SaveGuildBankMoney function. Verify if it's zero or what not.

If it's zero then lets try something.

I don't think it is the SaveGuildBankMoney() function so I don't think the last part of the test is required but if you would like me to do it anyway, let me know.

commented

Well I found the answer.

[09:33:37]: [Scanner]: SaveGuildBankMoney, 0

GetGuildBankMoney() is returning zero, so it's being written as zero at login.

commented

This is the direct line from BagSync for debugging.
Debug(BSYC_DL.INFO, "SaveGuildBankMoney", GetGuildBankMoney())

The second parameter for that debug line is zero because the return for the function GetGuildBankMoney() is zero.

commented

If it's zero then lets try something.

  • Open Scanner.lua and find the function "Scanner:SaveGuildBankMoney()"
  • comment out using "--" or remove the line guildDB.money = GetGuildBankMoney()
  • save it and now go to your guild bank, open it. Save and exit and relogin.

We need to figure out where it's being overwritten. There is only a few places this happens.

Try this part of my instructions above and see if it still occurs. This requires you to manually check the guild bank though.

commented

Try this part of my instructions above and see if it still occurs. This requires you to manually check the guild bank though.

Ah, yup! Commenting that out fixed* it! I wonder if Blizzard changed it so you can only call GetGuildBankMoney() if you have the Guild window open.

Well, fixed in that it shows Guild gold now in /bgs gold correctly all the time, but it (obviously) won't update when you do a Guild Bank scan since we commented that part out.

commented
  • Logging in fresh: /print GetGuildBankMoney() returns 0.
  • Opening a vendor with repair options returns 0.
  • Opening the Guild Bank returns the correct value for the guild bank that is opened

Interesting to note here (highlighted), per https://wowpedia.fandom.com/wiki/API_GetGuildBankMoney

Will return 0 (zero) if the guild bank frame was not opened, or a cached value from the last time the guild bank frame was opened on any character since the game client was started.

I think the correct/easiest way to handle it will be to only call GetGuildBankMoney() if the Guild Bank frame is open (as you rightfully suggested), otherwise you may get a cached value or 0 if the Guild Bank was never opened.

commented

Well that settles it. I'm going to have to set it to only save at a guild bank. If someone mentions something then I'll point them to the API restriction. Technically yes I can do a check for CanMerchantRepair() and CanGuildBankRepair() then hook into RepairAllItems() to check for the guildbank flag. But I really don't want to as that is just extra work and debugging I'd have to do for the future and I just really want to keep things simple. If you want guild bank money values, just visit the guild bank.