summaryrefslogtreecommitdiffstats
path: root/src/chat-server
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2011-05-30 23:18:00 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2011-05-30 23:18:00 +0200
commit0e04885bcef86a571a0c3069b4706422f9af2566 (patch)
tree1702fff382fae7ff64be7423ee349e0eb2780224 /src/chat-server
parent406be26dd7a12795a4a2702aabe2ef46a5e0a6bb (diff)
downloadmanaserv-0e04885bcef86a571a0c3069b4706422f9af2566.tar.gz
manaserv-0e04885bcef86a571a0c3069b4706422f9af2566.tar.xz
manaserv-0e04885bcef86a571a0c3069b4706422f9af2566.zip
Routing party invite through the map server
The player sends party invites to the game server. If the invitee is within the visual range of the inviter, the game server forwards the invite to the chat server. Reviewed-by: Bjorn, Jaxad0127
Diffstat (limited to 'src/chat-server')
-rw-r--r--src/chat-server/chathandler.cpp4
-rw-r--r--src/chat-server/chathandler.h3
-rw-r--r--src/chat-server/partyhandler.cpp52
3 files changed, 27 insertions, 32 deletions
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index 73eede6..1f6cfdb 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -227,10 +227,6 @@ void ChatHandler::processMessage(NetComputer *comp, MessageIn &message)
handleGuildQuit(computer, message);
break;
- case PCMSG_PARTY_INVITE:
- handlePartyInvite(computer, message);
- break;
-
case PCMSG_PARTY_ACCEPT_INVITE:
handlePartyAcceptInvite(computer, message);
break;
diff --git a/src/chat-server/chathandler.h b/src/chat-server/chathandler.h
index 392f053..c969a9a 100644
--- a/src/chat-server/chathandler.h
+++ b/src/chat-server/chathandler.h
@@ -101,6 +101,8 @@ class ChatHandler : public ConnectionHandler
const std::string &characterName,
char eventId);
+ void handlePartyInvite(MessageIn &msg);
+
protected:
/**
* Process chat related messages.
@@ -162,7 +164,6 @@ class ChatHandler : public ConnectionHandler
void handleGuildKickMember(ChatClient &client, MessageIn &msg);
void handleGuildQuit(ChatClient &client, MessageIn &msg);
- void handlePartyInvite(ChatClient &client, MessageIn &msg);
void handlePartyAcceptInvite(ChatClient &client, MessageIn &msg);
void handlePartyQuit(ChatClient &client);
// TODO: Merge with handlePartyAcceptInvite?
diff --git a/src/chat-server/partyhandler.cpp b/src/chat-server/partyhandler.cpp
index 52eb89a..4086275 100644
--- a/src/chat-server/partyhandler.cpp
+++ b/src/chat-server/partyhandler.cpp
@@ -87,43 +87,41 @@ bool ChatHandler::handlePartyJoin(const std::string &invited, const std::string
}
-void ChatHandler::handlePartyInvite(ChatClient &client, MessageIn &msg)
+void ChatHandler::handlePartyInvite(MessageIn &msg)
{
- //TODO: Handle errors
- MessageOut out(CPMSG_PARTY_INVITED);
+ std::string inviterName = msg.readString();
+ std::string inviteeName = msg.readString();
+ ChatClient *inviter = getClient(inviterName);
+
+ if (!inviter)
+ return;
- out.writeString(client.characterName);
+ ChatClient *invitee = getClient(inviteeName);
- const std::string invited = msg.readString();
- if (invited == client.characterName)
+ if (!invitee)
{
+ // TODO: Send error message
return;
}
- if (!invited.empty())
- {
- // Get client and send it the invite
- ChatClient *c = getClient(invited);
- if (c)
- {
- ++client.numInvites;
- // TODO: Check number of invites
- // and do something if too many in a short time
+ ++invitee->numInvites;
+ // TODO: Check number of invites
+ // and do something if too many in a short time
- // store the invite
- PartyInvite invite;
- invite.mInvited = invited;
- invite.mInviter = client.characterName;
- if (client.party)
- invite.mPartyId = client.party->getId();
- else
- invite.mPartyId = 0;
+ // store the invite
+ PartyInvite invite;
+ invite.mInvited = inviteeName;
+ invite.mInviter = inviterName;
+ if (inviter->party)
+ invite.mPartyId = inviter->party->getId();
+ else
+ invite.mPartyId = 0;
- mPartyInvitedUsers.push_back(invite);
+ mPartyInvitedUsers.push_back(invite);
- c->send(out);
- }
- }
+ MessageOut out(CPMSG_PARTY_INVITED);
+ out.writeString(inviterName);
+ invitee->send(out);
}
void ChatHandler::handlePartyAcceptInvite(ChatClient &client, MessageIn &msg)