From eb9e0db9301804826119af95fd94359dcf199f5f Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Tue, 30 Nov 2010 19:07:56 +0000 Subject: [PATCH] MDB reassures me it's safe to assume the client is a CrowdClient here, which makes the function short enough to inline. Also rename _auxobj to _bodyobj. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6322 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/chat/client/ChatDirector.as | 36 +++++++------------ .../crowd/chat/client/TellHandler.as | 3 +- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/main/as/com/threerings/crowd/chat/client/ChatDirector.as b/src/main/as/com/threerings/crowd/chat/client/ChatDirector.as index 40915ba31..952b1b9b2 100644 --- a/src/main/as/com/threerings/crowd/chat/client/ChatDirector.as +++ b/src/main/as/com/threerings/crowd/chat/client/ChatDirector.as @@ -67,16 +67,6 @@ public class ChatDirector extends BasicDirector // statically reference classes we require ChatMarshaller; - /** - * Convenience method for returning the body of a client in a super safe manner, taking - * into account the (remote, one imagines) possibility that it might not be a CrowdClient. - */ - public static function getBodyObject (client :Client) :BodyObject - { - return (client is CrowdClient) ? (client as CrowdClient).bodyOf() : - (client.getClientObject() as BodyObject); - } - /** * Creates a chat director and initializes it with the supplied context. * @@ -624,10 +614,9 @@ public class ChatDirector extends BasicDirector { super.clientDidLogon(event); - _auxobj = getBodyObject(event.getClient()); - + _bodyobj = (event.getClient() as CrowdClient).bodyOf(); // listen on the body object for tells - addAuxiliarySource(_auxobj, ChatCodes.USER_CHAT_TYPE); + addAuxiliarySource(_bodyobj, ChatCodes.USER_CHAT_TYPE); } // documentation inherited @@ -636,13 +625,12 @@ public class ChatDirector extends BasicDirector super.clientObjectDidChange(event); // change what we're listening to for tells - if (_auxobj != null) { - removeAuxiliarySource(_auxobj); + if (_bodyobj != null) { + removeAuxiliarySource(_bodyobj); } - _auxobj = getBodyObject(event.getClient()); - + _bodyobj = (event.getClient() as CrowdClient).bodyOf(); // listen on the body object for tells - addAuxiliarySource(_auxobj, ChatCodes.USER_CHAT_TYPE); + addAuxiliarySource(_bodyobj, ChatCodes.USER_CHAT_TYPE); if (clearChatOnClientExit()) { clearDisplays(); @@ -654,10 +642,10 @@ public class ChatDirector extends BasicDirector { super.clientDidLogoff(event); - if (_auxobj != null) { + if (_bodyobj != null) { // stop listening to it for tells - removeAuxiliarySource(_auxobj); - _auxobj = null; + removeAuxiliarySource(_bodyobj); + _bodyobj = null; } // in fact, clear out all auxiliary sources @@ -716,7 +704,7 @@ public class ChatDirector extends BasicDirector addChatter(speaker); // note whether or not we have an auto-response - var self :BodyObject = getBodyObject(_cctx.getClient()); + var self :BodyObject = (_cctx.getClient() as CrowdClient).bodyOf(); if (!StringUtil.isBlank(self.awayMessage)) { autoResponse = self.awayMessage; } @@ -932,7 +920,7 @@ public class ChatDirector extends BasicDirector internal function getCommandHandlers (command :String) :Map { var matches :Map = Maps.newMapOf(String); - var user :BodyObject = getBodyObject(_cctx.getClient()); + var user :BodyObject = (_cctx.getClient() as CrowdClient).bodyOf(); var keys :Array = _handlers.keys(); for (var ii :int = 0; ii < keys.length; ii++) { var cmd :String = (keys[ii] as String); @@ -1064,7 +1052,7 @@ public class ChatDirector extends BasicDirector protected var _place :PlaceObject; /** The object that we're listening to for tells. */ - protected var _auxobj :DObject; + protected var _bodyobj :DObject; /** A list of registered chat displays. */ protected var _displays :ObserverList = new ObserverList(); diff --git a/src/main/as/com/threerings/crowd/chat/client/TellHandler.as b/src/main/as/com/threerings/crowd/chat/client/TellHandler.as index ce40d740e..d4ffcc55a 100644 --- a/src/main/as/com/threerings/crowd/chat/client/TellHandler.as +++ b/src/main/as/com/threerings/crowd/chat/client/TellHandler.as @@ -26,6 +26,7 @@ import com.threerings.util.ResultAdapter; import com.threerings.util.ResultListener; import com.threerings.util.StringUtil; +import com.threerings.crowd.client.CrowdClient; import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.chat.data.ChatCodes; @@ -53,7 +54,7 @@ public class TellHandler extends CommandHandler } // make sure we're not trying to tell something to ourselves - var self :BodyObject = ChatDirector.getBodyObject(ctx.getClient()); + var self :BodyObject = (ctx.getClient() as CrowdClient).bodyOf(); if (handle.toLowerCase() === self.getVisibleName().toString().toLowerCase()) { return "m.talk_self"; }