Quantcast

Fixed cross-realm addon communication.

F16Gaming [04-07-12 - 23:22]
Fixed cross-realm addon communication.
Filename
AddonComm.lua
Command.lua
PlayerManager.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/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