From 8615f1bbad630602009c04a317cd83e03aaa620c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 3 Jun 2010 14:12:42 -0600 Subject: Unload loaded DBs before loading them again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This greatly simplifies handling DBs when changing states. No more need to manage unloading in Client (except when exiting). Reviewed-by: Thorbjørn Lindeijer --- src/statuseffect.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/statuseffect.cpp') diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 49619f8a..6ab0b8fa 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -32,6 +32,8 @@ #define STATUS_EFFECTS_FILE "status-effects.xml" +bool StatusEffect::mLoaded = false; + StatusEffect::StatusEffect() : mPersistentParticleEffect(false) {} @@ -113,6 +115,9 @@ StatusEffect *StatusEffect::getStunEffect(int index, bool enabling) void StatusEffect::load() { + if (mLoaded) + unload(); + XML::Document doc(STATUS_EFFECTS_FILE); xmlNodePtr rootNode = doc.rootNode(); @@ -175,8 +180,13 @@ void unloadMap(std::map map) void StatusEffect::unload() { + if (!mLoaded) + return; + unloadMap(statusEffects[0]); unloadMap(statusEffects[1]); unloadMap(stunEffects[0]); unloadMap(stunEffects[1]); + + mLoaded = false; } -- cgit v1.2.3-60-g2f50