summaryrefslogtreecommitdiff
path: root/src/connectionhandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-12-27 03:42:40 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-12-27 03:42:40 +0000
commit205579c3be58537060785d174f9f67c89444a21b (patch)
tree31c7c8e0af476e70259650e1c577eaf299f3fc78 /src/connectionhandler.cpp
parentad9ecbf35e0d986d704deba6f8f20ad72a94a99e (diff)
downloadmanaserv-205579c3be58537060785d174f9f67c89444a21b.tar.gz
manaserv-205579c3be58537060785d174f9f67c89444a21b.tar.bz2
manaserv-205579c3be58537060785d174f9f67c89444a21b.tar.xz
manaserv-205579c3be58537060785d174f9f67c89444a21b.zip
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.
Diffstat (limited to 'src/connectionhandler.cpp')
-rw-r--r--src/connectionhandler.cpp43
1 files changed, 42 insertions, 1 deletions
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 <iostream>
#include <vector>
#include <sstream>
#include <SDL_net.h>
@@ -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;
+ }
+ }
+ }
+}
+
+