diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-30 18:04:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-30 18:04:08 +0300 |
commit | 19738d5a2d5d96aef78e51da99061a22d7cf15bb (patch) | |
tree | dced9aacaf48cf32d4a1d4a7399861c96aebc22c /src | |
parent | c96d089ab76316e5117c49e2ccdd3e9aab4bd29f (diff) | |
download | ManaVerse-19738d5a2d5d96aef78e51da99061a22d7cf15bb.tar.gz ManaVerse-19738d5a2d5d96aef78e51da99061a22d7cf15bb.tar.bz2 ManaVerse-19738d5a2d5d96aef78e51da99061a22d7cf15bb.tar.xz ManaVerse-19738d5a2d5d96aef78e51da99061a22d7cf15bb.zip |
Remove unused code from guildhandler.
Fix memory leak in guild class.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/guild.cpp | 22 | ||||
-rw-r--r-- | src/guild.h | 4 | ||||
-rw-r--r-- | src/net/ea/guildhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/guildhandler.h | 2 | ||||
-rw-r--r-- | src/net/guildhandler.h | 2 | ||||
-rw-r--r-- | src/net/manaserv/guildhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/manaserv/guildhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 23 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.h | 13 |
10 files changed, 43 insertions, 38 deletions
diff --git a/src/client.cpp b/src/client.cpp index 6611d3dcf..68f31bd27 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -29,6 +29,7 @@ #include "emoteshortcut.h" #include "event.h" #include "game.h" +#include "guild.h" #include "graphicsvertexes.h" #include "itemshortcut.h" #include "keyboardconfig.h" @@ -71,6 +72,7 @@ #include "net/charhandler.h" #include "net/gamehandler.h" #include "net/generalhandler.h" +#include "net/guildhandler.h" #include "net/logindata.h" #include "net/loginhandler.h" #include "net/net.h" @@ -851,7 +853,9 @@ int Client::exec() if (resman) resman->cleanOrphans(); Party::clearParties(); + Guild::clearGuilds(); Net::getNpcHandler()->clearDialogs(); + Net::getGuildHandler()->clear(); Net::getPartyHandler()->clear(); } diff --git a/src/guild.cpp b/src/guild.cpp index ec8baee03..b84602858 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -71,6 +71,11 @@ Guild::Guild(short id): guilds[id] = this; } +Guild::~Guild() +{ + clearMembers(); +} + GuildMember *Guild::addMember(int accountId, int charId, const std::string &name) { @@ -305,7 +310,9 @@ Guild *Guild::getGuild(short id) if (it != guilds.end()) return it->second; - return new Guild(id); + Guild *guild = new Guild(id); + guilds[id] = guild; + return guild; } std::string Guild::getPos(int id) const @@ -320,4 +327,15 @@ std::string Guild::getPos(int id) const void Guild::sort() { std::sort(mMembers.begin(), mMembers.end(), guildSorter); -}
\ No newline at end of file +} + +void Guild::clearGuilds() +{ + GuildMap::iterator it = guilds.begin(); + while (it != guilds.end()) + { + delete (*it).second; + ++ it; + } + guilds.clear(); +} diff --git a/src/guild.h b/src/guild.h index 39ca42188..7986eb5d3 100644 --- a/src/guild.h +++ b/src/guild.h @@ -65,6 +65,8 @@ protected: class Guild : public AvatarListModel { public: + ~Guild(); + /** * Set the guild's name. */ @@ -179,6 +181,8 @@ public: int getEmblemId() { return mEmblemId; } + static void clearGuilds(); + private: typedef std::map<int, Guild*> GuildMap; static GuildMap guilds; diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index cf0e19b36..163fed401 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -587,4 +587,9 @@ void GuildHandler::processGuildBroken(Net::MessageIn &msg) msg.readInt32(); // Flag } +void GuildHandler::clear() +{ + taGuild = 0; +} + } // namespace Ea diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 7c516c61b..06edb2e89 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -104,6 +104,8 @@ class GuildHandler : public Net::GuildHandler virtual void processGuildBroken(Net::MessageIn &msg); + void clear(); + protected: bool showBasicInfo; }; diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h index d5556074c..4070abad5 100644 --- a/src/net/guildhandler.h +++ b/src/net/guildhandler.h @@ -70,6 +70,8 @@ class GuildHandler virtual void changeNotice(int guildId, std::string msg1, std::string msg2) = 0; + + virtual void clear() = 0; }; } diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index 354b96762..dc3dbc616 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -358,4 +358,8 @@ void GuildHandler::changeNotice(int guildId A_UNUSED, // TODO } +void GuildHandler::clear() +{ +} + } // namespace ManaServ diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h index 11fc2dfdb..023e60b08 100644 --- a/src/net/manaserv/guildhandler.h +++ b/src/net/manaserv/guildhandler.h @@ -76,6 +76,8 @@ public: void changeNotice(int guildId, std::string msg1, std::string msg2); + void clear(); + protected: void joinedGuild(Net::MessageIn &msg); }; diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index cbb32c3c8..43583971f 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -311,24 +311,6 @@ void GuildHandler::changeMemberPostion(GuildMember *member, int level) msg.writeInt32(level); // pos } -void GuildHandler::requestAlliance(int guildId A_UNUSED, - int otherGuildId A_UNUSED) -{ - // TODO -} - -void GuildHandler::requestAllianceResponse(int guildId A_UNUSED, - int otherGuildId A_UNUSED, - bool response A_UNUSED) -{ - // TODO -} - -void GuildHandler::endAlliance(int guildId A_UNUSED, int otherGuildId A_UNUSED) -{ - // TODO -} - void GuildHandler::changeNotice(int guildId, std::string msg1, std::string msg2) { @@ -338,9 +320,4 @@ void GuildHandler::changeNotice(int guildId, std::string msg1, msg.writeString(msg2, 120); // msg2 } -bool GuildHandler::isSupported() -{ - return true; -} - } // namespace TmwAthena diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index 58bfa2b0c..d8a1cc9e7 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -68,20 +68,7 @@ class GuildHandler : public Ea::GuildHandler, public MessageHandler void changeMemberPostion(GuildMember *member, int level); - void requestAlliance(int guildId, int otherGuildId); - - void requestAllianceResponse(int guildId, int otherGuildId, - bool response); - - void endAlliance(int guildId, int otherGuildId); - void changeNotice(int guildId, std::string msg1, std::string msg2); - - bool isSupported(); - - private: - // TmwAthena (and eAthena) only supports one guild per player -// Guild *mGuild; }; extern Ea::GuildTab *guildTab; |