From 68f46eb4a13b49d7c2fbb3d7bd84359d2030665b Mon Sep 17 00:00:00 2001 From: F16Gaming Date: Wed, 23 May 2012 19:52:19 +0200 Subject: [PATCH] Some optimization. --- AuthManager.lua | 5 +++++ ChatManager.lua | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/AuthManager.lua b/AuthManager.lua index b19d0b3..37931c6 100644 --- a/AuthManager.lua +++ b/AuthManager.lua @@ -17,6 +17,11 @@ * along with Command. If not, see . --]] +-- Upvalues +local tostring = tostring +local tonumber = tonumber +local math = math + local C = Command C.AuthManager = { diff --git a/ChatManager.lua b/ChatManager.lua index d5aa1ec..740bf74 100644 --- a/ChatManager.lua +++ b/ChatManager.lua @@ -173,9 +173,11 @@ end --- Handle a chat message. -- @param msg The message to handle. -- @param sender Player object of the player who sent the message. --- @param channel Channel the message was sent from. +-- @param channel The channel to which HandleMessage will send the result. -- @param target Player or channel index. +-- @param sourceChannel The source channel that the message was sent from. -- @param isBN True if battle.net message, false or nil otherwise. +-- @param pID Player ID (for battle.net messages, this is nil when isBN is false or nil). -- function CM:HandleMessage(msg, sender, channel, target, sourceChannel, isBN, pID) isBN = isBN or false @@ -223,6 +225,10 @@ function CM:HandleMessage(msg, sender, channel, target, sourceChannel, isBN, pID end end elseif result == "RAW_TABLE_OUTPUT" then + if type(arg) ~= "table" then + error("Received RAW_TABLE_OUTPUT request, but arg was of type '" .. type(arg) .. "', expected 'table', aborting...") + return + end for _,v in ipairs(arg) do self:SendMessage(tostring(v), channel, target, isBN) end -- 1.7.9.5