From afc816e3001104653982de25099fcc634d7ed686 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 May 2010 01:08:59 +0300 Subject: Allow start game if update server is down. Small code style changes. Signed-off-by: Jared Adams --- src/gui/updatewindow.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 975fdcff..7448a102 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -45,6 +45,9 @@ #include #include +const std::string xmlUpdateFile = "resources.xml"; +const std::string txtUpdateFile = "resources2.txt"; + /** * Load the given file into a vector of updateFiles. */ @@ -72,13 +75,10 @@ std::vector loadXMLFile(const std::string &fileName) file.type = XML::getProperty(fileNode, "type", "data"); file.desc = XML::getProperty(fileNode, "description", ""); if (XML::getProperty(fileNode, "required", "yes") == "yes") - { file.required = true; - } else - { file.required = false; - } + files.push_back(file); } @@ -344,7 +344,8 @@ void UpdaterWindow::download() { if (mDownloadStatus == UPDATE_RESOURCES) { - mDownload->setFile(mUpdatesDir + "/" + mCurrentFile, mCurrentChecksum); + mDownload->setFile(mUpdatesDir + "/" + mCurrentFile, + mCurrentChecksum); } else { @@ -353,9 +354,7 @@ void UpdaterWindow::download() } if (mDownloadStatus != UPDATE_RESOURCES) - { mDownload->noCache(); - } setLabel(mCurrentFile + " (0%)"); mDownloadComplete = false; @@ -368,9 +367,22 @@ void UpdaterWindow::loadUpdates() { ResourceManager *resman = ResourceManager::getInstance(); + if (!mUpdateFiles.size()) + { // updates not downloaded + mUpdateFiles = loadXMLFile(mUpdatesDir + "/" + xmlUpdateFile); + if (!mUpdateFiles.size()) + { + logger->log("Warning this server does not have a" + " %s file falling back to %s", xmlUpdateFile.c_str(), + txtUpdateFile.c_str()); + mUpdateFiles = loadTxtFile(mUpdatesDir + "/" + txtUpdateFile); + } + } + for (mUpdateIndex = 0; mUpdateIndex < mUpdateFiles.size(); mUpdateIndex++) { - resman->addToSearchPath(mUpdatesDir + "/" + mUpdateFiles[mUpdateIndex].name, false); + resman->addToSearchPath(mUpdatesDir + "/" + + mUpdateFiles[mUpdateIndex].name, false); } } @@ -433,7 +445,9 @@ void UpdaterWindow::logic() mUpdateFiles = loadXMLFile(mUpdatesDir + "/" + xmlUpdateFile); if (mUpdateFiles.size() == 0) { - logger->log("Warning this server does not have a %s file falling back to %s",xmlUpdateFile.c_str(),txtUpdateFile.c_str()); + logger->log("Warning this server does not have a %s" + " file falling back to %s", + xmlUpdateFile.c_str(), txtUpdateFile.c_str()); // If the resources.xml file fails, fall back onto a older version mCurrentFile = txtUpdateFile; -- cgit v1.2.3-70-g09d2