Quantcast

Merge branch 'master' into mop

F16Gaming [04-07-12 - 23:22]
Merge branch 'master' into mop
Filename
AddonComm.lua
Command.lua
Events.lua
PlayerManager.lua
String.lua
diff --git a/AddonComm.lua b/AddonComm.lua
index 9858491..022ec13 100644
--- a/AddonComm.lua
+++ b/AddonComm.lua
@@ -121,6 +121,12 @@ function AC:Receive(msgType, msg, channel, sender)
 		wipe(self.GroupMembers)
 		for _,v in ipairs(t) do
 			if v then
+				if not v:find("-") then
+					local name, realm = UnitName(v)
+					if realm then
+						v = ("%s-%s"):format(name, realm)
+					end
+				end
 				table.insert(self.GroupMembers, v)
 			end
 		end
@@ -129,6 +135,12 @@ function AC:Receive(msgType, msg, channel, sender)
 	elseif msgType == self.Type.GroupAdd then
 		if channel ~= "WHISPER" or not GT:IsGroup() then return end
 		if self.GroupMembers[1] ~= UnitName("player") then return end
+		if not msg:find("-") then
+			local name, realm = UnitName(msg)
+			if realm then
+				msg = ("%s-%s"):format(name, realm)
+			end
+		end
 		if not CET:HasValue(self.GroupMembers, msg) then
 			table.insert(self.GroupMembers, msg)
 		end
@@ -177,6 +189,14 @@ function AC:Send(msgType, msg, channel, target)
 		error(L("AC_ERR_MSGTYPE"):format(tostring(msgType)))
 		return
 	end
+	if type(target) == "string" then
+		if not target:find("-") then
+			local name, realm = UnitName(target)
+			if realm then
+				target = ("%s-%s"):format(name, realm)
+			end
+		end
+	end
 	SendAddonMessage(msgType, msg, channel, target)
 	if msgType ~= self.Type.VersionUpdate and channel ~= "WHISPER" then
 		SendAddonMessage(self.Type.VersionUpdate, self.Format.VersionUpdate:format(C.VersionNum), channel)
diff --git a/Command.lua b/Command.lua
index 3a5cbdf..fb8e164 100644
--- a/Command.lua
+++ b/Command.lua
@@ -20,6 +20,7 @@
 -- Upvalues
 local type = type
 local wipe = wipe
+local assert = assert

 --- Table containing all Command methods.
 -- This is referenced "C" in Command.lua
diff --git a/Events.lua b/Events.lua
index 98a9faa..ccf65b1 100644
--- a/Events.lua
+++ b/Events.lua
@@ -37,7 +37,7 @@ function C.Events.ADDON_LOADED(self, ...)
 	local name = (select(1, ...))
 	if name:lower() ~= self.Name:lower() then return end
 	self:Init()
-	C.Frame:UnregisterEvent("ADDON_LOADED")
+	self.Frame:UnregisterEvent("ADDON_LOADED")
 end

 --- Event handler for LFG_UPDATE
diff --git a/PlayerManager.lua b/PlayerManager.lua
index 0e56e56..9c831bf 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -37,7 +37,6 @@ local CCM
 local CET = C.Extensions.Table
 local log

-
 --- Table containing all PlayerManager methods.
 -- This is referenced "PM" in PlayerManager.lua.
 -- @name Command.PlayerManager
diff --git a/String.lua b/String.lua
index eda3adf..a5374ca 100644
--- a/String.lua
+++ b/String.lua
@@ -49,7 +49,7 @@ end

 --- Check if a string ends with a specific string.
 -- @param s String to be checked.
--- @param target Stromg to search for at end of s.
+-- @param target String to search for at end of s.
 --
 function CES:EndsWith(s, target)
 	return target == '' or s:sub(-target:len()) == target
@@ -77,15 +77,15 @@ function CES:Split(s, d)
 		end
 	else
 		if not s:find(d) then return {s} end
-		local p = "(.-)" .. d .. "()"
-		local nb = 0
+		local pattern = "(.-)" .. d .. "()"
+		local num = 0
 		local lastPos
-		for part,pos in s:gmatch(p) do
-			nb = nb + 1
-			t[nb] = part
+		for part,pos in s:gmatch(pattern) do
+			num = num + 1
+			t[num] = part
 			lastPos = pos
 		end
-		t[nb + 1] = s:sub(lastPos)
+		t[num + 1] = s:sub(lastPos)
 	end
 	return t
 end