Quantcast

Merge branch 'master' into mop

F16Gaming [07-23-12 - 04:06]
Merge branch 'master' into mop
Filename
Events_Chat.lua
PlayerManager.lua
Table.lua
locales/enUS.lua
locales/svSE.lua
diff --git a/Events_Chat.lua b/Events_Chat.lua
index 22fe4de..0db5abe 100644
--- a/Events_Chat.lua
+++ b/Events_Chat.lua
@@ -29,8 +29,14 @@ local AC = C.AddonComm
 local BNT = C.BattleNetTools

 function C.Events.CHAT_MSG_SYSTEM(self, event, ...)
+	local message = (select(1, ...))
+
 	if C.RollManager.Running then
-		C.RollManager:ParseMessage((select(1, ...)))
+		C.RollManager:ParseMessage(message)
+	end
+
+	if C.Extensions.Table:GetRealLength(C.PlayerManager.Invites) > 0 then
+		C.PlayerManager:ParseMessage(message)
 	end
 end

diff --git a/PlayerManager.lua b/PlayerManager.lua
index 787fe7a..d80559a 100644
--- a/PlayerManager.lua
+++ b/PlayerManager.lua
@@ -65,6 +65,7 @@ C.PlayerManager = {
 	Dialogs = {
 		Kick = "COMMAND_CONFIRMKICK"
 	},
+	Invites = {},
 	Access = {
 		Min = 0,
 		Max = 4,
@@ -233,6 +234,29 @@ function PM:LoadSavedVars()
 	List = self.Data.LIST
 end

+function PM:ParseMessage(message)
+	local name = message:match(L("PM_MATCH_INVITEACCEPTED_PARTY"))
+	if not name then name = message:match(L("PM_MATCH_INVITEACCEPTED_RAID")) end
+	if name then
+		if not self.Invites[name] then return end
+		self.Invites[name] = nil
+		return
+	end
+	name = message:match(L("PM_MATCH_INGROUP"))
+	if name then
+		if not self.Invites[name] then return end
+		CM:SendMessage(L("PM_INVITE_INOTHERGROUP"):format(name), "WHISPER", self.Invites[name][1])
+		self.Invites[name] = nil
+		return
+	end
+	name = message:match(L("PM_MATCH_INVITEDECLINED"))
+	if name then
+		if not self.Invites[name] then return end
+		CM:SendMessage(L("PM_INVITE_DECLINED"):format(name), "WHISPER", self.Invites[name][1])
+		self.Invites[name] = nil
+	end
+end
+
 --- Get or create a player.
 -- @param name Name of player.
 -- @return Player from list of players if exists, otherwise a new player object.
@@ -592,13 +616,16 @@ function PM:Invite(player, sender)
 		return false, "PM_INVITE_FULL"
 	end
 	if GT:IsGroupLeader() or GT:IsRaidLeaderOrAssistant() or not GT:IsGroup() then
-		if player.Info.Name == sender.Info.Name then
+		if self.Invites[player.Info.Name] then
+			return false, "PM_INVITE_ACTIVE", {player.Info.Name}
+		elseif player.Info.Name == sender.Info.Name then
 			InviteUnit(player.Info.Name)
 			return "PM_INVITE_NOTIFYTARGET"
 		elseif player.Settings.Invite then
 			InviteUnit(player.Info.Name)
 			local msg = L(player.Settings.Locale, "PM_INVITE_NOTIFY", true):format(sender.Info.Name, player.Info.Name)
 			CM:SendMessage(msg, "WHISPER", player.Info.Name)
+			self.Invites[player.Info.Name] = {sender.Info.Name}
 			return "PM_INVITE_SUCCESS", {player.Info.Name}
 		else
 			return false, "PM_INVITE_BLOCKED", {player.Info.Name}
diff --git a/Table.lua b/Table.lua
index dfb7cca..f504157 100644
--- a/Table.lua
+++ b/Table.lua
@@ -1,18 +1,18 @@
 --[[
 	* Copyright (c) 2011-2012 by Adam Hellberg.
-	*
+	*
 	* This file is part of Command.
-	*
+	*
 	* Command is free software: you can redistribute it and/or modify
 	* it under the terms of the GNU General Public License as published by
 	* the Free Software Foundation, either version 3 of the License, or
 	* (at your option) any later version.
-	*
+	*
 	* Command is distributed in the hope that it will be useful,
 	* but WITHOUT ANY WARRANTY; without even the implied warranty of
 	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 	* GNU General Public License for more details.
-	*
+	*
 	* You should have received a copy of the GNU General Public License
 	* along with Command. If not, see <http://www.gnu.org/licenses/>.
 --]]
@@ -101,3 +101,11 @@ function CET:Join(tbl, d)
 	end
 	return s
 end
+
+function CET:GetRealLength(tbl)
+	local length = 0
+	for _,_ in pairs(tbl) do
+		length = length + 1
+	end
+	return length
+end
diff --git a/locales/enUS.lua b/locales/enUS.lua
index fc6553f..2d16a6d 100644
--- a/locales/enUS.lua
+++ b/locales/enUS.lua
@@ -337,6 +337,11 @@ local L = {
 	PM_ERR_LOCKED = "Target player is locked and cannot be modified.",
 	PM_ERR_NOTINGROUP = "%s is not in the group.",

+	PM_MATCH_INVITEACCEPTED_PARTY = "(%w+) joins the party.",
+	PM_MATCH_INVITEACCEPTED_RAID = "(%w+) has joined the raid group.",
+	PM_MATCH_INVITEDECLINED = "(%w+) declines your group invitation.",
+	PM_MATCH_INGROUP = "(%w+) is already in a group.",
+
 	PM_ACCESS_ALLOWED = "%q is now allowed for %s.",
 	PM_ACCESS_DENIED = "%q is now denied for %s.",

@@ -374,6 +379,9 @@ local L = {
 	PM_INVITE_SELF = "Cannot invite myself to group.",
 	PM_INVITE_INGROUP = "%s is already in the group.",
 	PM_INVITE_FULL = "The group is already full.",
+	PM_INVITE_ACTIVE = "%s already has an active invite.",
+	PM_INVITE_DECLINED = "%s has declined the group invite.",
+	PM_INVITE_INOTHERGROUP = "%s is already in a group.",
 	PM_INVITE_NOTIFYTARGET = "Invited you to the group.",
 	PM_INVITE_NOTIFY = "%s invited you to the group, %s. Whisper !blockinvites to block these invites.",
 	PM_INVITE_SUCCESS = "Invited %s to group.",
diff --git a/locales/svSE.lua b/locales/svSE.lua
index fe63925..3d9df87 100644
--- a/locales/svSE.lua
+++ b/locales/svSE.lua
@@ -337,6 +337,11 @@ local L = {
 	PM_ERR_LOCKED = "Target player is locked and cannot be modified.",
 	PM_ERR_NOTINGROUP = "%s is not in the group.",

+	PM_MATCH_INVITEACCEPTED_PARTY = "(%w+) joins the party.",
+	PM_MATCH_INVITEACCEPTED_RAID = "(%w+) has joined the raid group.",
+	PM_MATCH_INVITEDECLINED = "(%w+) declines your group invitation.",
+	PM_MATCH_INGROUP = "(%w+) is already in a group.",
+
 	PM_ACCESS_ALLOWED = "%q is now allowed for %s.",
 	PM_ACCESS_DENIED = "%q is now denied for %s.",

@@ -374,6 +379,9 @@ local L = {
 	PM_INVITE_SELF = "Cannot invite myself to group.",
 	PM_INVITE_INGROUP = "%s is already in the group.",
 	PM_INVITE_FULL = "The group is already full.",
+	PM_INVITE_ACTIVE = "%s already has an active invite.",
+	PM_INVITE_DECLINED = "%s has declined the group invite.",
+	PM_INVITE_INOTHERGROUP = "%s is already in a group.",
 	PM_INVITE_NOTIFYTARGET = "Invited you to the group.",
 	PM_INVITE_NOTIFY = "%s invited you to the group, %s. Whisper !blockinvites to block these invites.",
 	PM_INVITE_SUCCESS = "Invited %s to group.",