08-31-17, 03:54 PM | #1 |
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; 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 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. |
|
09-03-17, 04:30 AM | #2 |
Unfortunately, I couldn't reproduce the issue with GetGuildInfo via chat commands. Running
Code:
/run print(GetGuildInfo("player")) Code:
AutoGear absolute 1 nil 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. |
|
09-03-17, 05:19 AM | #3 |
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.
|
|
09-03-17, 09:40 AM | #4 |
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. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » Looking for Broken Code Help |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|