Thread Tools Display Modes
07-10-12, 10:09 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Guild repairs API

Hello.

I've been trying to fix a problem with my auto repair mod when it comes to guild repairs. Namely, if the guild bank has insufficient funds for your repairs, but you are allowed to withdraw money, then the addon should not tell you that your gear was repaired.

Wowprogramming states that GetGuildBankMoney() only updates when GUILDBANK_UPDATE_MONEY or GUILDBANKFRAME_OPENED fires. Otherwise, it returns a cached amount. This seems to be a problem even in the Blizzard UI; sometimes, when mousing over the guild repair icon, the tooltip indicates the amount of a guild of one of your other characters.

This code is used in MerchantFrame.xml, used to calculate the amount you can use for repairs:

Code:
local amount = GetGuildBankWithdrawMoney();
local guildBankMoney = GetGuildBankMoney();
if ( amount == -1 ) then
	-- Guild leader shows full guild bank amount
	amount = guildBankMoney;
else
	amount = min(amount, guildBankMoney);
end
The problem here is that when GetGuildBankMoney() returns a cached amount, for example 0, the display will be incorrect.

In fact, even the button is bugged - they acknowledge it in the code. You hear the 'repair' sound when you click it, even when your guild has no money left. You do get an error though stating that your guild does not have enough money when you try this, but that's before the amount returned by GetGuildBankMoney() even updates.

--

Simply put - is there a fool-proof way to ensure your guild has enough money before the addon attempts to repair? Perhaps there is a way to force either of these events to fire? Or should the addon check your gear's durability after it attempted a repair, to ensure that it actually was repaired?
  Reply With Quote
07-10-12, 10:46 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
The only way I can think of to get those events to fire is to physically go to the guild bank and open it briefly. Everything that triggers those events is in C code and therefore is out of reach of Lua.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
07-10-12, 10:50 AM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I see, thanks. I'll have to go with the workaround of iterating over equipped items and checking if they were effectively repaired - bit of a hack, but it seems to work.
  Reply With Quote
07-12-12, 09:26 AM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Ah, turns out that isn't fool-proof either. Durability doesn't update instantly, so you'd have to register UPDATE_INVENTORY_DURABILITY and wait until it fires - thing is, it doesn't fire when your guild actually does lack funds to repair.

Seems like this is something Blizzard will have to update themselves.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Guild repairs API


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