summaryrefslogtreecommitdiff
path: root/src/gui/windows/updaterwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-16 20:53:04 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-16 20:53:04 +0300
commitc39bbbafc43db2dfa17e970dfbd5e12ee1d7ceb7 (patch)
tree9ad28893c7948f79d3e01841f7f07086b636eb37 /src/gui/windows/updaterwindow.cpp
parent64519c3ffb855c4b6ff6f428ba29173217327306 (diff)
downloadmanaverse-c39bbbafc43db2dfa17e970dfbd5e12ee1d7ceb7.tar.gz
manaverse-c39bbbafc43db2dfa17e970dfbd5e12ee1d7ceb7.tar.bz2
manaverse-c39bbbafc43db2dfa17e970dfbd5e12ee1d7ceb7.tar.xz
manaverse-c39bbbafc43db2dfa17e970dfbd5e12ee1d7ceb7.zip
load mods from <mod> tag in resources.xml
Diffstat (limited to 'src/gui/windows/updaterwindow.cpp')
-rw-r--r--src/gui/windows/updaterwindow.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 5eebbaf13..584f8e90e 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -60,7 +60,8 @@ const std::string updateServer2
/**
* Load the given file into a vector of updateFiles.
*/
-static std::vector<UpdateFile> loadXMLFile(const std::string &fileName)
+static std::vector<UpdateFile> loadXMLFile(const std::string &fileName,
+ const bool loadMods)
{
std::vector<UpdateFile> files;
XML::Document doc(fileName, false);
@@ -74,11 +75,9 @@ static std::vector<UpdateFile> loadXMLFile(const std::string &fileName)
for_each_xml_child_node(fileNode, rootNode)
{
- if (!xmlNameEqual(fileNode, "update")
- && !xmlNameEqual(fileNode, "update2"))
- {
+ const bool isMod = xmlNameEqual(fileNode, "mod");
+ if (!xmlNameEqual(fileNode, "update") && !isMod)
continue;
- }
UpdateFile file;
file.name = XML::getProperty(fileNode, "file", "");
@@ -86,6 +85,9 @@ static std::vector<UpdateFile> loadXMLFile(const std::string &fileName)
file.type = XML::getProperty(fileNode, "type", "data");
file.desc = XML::getProperty(fileNode, "description", "");
file.group = XML::getProperty(fileNode, "group", "");
+ if (!file.group.empty() && (!isMod || !loadMods))
+ continue;
+
const std::string version = XML::getProperty(
fileNode, "version", "");
if (!version.empty())
@@ -562,7 +564,7 @@ void UpdaterWindow::loadUpdates()
if (mUpdateFiles.empty())
{ // updates not downloaded
mUpdateFiles = loadXMLFile(std::string(mUpdatesDir).append(
- "/").append(xmlUpdateFile));
+ "/").append(xmlUpdateFile), false);
if (mUpdateFiles.empty())
{
logger->log("Warning this server does not have a"
@@ -591,8 +593,8 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir)
{
const ResourceManager *const resman = ResourceManager::getInstance();
- std::vector<UpdateFile> updateFiles
- = loadXMLFile(std::string(dir).append("/").append(xmlUpdateFile));
+ std::vector<UpdateFile> updateFiles = loadXMLFile(
+ std::string(dir).append("/").append(xmlUpdateFile), false);
if (updateFiles.empty())
{
@@ -620,8 +622,8 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir)
void UpdaterWindow::unloadUpdates(const std::string &dir)
{
const ResourceManager *const resman = ResourceManager::getInstance();
- std::vector<UpdateFile> updateFiles
- = loadXMLFile(std::string(dir).append("/").append(xmlUpdateFile));
+ std::vector<UpdateFile> updateFiles = loadXMLFile(
+ std::string(dir).append("/").append(xmlUpdateFile), true);
if (updateFiles.empty())
{
@@ -643,8 +645,8 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir,
const ResourceManager *const resman)
{
std::string fixPath = dir + "/fix";
- std::vector<UpdateFile> updateFiles
- = loadXMLFile(std::string(fixPath).append("/").append(xmlUpdateFile));
+ std::vector<UpdateFile> updateFiles = loadXMLFile(
+ std::string(fixPath).append("/").append(xmlUpdateFile), false);
for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
updateFiles.size()); updateIndex < sz; updateIndex ++)
@@ -668,8 +670,8 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir,
const ResourceManager *const resman)
{
const std::string fixPath = dir + "/fix";
- const std::vector<UpdateFile> updateFiles
- = loadXMLFile(std::string(fixPath).append("/").append(xmlUpdateFile));
+ const std::vector<UpdateFile> updateFiles = loadXMLFile(
+ std::string(fixPath).append("/").append(xmlUpdateFile), true);
for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
updateFiles.size()); updateIndex < sz; updateIndex ++)
@@ -796,7 +798,7 @@ void UpdaterWindow::logic()
if (mCurrentFile == xmlUpdateFile)
{
mUpdateFiles = loadXMLFile(std::string(mUpdatesDir).append(
- "/").append(xmlUpdateFile));
+ "/").append(xmlUpdateFile), true);
if (mUpdateFiles.empty())
{
@@ -885,7 +887,7 @@ void UpdaterWindow::logic()
if (mCurrentFile == xmlUpdateFile)
{
mTempUpdateFiles = loadXMLFile(std::string(
- mUpdatesDir).append("/").append(xmlUpdateFile));
+ mUpdatesDir).append("/").append(xmlUpdateFile), true);
}
mUpdateIndexOffset = mUpdateIndex;
mUpdateIndex = 0;
@@ -1015,8 +1017,8 @@ void UpdaterWindow::loadMods(const std::string &dir,
}
}
- std::vector<UpdateFile> updateFiles2
- = loadXMLFile(std::string(fixPath).append("/").append(xmlUpdateFile));
+ std::vector<UpdateFile> updateFiles2 = loadXMLFile(
+ std::string(fixPath).append("/").append(xmlUpdateFile), true);
for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
updateFiles2.size()); updateIndex < sz; updateIndex ++)