Merge branch 'master' of git.esoui.com:eso-GuildChat-50

CrazyDutchGuy [07-13-14 - 09:08]
Merge branch 'master' of git.esoui.com:eso-GuildChat-50

Conflicts:
	GuildChat.lua
	GuildChat.txt
	Libs/libGuildInfo/LibGuildInfo.lua
Filename
Libs/libGuildInfo/LibGuildInfo.lua
diff --git a/Libs/libGuildInfo/LibGuildInfo.lua b/Libs/libGuildInfo/LibGuildInfo.lua
index 28f975e..ffe1c71 100644
--- a/Libs/libGuildInfo/LibGuildInfo.lua
+++ b/Libs/libGuildInfo/LibGuildInfo.lua
@@ -1,10 +1,13 @@
-local MAJOR, MINOR = "LibGuildInfo-1.0", 1
+local MAJOR, MINOR = "LibGuildInfo-1.0", 2
 local LibGuildInfo, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 if not LibGuildInfo then return end	--the same or newer version of this lib is already loaded into memory

 local Classes = {[1] = "Dragon Knight", [2]="Sorcerer", [3]="Nightblade", [6]="Templar"}
 local Alliances = {[1] = "Aldmeri Dominion", [2] = "Ebonhart Pact", [3] = "Daggerfall Convenant"}
 -- API --
+
+-- If the table for the name is empty, that means the member has left the guild (thus the 'next' usage)
+-- All future API should funnel through this function, or be aware of the limitations
 function LibGuildInfo:GetGuildMemberByMemberName(name)
 	local member = name:find("@") and self.DisplayNames[name:lower()] or self.CharacterNames[name:lower()]
 	if member and next(member) then return member end
@@ -45,9 +48,7 @@ end

 function LibGuildInfo:GetGuildRankByMemberName(name)
 	local rankIndex = self:GetGuildRankIndexByMemberName(name)
-	if not rankIndex then
-		return "??"
-	elseif rankIndex == 1 then
+	if rankIndex == 1 then
 		return "GL"
 	else
 		return "R"..rankIndex
@@ -57,7 +58,9 @@ end
 -- Setup functions --

 -- This is my deep table copy function, that bypasses previously copied tables
--- to avoid infinite loops when it comes to recursive copying.
+-- to avoid infinite loops when it comes to recursive copying. Essentially a copy
+-- of the ZO_DeepCopyTable, but without the game locking
+
 local visitedTables = {}

 function LibGuildInfo:DeepTableCopy(source, subCall)
@@ -139,12 +142,15 @@ function LibGuildInfo:OnGuildMemberAdded(guildId, displayName)
 	GUILD_ROSTER:SetGuildId(currentGuildId)
 end

+-- If they're removed from the guild, empty the table out
 function LibGuildInfo:OnGuildMemberRemoved(guildId, displayName)
 	if not self.GuildDataLoaded then return end
 	local v = self.DisplayNames[displayName:lower()]
 	ZO_ClearTable(v)
 end

+-- We just shallow copy into the existing table so as not to lose the
+-- table references everywhere by replacing it
 function LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName)
 	if not self.GuildDataLoaded then return end
 	local currentGuildId = GUILD_ROSTER.guildId
@@ -155,10 +161,10 @@ function LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName)
 	GUILD_ROSTER:SetGuildId(currentGuildId)
 end

-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_PLAYER_ACTIVATED, function() LibGuildInfo:DataLoaded() end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_ADDED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberAdded(guildId, displayName) end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_REMOVED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberRemoved(guildId, displayName) end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_CHARACTER_UPDATED,  function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_CHARACTER_LEVEL_CHANGED,	function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_CHARACTER_VETERAN_RANK_CHANGED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
-EVENT_MANAGER:RegisterForEvent("LibGuildInfo", EVENT_GUILD_MEMBER_RANK_CHANGED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_PLAYER_ACTIVATED, function() LibGuildInfo:DataLoaded() end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_ADDED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberAdded(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_REMOVED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberRemoved(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_CHARACTER_UPDATED,  function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_CHARACTER_LEVEL_CHANGED,	function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_CHARACTER_VETERAN_RANK_CHANGED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)
+EVENT_MANAGER:RegisterForEvent(MAJOR, EVENT_GUILD_MEMBER_RANK_CHANGED, function(_, guildId, displayName) LibGuildInfo:OnGuildMemberCharacterUpdated(guildId, displayName) end)