summaryrefslogtreecommitdiff
path: root/src/gui/updaterwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-13 00:47:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-13 00:47:33 +0300
commit68a06297d94c0a2780b0bbb4070813f931cdfc24 (patch)
treeefc4f1227231c4d6e72d7d315f23a3405ddb63fd /src/gui/updaterwindow.cpp
parenta18645643144058d67301435505a506e36e0aa6b (diff)
downloadmv-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.gz
mv-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.bz2
mv-68a06297d94c0a2780b0bbb4070813f931cdfc24.tar.xz
mv-68a06297d94c0a2780b0bbb4070813f931cdfc24.zip
fix resource files unloading while switching servers.
Diffstat (limited to 'src/gui/updaterwindow.cpp')
-rw-r--r--src/gui/updaterwindow.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 197b97e3a..a29514994 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -594,6 +594,29 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir)
loadManaPlusUpdates(dir, resman);
}
+void UpdaterWindow::unloadUpdates(const std::string &dir)
+{
+ const ResourceManager *const resman = ResourceManager::getInstance();
+
+ std::vector<UpdateFile> updateFiles
+ = loadXMLFile(std::string(dir).append("/").append(xmlUpdateFile));
+
+ if (updateFiles.empty())
+ {
+ updateFiles = loadTxtFile(std::string(dir).append(
+ "/").append(txtUpdateFile));
+ }
+
+ std::string fixPath = dir + "/fix";
+ for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
+ updateFiles.size()); updateIndex < sz; updateIndex ++)
+ {
+ UpdaterWindow::removeUpdateFile(resman, dir, fixPath,
+ updateFiles[updateIndex].name);
+ }
+ unloadManaPlusUpdates(dir, resman);
+}
+
void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
const ResourceManager *const resman)
{
@@ -615,6 +638,27 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
}
}
+void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir,
+ const ResourceManager *const resman)
+{
+ std::string fixPath = dir + "/fix";
+ std::vector<UpdateFile> updateFiles
+ = loadXMLFile(std::string(fixPath).append("/").append(xmlUpdateFile));
+
+ for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
+ updateFiles.size()); updateIndex < sz; updateIndex ++)
+ {
+ std::string name = updateFiles[updateIndex].name;
+ if (strStartWith(name, "manaplus_"))
+ {
+ struct stat statbuf;
+ std::string file = std::string(fixPath).append("/").append(name);
+ if (!stat(file.c_str(), &statbuf))
+ resman->removeFromSearchPath(file);
+ }
+ }
+}
+
void UpdaterWindow::addUpdateFile(const ResourceManager *const resman,
const std::string &path,
const std::string &fixPath,
@@ -634,6 +678,18 @@ void UpdaterWindow::addUpdateFile(const ResourceManager *const resman,
resman->addToSearchPath(tmpPath, append);
}
+void UpdaterWindow::removeUpdateFile(const ResourceManager *const resman,
+ const std::string &path,
+ const std::string &fixPath,
+ const std::string &file)
+{
+ resman->removeFromSearchPath(std::string(path).append("/").append(file));
+ const std::string fixFile = std::string(fixPath).append("/").append(file);
+ struct stat statbuf;
+ if (!stat(fixFile.c_str(), &statbuf))
+ resman->removeFromSearchPath(fixFile);
+}
+
void UpdaterWindow::logic()
{
BLOCK_START("UpdaterWindow::logic")