Thread Tools Display Modes
07/02/14, 04:24 AM   #1
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
planning "DisplayNameFix"

Garkin and farangkao found a way for addons to possibly solve the whole "DisplayName" issue temporarily.

Basically it invovles getting the proper Display Name from your first Guild (if you have any) or from your "remmber account name" setting on the Login Screen.
They have been thinking about just working that into their addons, but I think a proper seperate addon is better.
This allows users to explicitly make all the nessesary work, and gives us one place to blank out the code once it works properly again.

Requirements to use this:
Before starting with this addon on, you must restructure your saved var files according. (basically the counter to what you do here). Otherwise you end up restting your data again.
As long as you use it, you must either be in at least 1 Guild or have checked the "rememebr account name" Checkbox on the login page.

Problems to think about:
1. If you need the display name before the OnLoadeed event, you have to add this addons as optional Dependency to your addon manifest. But those cases should be rare.
2. We need to check if the current version of GetDispalyName() is working properly (not returning nil or ""). If it does, no work has to be done.
3. We need to check if the name was successfully retreived either from the Guilds or from the CVars. If not, we best just return the result of the original GetDisplayName()

Code is following soon. And I wait for full peer review on my code before I throw out something as dangerous as this.
  Reply With Quote
07/02/14, 04:43 AM   #2
farangkao
 
farangkao's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 59
Just to clarify, i will not fix GetDisplayName with my Addon, but i will use the Idea to determine which Account Name is active (for support for Multiple Accounts until the Bug is officially fixed) without redefining GetDisplayName.

On General your Idea is good,that way it can be easily disabled/enabled.

Some idea's (Avoid User needs to Edit his Files):
- Addon's can "subscribe" to the new GetDisplayName functionality as soon they are prepared for it.
- Addon's that don't update lately and are being tested to not loose data with a change, could be added to a list by yourself.
- In theory an Addon could read the Data into Table(s) saved under [""] ,then request the new GetDisplayName Function and save it again under ["@Accountname"], with no need for Users to fiddle around with Notepad++

Possible Problems:
- User disables your Addon before a Patch brings back the GetDisplayName properly, all "fixed" SavedVars would not be read/saved correctly, hence a possible "data loss" for the End User.
Possible workaround: User needs to confirm in the Options of your Addon first, that he is aware of this ,and won't disable it ,until the addon is officially not necessairy anymore.


Advantages of this Workaround ,then waiting for the official Fix:
- If ZOS is not doing some automatic transfer of the Saved Vars, but just fixes the Function,
it will cause a Data loss, unless the User had used your Addon before to fix it
or does a manual Edit of his SavedVars once again before the Patch is messing with the files.

Last edited by farangkao : 07/02/14 at 04:55 AM.
  Reply With Quote
07/02/14, 04:44 AM   #3
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Lua Code:
  1. --step one: get a reference on the current GDN function
  2. local oldGDN = GetDisplayName
  3.  
  4. --step two, prepare the two sub functions
  5. local function gdnGuild()
  6.     local result = nil
  7.  
  8.     --try to get the name from teh Guild
  9.     if GetNumGuilds() > 0 then
  10.           result = GetGuildMemberInfo(GetGuildId(1), GetPlayerGuildMemberIndex(GetGuildId(1)))
  11.     end
  12.  
  13.     --check if what you got is at least remotely valid just in case; if not, ignore it
  14.    if not (result ~= nil and string.len(result) >= 2 and string.sub(result, 1, 1) == "@") then
  15.      result = nil
  16.    end
  17.  
  18.    return result
  19. end
  20.  
  21. local function gdnLogin()
  22.     local result = GetCVar("AccountName")
  23.  
  24.     if(result ~= nil and string.len(result) > 0) then
  25.      result = "@" .. result
  26.    else
  27.      result = nil
  28.    end
  29.  
  30.    return result
  31. end
  32.  
  33. --Step three, build your actuall function
  34. local function newGDN()
  35.   local result = nil
  36.  
  37.   --1. Try out the Guild function. If you get a hit, out with it
  38.   result = gdnGuild()
  39.   if(result ~= nil) then return result end
  40.  
  41.   --2. Try out the Login function. If you get a hit, out with it
  42.   result = gdnLogin()
  43.   if(result ~= nil) then return result end
  44.  
  45.   --3. If all failed, at least return the normal function result
  46.   return oldGDN ()
  47. end
  48.  
  49. --Step four, check if the current function is buggy. If so, replace it:
  50. local DName = GetDisplayName()
  51. if (DName == nil or string.len(DName) <= 1 or string.sub(result, 1, 1) ~= "@") then
  52.   GetDisplayName = newGDN
  53. end

Last edited by zgrssd : 07/02/14 at 05:21 AM.
  Reply With Quote
07/02/14, 05:25 AM   #4
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
I just realised that other addons migh be interested to know my addon is there. And wheter it replaced the GetDisplayName function or not (and maybe accessing my other functions). So I am going to add the following table to the global namespace:
Code:
if(DisplayNameFix01 == nil) then

DisplayNameFix01 = { 
  oldGDN = oldGDN, 
  newGDN = newGDN,
  GDNbyGuild = gdnGuild,
  GDNbyLogin = gdnLogin
  replacedGDN = --tells you if the normal GDN was overwritten; will add proper local variable to be set in the check
}
end
Edit: Added a if block to not overwrite the global variable it it exists already
Edit2:
Notes to self:
Add a check if this addon is out of date before before checking if the oldGDN is working (doing extra nothing if the API versio ncahnges).
Maybe use libStub isntead of Global variable.

Last edited by zgrssd : 07/02/14 at 05:43 AM.
  Reply With Quote
07/02/14, 07:38 AM   #5
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
That went surprisingly well. But then again it was the idea of others who know the game a lot better then me.

Just having my addon running instantly let's the addons use the proper account names for Saved Variables. I could even test it on the NA server where I have no guild to call upon.
Uploading a Beta version of this next for fellow programmers to test.
  Reply With Quote
07/02/14, 08:16 AM   #6
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
As promised, here is the alpha/0.01 version:
http://www.esoui.com/downloads/info6...ayNameFix.html
  Reply With Quote
07/04/14, 06:01 AM   #7
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Just uploaded version 0.02
It now has a user override and I reordered the logic to go for the fastest/most reliable ways first.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » planning "DisplayNameFix"


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