diff options
author | Roderic Morris <roderic@ccs.neu.edu> | 2008-06-26 14:00:33 +0000 |
---|---|---|
committer | Roderic Morris <roderic@ccs.neu.edu> | 2008-06-26 14:00:33 +0000 |
commit | bb8623fa6e5584adeee6a613b3a28cb5550048d9 (patch) | |
tree | b8e980b14de4007fcd03f6cbc869d3c8e0d29ad2 /src | |
parent | 7250de62aa9b14697eb861e7c13978ba439a8f0c (diff) | |
download | manaserv-bb8623fa6e5584adeee6a613b3a28cb5550048d9.tar.gz manaserv-bb8623fa6e5584adeee6a613b3a28cb5550048d9.tar.bz2 manaserv-bb8623fa6e5584adeee6a613b3a28cb5550048d9.tar.xz manaserv-bb8623fa6e5584adeee6a613b3a28cb5550048d9.zip |
fix compile error, and improve guild related methods
Diffstat (limited to 'src')
-rw-r--r-- | src/account-server/serverhandler.cpp | 6 | ||||
-rw-r--r-- | src/chat-server/chathandler.cpp | 2 | ||||
-rw-r--r-- | src/chat-server/guild.cpp | 16 | ||||
-rw-r--r-- | src/chat-server/guild.hpp | 5 | ||||
-rw-r--r-- | src/chat-server/guildmanager.cpp | 4 | ||||
-rw-r--r-- | src/chat-server/guildmanager.hpp | 2 | ||||
-rw-r--r-- | src/scripting/lua.cpp | 2 |
7 files changed, 9 insertions, 28 deletions
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index f7c32245..14a9efc1 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -23,6 +23,7 @@ #include <cassert> #include <sstream> +#include <list> #include "account-server/serverhandler.hpp" @@ -459,9 +460,10 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) result.writeByte(ERRMSG_OK); result.writeLong(playerId); result.writeShort(guildId); - for (int i = 0; i < guild->totalMembers(); ++i) + for (std::list<std::string>::const_iterater itr = guild->getMembers()->begin(); + itr != guild->getMembers()->end(); ++itr) { - result.writeString(guild->getMember(i)); + result.writeString((*itr)); } } break; diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp index 907ec8fb..2523445c 100644 --- a/src/chat-server/chathandler.cpp +++ b/src/chat-server/chathandler.cpp @@ -788,7 +788,7 @@ void ChatHandler::sendGuildInvite(const std::string &invitedName, void ChatHandler::sendGuildRejoin(ChatClient &client) { // Get list of guilds and check what rights they have. - std::vector<Guild*> guilds = guildManager->getGuilds(client.characterName); + std::vector<Guild*> guilds = guildManager->getGuildsForPlayer(client.characterName); for (unsigned int i = 0; i != guilds.size(); ++i) { Guild *guild = guilds[i]; diff --git a/src/chat-server/guild.cpp b/src/chat-server/guild.cpp index 9da0f9a8..7a2a43d9 100644 --- a/src/chat-server/guild.cpp +++ b/src/chat-server/guild.cpp @@ -60,22 +60,6 @@ void Guild::addInvited(const std::string &playerName) mInvited.push_back(playerName); } -const std::string& Guild::getMember(int i) const -{ - const static std::string empty = ""; - int x = 0; - for (GuildMembers::const_iterator itr = mMembers.begin(); - itr != mMembers.end(); - ++itr, ++x) - { - if (x == i) - { - return (*itr); - } - } - return empty; -} - bool Guild::checkInGuild(const std::string &playerName) { return std::find(mMembers.begin(), mMembers.end(), playerName) != mMembers.end(); diff --git a/src/chat-server/guild.hpp b/src/chat-server/guild.hpp index 5d0be6bc..67a6817b 100644 --- a/src/chat-server/guild.hpp +++ b/src/chat-server/guild.hpp @@ -100,11 +100,6 @@ class Guild { return mMembers.size(); } /** - * Get a member in the guild. - */ - const std::string& getMember(int i) const; - - /** * Find member by name. */ bool checkInGuild(const std::string &playerName); diff --git a/src/chat-server/guildmanager.cpp b/src/chat-server/guildmanager.cpp index 8cb98b1a..95159175 100644 --- a/src/chat-server/guildmanager.cpp +++ b/src/chat-server/guildmanager.cpp @@ -123,7 +123,7 @@ bool GuildManager::doesExist(const std::string &name) return findByName(name) != NULL; } -std::vector<Guild*> GuildManager::getGuilds(const std::string &name) +std::vector<Guild*> GuildManager::getGuildsForPlayer(const std::string &name) { std::vector<Guild*> guildList; @@ -140,7 +140,7 @@ std::vector<Guild*> GuildManager::getGuilds(const std::string &name) void GuildManager::disconnectPlayer(ChatClient *player) { - std::vector<Guild*> guildList = getGuilds(player->characterName); + std::vector<Guild*> guildList = getGuildsForPlayer(player->characterName); for (std::vector<Guild*>::const_iterator itr = guildList.begin(); itr != guildList.end(); ++itr) diff --git a/src/chat-server/guildmanager.hpp b/src/chat-server/guildmanager.hpp index 2545afb4..97105fc8 100644 --- a/src/chat-server/guildmanager.hpp +++ b/src/chat-server/guildmanager.hpp @@ -91,7 +91,7 @@ class GuildManager /** * Return the guilds a character is in */ - std::vector<Guild*> getGuilds(const std::string &name); + std::vector<Guild*> getGuildsForPlayer(const std::string &name); /** * Inform guild members that a player has disconnected. diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index cb8e906c..ae9ff1b2 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -188,7 +188,7 @@ static int LuaNpc_Choice(lua_State *s) */ static int LuaNpc_Create(lua_State *s) { - if (!lua_isstring(s, 1), !lua_isnumber(s, 2) || !lua_isnumber(s, 3) || !lua_isnumber(s, 4)) + if (!lua_isstring(s, 1) || !lua_isnumber(s, 2) || !lua_isnumber(s, 3) || !lua_isnumber(s, 4)) { raiseScriptError(s, "npc_create called with incorrect parameters."); return 0; |