diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-13 00:47:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-13 00:47:33 +0300 |
commit | 68a06297d94c0a2780b0bbb4070813f931cdfc24 (patch) | |
tree | efc4f1227231c4d6e72d7d315f23a3405ddb63fd /src/client.cpp | |
parent | a18645643144058d67301435505a506e36e0aa6b (diff) | |
download | manaplus-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.gz manaplus-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.bz2 manaplus-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.xz manaplus-68a06297d94c0a2780b0bbb4070813f931cdfc24.zip |
fix resource files unloading while switching servers.
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp index cb17f4919..705670277 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -300,7 +300,8 @@ Client::Client(const Options &options) : mSkin(nullptr), mButtonPadding(1), mButtonSpacing(3), - mKeyboardHeight(0) + mKeyboardHeight(0), + mOldUpdates() { mInstance = this; @@ -1205,8 +1206,34 @@ int Client::gameExec() switch (mState) { case STATE_CHOOSE_SERVER: + { BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER") logger->log1("State: CHOOSE SERVER"); + const ResourceManager *const resman + = ResourceManager::getInstance(); + if (mOptions.dataPath.empty()) + { + // Add customdata directory + resman->searchAndRemoveArchives( + "customdata/", + "zip"); + } + + if (!mOldUpdates.empty()) + { + UpdaterWindow::unloadUpdates(mOldUpdates); + mOldUpdates.clear(); + } + + if (!mOptions.skipUpdate) + { + resman->searchAndRemoveArchives( + mUpdatesDir + "/local/", + "zip"); + + resman->removeFromSearchPath(mLocalDataDir + dirSeparator + + mUpdatesDir + "/local/"); + } loginData.clearUpdateHost(); serverVersion = 0; @@ -1235,6 +1262,7 @@ int Client::gameExec() } BLOCK_END("Client::gameExec STATE_CHOOSE_SERVER") break; + } case STATE_CONNECT_SERVER: BLOCK_START("Client::gameExec STATE_CONNECT_SERVER") @@ -1330,6 +1358,7 @@ int Client::gameExec() case STATE_UPDATE: BLOCK_START("Client::gameExec STATE_UPDATE") + logger->log1("State: UPDATE"); // Determine which source to use for the update host if (!mOptions.updateHost.empty()) mUpdateHost = mOptions.updateHost; @@ -1337,22 +1366,29 @@ int Client::gameExec() mUpdateHost = loginData.updateHost; initUpdatesDir(); + if (!mOldUpdates.empty()) + UpdaterWindow::unloadUpdates(mOldUpdates); + if (mOptions.skipUpdate) { mState = STATE_LOAD_DATA; + mOldUpdates = ""; } else if (loginData.updateType & LoginData::Upd_Skip) { - UpdaterWindow::loadLocalUpdates(mLocalDataDir - + dirSeparator + mUpdatesDir); + mOldUpdates = mLocalDataDir + + dirSeparator + mUpdatesDir; + UpdaterWindow::loadLocalUpdates(mOldUpdates); mState = STATE_LOAD_DATA; } else { - logger->log1("State: UPDATE"); + mOldUpdates = mLocalDataDir + + dirSeparator + mUpdatesDir; mCurrentDialog = new UpdaterWindow(mUpdateHost, - mLocalDataDir + dirSeparator + mUpdatesDir, - mOptions.dataPath.empty(), loginData.updateType); + mOldUpdates, + mOptions.dataPath.empty(), + loginData.updateType); } BLOCK_END("Client::gameExec STATE_UPDATE") break; |