From 19738d5a2d5d96aef78e51da99061a22d7cf15bb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 30 Jul 2011 18:04:08 +0300 Subject: Remove unused code from guildhandler. Fix memory leak in guild class. --- src/guild.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/guild.cpp') 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(); +} -- cgit v1.2.3-70-g09d2