summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-11-04 17:07:58 +0000
committerDavid Athay <ko2fan@gmail.com>2008-11-04 17:07:58 +0000
commit861fcef3203ffe32c3d8e9b62aa79e2a54934c09 (patch)
treed3a3f8296b479931fc51f1a6a015179ecb2397f7 /src
parent450ef8ede6ff81f09fcadc3683ec7659c994ae83 (diff)
downloadmanaserv-861fcef3203ffe32c3d8e9b62aa79e2a54934c09.tar.gz
manaserv-861fcef3203ffe32c3d8e9b62aa79e2a54934c09.tar.bz2
manaserv-861fcef3203ffe32c3d8e9b62aa79e2a54934c09.tar.xz
manaserv-861fcef3203ffe32c3d8e9b62aa79e2a54934c09.zip
Added notifiying party members when a player joins or leaves the party.
Diffstat (limited to 'src')
-rw-r--r--src/chat-server/chathandler.cpp38
-rw-r--r--src/chat-server/chathandler.hpp18
-rw-r--r--src/defines.h3
3 files changed, 59 insertions, 0 deletions
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index 2cffbc2a..f0e97de9 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -983,6 +983,9 @@ bool ChatHandler::handlePartyJoin(const std::string &invited, const std::string
out.writeByte(ERRMSG_OK);
c1->send(out);
+ // tell everyone a player joined
+ informPartyMemberJoined(*c2);
+
// tell game server to update info
updateInfo(c2, c2->party->getId());
return true;
@@ -1060,6 +1063,8 @@ void ChatHandler::removeUserFromParty(ChatClient &client)
if (client.party)
{
client.party->removeUser(client.characterName);
+ informPartyMemberQuit(client);
+
// if theres less than 1 member left, remove the party
if (client.party->numUsers() < 1)
{
@@ -1069,6 +1074,39 @@ void ChatHandler::removeUserFromParty(ChatClient &client)
}
}
+void ChatHandler::informPartyMemberQuit(ChatClient &client)
+{
+ std::map<std::string, ChatClient*>::iterator itr;
+ std::map<std::string, ChatClient*>::const_iterator itr_end = mPlayerMap.end();
+
+ for (itr = mPlayerMap.begin(); itr != itr_end; ++itr)
+ {
+ if (itr->second.party == client.party)
+ {
+ MessageOut out(CPMSG_PARTY_MEMBER_LEFT);
+ out.writeShort(client.characterId);
+ itr->second.send(out);
+ }
+ }
+}
+
+void ChatHandler::informPartyMemberJoined(ChatClient &client)
+{
+ std::map<std::string, ChatClient*>::iterator itr;
+ std::map<std::string, ChatClient*>::const_iterator itr_end = mPlayerMap.end();
+
+ for (itr = mPlayerMap.begin(); itr != itr_end; ++itr)
+ {
+ if (itr->second.party == client.party)
+ {
+ MessageOut out(CPMSG_PARTY_NEW_MEMBER);
+ out.writeShort(client.characterId);
+ out.writeString(client.characterName);
+ itr->second.send(out);
+ }
+ }
+}
+
ChatClient* ChatHandler::getClient(const std::string &name)
{
std::map<std::string, ChatClient*>::iterator itr;
diff --git a/src/chat-server/chathandler.hpp b/src/chat-server/chathandler.hpp
index 42866f77..c94d2999 100644
--- a/src/chat-server/chathandler.hpp
+++ b/src/chat-server/chathandler.hpp
@@ -271,6 +271,24 @@ class ChatHandler : public ConnectionHandler
removeUserFromParty(ChatClient &client);
/**
+ * Send new member info to party members.
+ */
+ void
+ sendPartyMemberInfo(ChatClient &client, MessageIn &msg);
+
+ /**
+ * Tell all the party members a member has left
+ */
+ void
+ informPartyMemberQuit(ChatClient &client);
+
+ /**
+ * Tell all the party members a member has joined
+ */
+ void
+ informPartyMemberJoined(ChatClient &client);
+
+ /**
* Tell the player to be more polite.
*/
void warnPlayerAboutBadWords(ChatClient &computer);
diff --git a/src/defines.h b/src/defines.h
index 7a1b4a88..498bad4c 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -161,6 +161,7 @@ enum {
GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action
PGMSG_DIRECTION_CHANGE = 0x0272, // B Direction
GPMSG_BEING_DIR_CHANGE = 0x0273, // W being id, B direction
+ GPMSG_BEING_HEALTH_CHANGE = 0x0274, // W being id, W health
GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position, B speed] [, W*2 destination] }*
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // B direction
@@ -220,6 +221,8 @@ enum {
CPMSG_PARTY_ACCEPT_INVITE_RESPONSE = 0x03A6, // B error
PCMSG_PARTY_QUIT = 0x03AA, // -
CPMSG_PARTY_QUIT_RESPONSE = 0x03AB, // B error
+ CPMSG_PARTY_NEW_MEMBER = 0x03B0, // W being id, S name
+ CPMSG_PARTY_MEMBER_LEFT = 0x03B1, // W being id
// Chat
CPMSG_ERROR = 0x0401, // B error