From 205579c3be58537060785d174f9f67c89444a21b Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Tue, 27 Dec 2005 03:42:40 +0000 Subject: Implemented common chat handling, except for chatting in channels. Also the Channel registering/unregistering isn't there yet and the commands needs to be implemented. Added a small slangs filter to reduce bad words in account names and in conversations a little. --- src/connectionhandler.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'src/connectionhandler.cpp') diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index c8ed1c6e..b8172fe0 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -21,7 +21,6 @@ */ -#include #include #include #include @@ -256,3 +255,45 @@ void ConnectionHandler::sendTo(tmwserv::BeingPtr beingPtr, MessageOut &msg) } } } + +void ConnectionHandler::sendTo(std::string name, MessageOut &msg) +{ + for (NetComputers::iterator i = clients.begin(); + i != clients.end(); + i++) { + if ((*i)->getCharacter().get()->getName() == name) { + (*i)->send(msg.getPacket()); + break; + } + } +} + +void ConnectionHandler::sendToEveryone(MessageOut &msg) +{ + for (NetComputers::iterator i = clients.begin(); + i != clients.end(); + i++) + { + (*i)->send(msg.getPacket()); + break; + } +} + +void ConnectionHandler::sendAround(tmwserv::BeingPtr beingPtr, MessageOut &msg) +{ + for (NetComputers::iterator i = clients.begin(); + i != clients.end(); + i++) { + // See if the other being is near enough, then send the message + if (abs((*i)->getCharacter().get()->getX() - beingPtr.get()->getX()) <= AROUND_AREA_IN_TILES ) + { + if (abs((*i)->getCharacter().get()->getY() - beingPtr.get()->getY()) <= AROUND_AREA_IN_TILES ) + { + (*i)->send(msg.getPacket()); + break; + } + } + } +} + + -- cgit v1.2.3-70-g09d2