Thread Tools Display Modes
10-25-19, 09:35 PM   #1
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 32
Fallout and proposed workaround to the recent SendWho() restrictions in Classic

Blizzard placed a restriction on scripts using SendWho() and got rid of SendWhoToUI(), to kill the use of Who in scripts like LFG addons for classic and perhaps this is good thing. But one thing needs to come back (or be unbroken) is basic information request about players... Finding basic player information { Class, Race, Sex, Level } if the player's name is known. Addons that color names in channels by class is an example of when then this information is needed.

If all the devs with addons that need this information implement the exact same protocol for querying the information, we can get this information request ability back... Using whisper addon messages, an online player has the option (by having or not having the addon installed) to give information about themselves; it's a simple request / respond protocol.


Click here for the most recent version of the proposed workaround (pastebin)...

Last edited by Nightness : 10-25-19 at 09:38 PM.
  Reply With Quote
10-25-19, 09:56 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
You don't need an addon to color names by class:

/run SetCVar("chatClassColorOverride",0)

Also, race and sex are available in GetPlayerInfoByGUID(). Most, if not all, chat events that have a player name also give a GUID. The only thing chat-related affected by the SendWho restriction is level.
  Reply With Quote
10-25-19, 10:51 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Don't worry, you're fine. I wasn't attacking you, just informing you. You don't need UnitGUID to get a player's GUID from chat, it comes in the 12th argument in chat event payloads. It's how that cvar I mentioned works in the UI code.

Lua Code:
  1. function ChatClassColorOverrideShown()
  2.     local value = GetCVar("chatClassColorOverride");
  3.     if value == "0" then
  4.         return true;
  5.     elseif value == "1" then
  6.         return false;
  7.     else
  8.         return nil;
  9.     end
  10. end
  11.  
  12. function Chat_ShouldColorChatByClass(chatTypeInfo)
  13.     local override = ChatClassColorOverrideShown();
  14.     local colorByClass = chatTypeInfo and chatTypeInfo.colorNameByClass;
  15.     return override or (override == nil and colorByClass);
  16. end
  17.  
  18. function GetColoredName(event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
  19. -- truncate...
  20.     if ( arg12 and info and Chat_ShouldColorChatByClass(info) ) then
  21.         local localizedClass, englishClass, localizedRace, englishRace, sex = GetPlayerInfoByGUID(arg12)
  22.  
  23.         if ( englishClass ) then
  24.             local classColorTable = RAID_CLASS_COLORS[englishClass];
  25.             if ( not classColorTable ) then
  26.                 return arg2;
  27.             end
  28.             return string.format("\124cff%.2x%.2x%.2x", classColorTable.r*255, classColorTable.g*255, classColorTable.b*255)..arg2.."\124r"
  29.         end
  30.     end
  31. -- truncate...
  32. end

GetColoredName is called every single time ChatFrame_MessageEventHandler is called. Also, as long as any event gives you the GUID, it will return usable values, no matter who the player is. It's a universal solution for every player your UI interacts with. You're right about the cache thing, but there's no point in asking for info about an offline player or a player you don't see anywhere in the UI anyways.

Last edited by Kanegasi : 10-25-19 at 10:54 PM.
  Reply With Quote
10-25-19, 10:53 PM   #4
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 32
Originally Posted by Kanegasi View Post
Don't worry, you're fine. I wasn't attacking you, just informing you.
I appreciate that, and walked all my comments back, I guess channel chat is enough to put you in the cache of the other people in the channel, that's all I wanted.

Thanks!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Fallout and proposed workaround to the recent SendWho() restrictions in Classic

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