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/guild.cpp | |
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/guild.cpp')
-rw-r--r-- | src/guild.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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(); +} |