diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-29 20:45:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-29 20:45:54 +0300 |
commit | 5b4160a49385bc6895681c5d103a4a5716829e4b (patch) | |
tree | 2b0119eef31a34b6345ce2b6f49ff8f0cfbca499 | |
parent | 085abf777701c8bdb3091084fe851b125e787ae1 (diff) | |
download | plus-5b4160a49385bc6895681c5d103a4a5716829e4b.tar.gz plus-5b4160a49385bc6895681c5d103a4a5716829e4b.tar.bz2 plus-5b4160a49385bc6895681c5d103a4a5716829e4b.tar.xz plus-5b4160a49385bc6895681c5d103a4a5716829e4b.zip |
Simplify remove listener calls.
-rw-r--r-- | src/actorspritemanager.cpp | 6 | ||||
-rw-r--r-- | src/client.cpp | 6 | ||||
-rw-r--r-- | src/configuration.cpp | 16 | ||||
-rw-r--r-- | src/configuration.h | 2 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 6 | ||||
-rw-r--r-- | src/gui/whoisonline.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 3 | ||||
-rw-r--r-- | src/localplayer.cpp | 11 | ||||
-rw-r--r-- | src/map.cpp | 4 | ||||
-rw-r--r-- | src/sound.cpp | 6 |
10 files changed, 22 insertions, 41 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 803a30e7e..758a452b1 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -203,11 +203,7 @@ ActorSpriteManager::ActorSpriteManager() : ActorSpriteManager::~ActorSpriteManager() { - config.removeListener("targetDeadPlayers", this); - config.removeListener("targetOnlyReachable", this); - config.removeListener("cyclePlayers", this); - config.removeListener("cycleMonsters", this); - config.removeListener("extMouseTargeting", this); + config.removeListeners(this); storeAttackList(); clear(); } diff --git a/src/client.cpp b/src/client.cpp index 0324bb8cc..95e49c6aa 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -707,11 +707,7 @@ void Client::gameClear() { if (logger) logger->log1("Quitting1"); - config.removeListener("fpslimit", this); - config.removeListener("guialpha", this); - config.removeListener("gamma", this); - config.removeListener("particleEmitterSkip", this); - config.removeListener("vsync", this); + config.removeListeners(this); SDL_RemoveTimer(mLogicCounterId); SDL_RemoveTimer(mSecondsCounterId); diff --git a/src/configuration.cpp b/src/configuration.cpp index 97540c385..624cf7865 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -617,14 +617,22 @@ void Configuration::write() xmlFreeTextWriter(writer); } -void Configuration::addListener( - const std::string &key, ConfigListener *listener) +void Configuration::addListener(const std::string &key, + ConfigListener *listener) { mListenerMap[key].push_front(listener); } -void Configuration::removeListener( - const std::string &key, ConfigListener *listener) +void Configuration::removeListener(const std::string &key, + ConfigListener *listener) { mListenerMap[key].remove(listener); } + +void Configuration::removeListeners(ConfigListener *listener) +{ + ListenerMapIterator it = mListenerMap.begin(); + ListenerMapIterator it_end = mListenerMap.end(); + for (; it != it_end; ++ it) + (it->second).remove(listener); +} diff --git a/src/configuration.h b/src/configuration.h index 122badfd5..2715ea59c 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -248,6 +248,8 @@ class Configuration : public ConfigurationObject */ void removeListener(const std::string &key, ConfigListener *listener); + void removeListeners(ConfigListener *listener); + void setValue(const std::string &key, const std::string &value); void setSilent(const std::string &key, const std::string &value); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1ef7b1cba..5c50836f6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -98,11 +98,7 @@ Viewport::Viewport(): Viewport::~Viewport() { - config.removeListener("ScrollLaziness", this); - config.removeListener("ScrollRadius", this); - config.removeListener("showBeingPopup", this); - config.removeListener("selfMouseHeal", this); - config.removeListener("enableLazyScrolling", this); + config.removeListeners(this); delete mPopupMenu; mPopupMenu = nullptr; diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index eba058bd7..734daa7a6 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -131,8 +131,7 @@ WhoIsOnline::WhoIsOnline(): WhoIsOnline::~WhoIsOnline() { - config.removeListener("updateOnlineList", this); - config.removeListener("groupFriends", this); + config.removeListeners(this); if (mThread && SDL_GetThreadID(mThread)) SDL_WaitThread(mThread, nullptr); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 822e71805..749837f7d 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -74,8 +74,7 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): AvatarListBox::~AvatarListBox() { - config.removeListener("showgender", this); - config.removeListener("showlevel", this); + config.removeListeners(this); instances--; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index f88423f8e..1acc6a938 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -205,17 +205,8 @@ LocalPlayer::~LocalPlayer() { logger->log1("LocalPlayer::~LocalPlayer"); - config.removeListener("showownname", this); - config.removeListener("targetDeadPlayers", this); + config.removeListeners(this); serverConfig.removeListener("enableBuggyServers", this); - config.removeListener("syncPlayerMove", this); - config.removeListener("drawPath", this); - config.removeListener("serverAttack", this); - config.removeListener("attackMoving", this); - config.removeListener("showJobExp", this); - config.removeListener("enableAdvert", this); - config.removeListener("tradebot", this); - config.removeListener("targetOnlyReachable", this); delete mAwayDialog; mAwayDialog = nullptr; diff --git a/src/map.cpp b/src/map.cpp index b8767e5e4..d983508b1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -177,9 +177,7 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): Map::~Map() { - config.removeListener("OverlayDetail", this); - config.removeListener("guialpha", this); - config.removeListener("beingopacity", this); + config.removeListeners(this); // delete metadata, layers, tilesets and overlays delete [] mMetaTiles; diff --git a/src/sound.cpp b/src/sound.cpp index 2c7ecb53d..5b7f1201d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -66,11 +66,7 @@ Sound::Sound(): Sound::~Sound() { - config.removeListener("playBattleSound", this); - config.removeListener("playGuiSound", this); - config.removeListener("playMusic", this); - config.removeListener("sfxVolume", this); - config.removeListener("musicVolume", this); + config.removeListeners(this); // Unlink the callback function. Mix_HookMusicFinished(nullptr); |