Thread Tools Display Modes
08-31-17, 03:54 PM   #1
Elderin
A Deviate Faerie Dragon
Join Date: Nov 2012
Posts: 17
Looking for Broken Code Help

I am having a timing issue show up in one of my addons and I'm hoping there is an elegant fix.

The addon has a frame to which an event handler is attached and the frame registers for the "ADDON_LOADED" AND "PLAYER_ENTERING_WORLD" events.

The event handler checks for the appropriate events; along with the addon name in the case of the "ADDON_LOADED" event.

Currently during the "ADDON_LOADED" event processing only a notification that the addon is loaded is produced.

It is in the "PLAYER_ENTERING_WORLD" event processing that my issue is occurring. Prior to the recent 7.3 patch all was working good. That processing makes a call to the following module

Code:
local function GetMyStats(getFullName)
	local pName = "me";
	local pRank = -1;
	local pOcls = false;
	local rName ="Realm Name";
	
	pName, rName = UnitFullName("player");  -- player name, player realm
	if (getFullName) then
		pName = pName.."-"..rName;
	end;
	if (IsInGuild()) then
		local gn, rn, ri, gr = GetGuildInfo("player");  -- guild name, rank name, rank index, guild realm
		if (gr == nil) then  -- guild realm is nil if it is the same as the player's realm
			gr = rName;
		end;
		if (ri) then
			GuildControlSetRank(ri + 1);
			print("Guild Name: "..(gn or "nil")..", Guild Realm: "..(gr or "nil").."\nGuild Rank Index: "..(ri or "nil")..", Rank Name: "..(rn or "nil"));
			local gcl, gcs, ocl, ocs = GuildControlGetRankFlags();
			for i, v in ipairs({GuildControlGetRankFlags()}) do
				local flag = _G["GUILDCONTROL_OPTION"..i];
				print (ri, i, flag, v);
			end;
			if (ocl and ocs) then
				pOcls = true;
			end;
			pRank = ri;
		end;
	end;
	return pName, pRank, pOcls;
end;
First, the GuildControlSetRank() function is now marked protected in the 7.3 release. Included in red in the code above, but actually commented out in my current code. This seems to cause the GuildControlGetRankFlags() to malfunction and return false for all the flags. That in itself is a separate issue and i am including it just in case someone may have some insight about it.

Second, my primary issue is when the addon is first loaded and the "PLAYER_ENTERING_WORLD" fires for the first time, the function GetGuildInfo("player") is returning all nil values except for the rank index which is returned as zero. If while in game I then perform a /reload, the new call to GetGuildInfo("player") returns all values properly loaded. The output of the first time run is shown below.

Code:
Guild Name: nil, Guild Realm: nil
  Guild Rank Index: 0, Rank Name: nil

0 1 Guildchat Listen false
0 2 Guildchat Speak false
0 3 Officerchat Listen false
0 4 Officerchat Speak false
0 5 Promote false
0 6 Demote false
0 7 Invite Member false
0 8 Remove Member false
0 9 Set MOTD false
0 10 Edit Public Note false
0 11 View Officer Note false
0 12 Edit Officer Note false
0 13 Modify Guild Info false
0 14 Create Guild Event false
0 15 Guild Bank Repair false
0 16 Withdraw Gold false
0 17 Create Guild Event false
0 18 Requires Authenticator false
0 19 Modify Bank Tabs false
0 20 Remove Guild Event false
After a /reload the guild information is correctly loaded but the flags continue to be false as shown. So, I am wondering if there might be a different event that that I need to use to get the guild info properly loaded the first time. Or, perhaps a call first to some other system function to cause it to be available sooner.

Originally, I made the call to the function shown during the "ADDON_LOADED" event processing but discovered that the player's realm name from UnitFullName() was not available until after the "PLAYER_ENTERING_WORLD" event fired. So, I moved it to the "PLAYER_ENTERING_WORLD" event processing and it has apparently been working until this recent release.

Thank for any help or ideas.
  Reply With Quote
09-03-17, 04:30 AM   #2
BujuArena
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 13
Unfortunately, I couldn't reproduce the issue with GetGuildInfo via chat commands. Running

Code:
/run print(GetGuildInfo("player"))
from chat returned

Code:
AutoGear absolute 1 nil
here.

You could try calling GuildRoster() before GetGuildInfo("player") if the issue persists. GuildRoster updates the guild info in the cache and automatically throttles itself to only working once every 10 seconds. I suspect it hadn't been called by the time your GetGuildInfo("player") call happened.
  Reply With Quote
09-03-17, 05:19 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I think something did change with PEW in 7.3, but I can't say for certain. What I can tell you is that MunkDev suggested to me to register for PLAYER_LOGIN instead.
  Reply With Quote
09-03-17, 09:40 AM   #4
Elderin
A Deviate Faerie Dragon
Join Date: Nov 2012
Posts: 17
I think I have finally gotten a sequence that works.

During the PLAYER_ENTERING_WORLD event processing
I make a call to GuildRoster() and register for GUILD_ROSTER_UPDATE

then during the GUILD_ROSTER_UPDATE processing
I make the call to GetGuildInfo("player") and it returns correct data.


The other issue accessing the guild control rank flags appears to simply be broken. Perhaps it is feasible that Blizz needed to make the GuildControlSetRank function protected. But, they then need to to allow the call to GuildControlGetRankFlags() to accept a guild rank argument (1 - GuildControlGetNumRanks()) and, of course, the function would have to be beefed up to validate that value.

I use the third and fourth return values (can listen to officer channel, can speak in officer channel) to determine whether the player's rank is an officer rank. Assuming, of course, that if the player can do both of those things then the player must be an officer. Then I can open up certain functions within my addon to the player that I want available only to officers of the guild.
I really haven't figured out any other way to determine if the player is an officer except hard coding for a specific guild and assuming that the guild master will not change those rank specifications. I really, really don't want to have to do that.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Looking for Broken Code Help

Thread Tools
Display Modes

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