summaryrefslogtreecommitdiff
path: root/src/account-server/serverhandler.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-07-07 14:07:11 +0000
committerDavid Athay <ko2fan@gmail.com>2008-07-07 14:07:11 +0000
commit833586f7e321443f86d4b857e762786a3ece440a (patch)
tree88fe682c734063fefdafc3852501f94813700165 /src/account-server/serverhandler.cpp
parent6d073b16ac9cfaf431baa6ddef7554fa65a99d4e (diff)
downloadmanaserv-833586f7e321443f86d4b857e762786a3ece440a.tar.gz
manaserv-833586f7e321443f86d4b857e762786a3ece440a.tar.bz2
manaserv-833586f7e321443f86d4b857e762786a3ece440a.tar.xz
manaserv-833586f7e321443f86d4b857e762786a3ece440a.zip
Added party support between account and game servers.
Diffstat (limited to 'src/account-server/serverhandler.cpp')
-rw-r--r--src/account-server/serverhandler.cpp222
1 files changed, 7 insertions, 215 deletions
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index 14a9efc1..7fc81100 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -324,170 +324,6 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
}
} break;
-#if 0
- case GAMSG_GUILD_CREATE:
- {
- LOG_DEBUG("GAMSG_GUILD_CREATE");
-
- result.writeShort(AGMSG_GUILD_CREATE_RESPONSE);
- // Check if the guild name is taken already
- int playerId = msg.readLong();
- std::string guildName = msg.readString();
- if (guildManager->findByName(guildName) != NULL)
- {
- result.writeByte(ERRMSG_ALREADY_TAKEN);
- break;
- }
- result.writeByte(ERRMSG_OK);
-
- Storage &store = Storage::instance("tmw");
- CharacterPtr ptr = store.getCharacter(playerId);
-
- // Add guild to character data.
- ptr->addGuild(guildName);
-
- // Who to send data to at the other end
- result.writeLong(playerId);
-
- short guildId = guildManager->createGuild(guildName, ptr.get());
- result.writeShort(guildId);
- result.writeString(guildName);
- result.writeShort(1);
- enterChannel(guildName, ptr.get());
- } break;
-
- case GAMSG_GUILD_INVITE:
- {
- // Add Inviting member to guild here
- LOG_DEBUG("Received msg ... GAMSG_GUILD_INVITE");
- result.writeShort(AGMSG_GUILD_INVITE_RESPONSE);
- // Check if user can invite users
- int playerId = msg.readLong();
- short id = msg.readShort();
- std::string member = msg.readString();
- Guild *guild = guildManager->findById(id);
-
- Storage &store = Storage::instance("tmw");
- CharacterPtr ptr = store.getCharacter(playerId);
-
- if (!guild->checkLeader(ptr.get()))
- {
- // Return that the user doesnt have the rights to invite.
- result.writeByte(ERRMSG_INSUFFICIENT_RIGHTS);
- break;
- }
-
- if (guild->checkInGuild(member))
- {
- // Return that invited member already in guild.
- result.writeByte(ERRMSG_ALREADY_TAKEN);
- break;
- }
-
- // Send invite to player using chat server
- if (store.doesCharacterNameExist(member))
- {
- sendInvite(member, ptr->getName(), guild->getName());
- }
-
- guild->addInvited(member);
- result.writeByte(ERRMSG_OK);
- } break;
-
- case GAMSG_GUILD_ACCEPT:
- {
- // Add accepting into guild
- LOG_DEBUG("Received msg ... GAMSG_GUILD_ACCEPT");
- result.writeShort(AGMSG_GUILD_ACCEPT_RESPONSE);
- int playerId = msg.readLong();
- std::string guildName = msg.readString();
- Guild *guild = guildManager->findByName(guildName);
- if (!guild)
- {
- // Return the guild does not exist.
- result.writeByte(ERRMSG_INVALID_ARGUMENT);
- break;
- }
-
- Storage &store = Storage::instance("tmw");
- CharacterPtr ptr = store.getCharacter(playerId);
-
- if (!guild->checkInvited(ptr->getName()))
- {
- // Return the user was not invited.
- result.writeByte(ERRMSG_INSUFFICIENT_RIGHTS);
- break;
- }
-
- if (guild->checkInGuild(ptr->getName()))
- {
- // Return that the player is already in the guild.
- result.writeByte(ERRMSG_ALREADY_TAKEN);
- break;
- }
-
- result.writeByte(ERRMSG_OK);
-
- // Who to send data to at the other end
- result.writeLong(playerId);
-
- // The guild id and guild name they have joined
- result.writeShort(guild->getId());
- result.writeString(guildName);
-
- // Add member to guild
- guildManager->addGuildMember(guild->getId(), ptr.get());
-
- // Add guild to character
- ptr->addGuild(guildName);
-
- // Enter Guild Channel
- enterChannel(guildName, ptr.get());
- } break;
-
- case GAMSG_GUILD_GET_MEMBERS:
- {
- LOG_DEBUG("Received msg ... GAMSG_GUILD_GET_MEMBERS");
- result.writeShort(AGMSG_GUILD_GET_MEMBERS_RESPONSE);
- int playerId = msg.readLong();
- short guildId = msg.readShort();
- Guild *guild = guildManager->findById(guildId);
- if (!guild)
- {
- result.writeByte(ERRMSG_INVALID_ARGUMENT);
- break;
- }
- result.writeByte(ERRMSG_OK);
- result.writeLong(playerId);
- result.writeShort(guildId);
- for (std::list<std::string>::const_iterater itr = guild->getMembers()->begin();
- itr != guild->getMembers()->end(); ++itr)
- {
- result.writeString((*itr));
- }
- } break;
-
- case GAMSG_GUILD_QUIT:
- {
- LOG_DEBUG("Received msg ... GAMSG_GUILD_QUIT");
- result.writeShort(AGMSG_GUILD_QUIT_RESPONSE);
- int playerId = msg.readLong();
- short guildId = msg.readShort();
- Guild *guild = guildManager->findById(guildId);
- if (!guild)
- {
- result.writeByte(ERRMSG_INVALID_ARGUMENT);
- break;
- }
- Storage &store = Storage::instance("tmw");
- CharacterPtr ptr = store.getCharacter(playerId);
- guildManager->removeGuildMember(guildId, ptr.get());
- result.writeByte(ERRMSG_OK);
- result.writeLong(playerId);
- result.writeShort(guildId);
- } break;
-#endif
-
default:
LOG_WARN("ServerHandler::processMessage, Invalid message type: "
<< msg.getId());
@@ -528,58 +364,14 @@ void GameServerHandler::dumpStatistics(std::ostream &os)
}
}
-#if 0
-void ServerHandler::enterChannel(const std::string &name,
- CharacterData *player)
+void GameServerHandler::sendPartyChange(Character *ptr, int partyId)
{
- MessageOut result(CPMSG_ENTER_CHANNEL_RESPONSE);
-
- short channelId = chatChannelManager->getChannelId(name);
- ChatChannel *channel = chatChannelManager->getChannel(channelId);
-
- if (!channel)
- {
- // Channel doesn't exist yet so create one
- channelId = chatChannelManager->registerPrivateChannel(name,
- "Guild Channel",
- "");
- channel = chatChannelManager->getChannel(channelId);
- }
-
- if (channel && channel->addUser(player->getName()))
+ GameServer *s = ::getGameServerFromMap(ptr->getMapId());
+ if (s)
{
- result.writeByte(ERRMSG_OK);
-
- // The user entered the channel, now give him the channel id, the
- // announcement string and the user list.
- result.writeShort(channelId);
- result.writeString(name);
- result.writeString(channel->getAnnouncement());
- const ChatChannel::ChannelUsers &userList = channel->getUserList();
-
- for (ChatChannel::ChannelUsers::const_iterator i = userList.begin(),
- i_end = userList.end();
- i != i_end; ++i)
- {
- result.writeString(*i);
- }
-
- // Send an CPMSG_UPDATE_CHANNEL to warn other clients a user went
- // in the channel.
- chatHandler->warnUsersAboutPlayerEventInChat(channel,
- player->getName(),
- CHAT_EVENT_NEW_PLAYER);
-
+ MessageOut msg(CGMSG_CHANGED_PARTY);
+ msg.writeLong(ptr->getDatabaseID());
+ msg.writeLong(partyId);
+ s->send(msg);
}
-
- chatHandler->sendGuildEnterChannel(result, player->getName());
-}
-
-void ServerHandler::sendInvite(const std::string &invitedName,
- const std::string &inviterName,
- const std::string &guildName)
-{
- // TODO: Separate account and chat server
- chatHandler->sendGuildInvite(invitedName, inviterName, guildName);
}
-#endif