summaryrefslogtreecommitdiff
path: root/src/gui/windows/updaterwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows/updaterwindow.cpp')
-rw-r--r--src/gui/windows/updaterwindow.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 948ce5a17..f15263d09 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -1,11 +1,11 @@
/*
- * The ManaPlus Client
+ * The ManaVerse Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2023 The ManaVerse Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
*
- * This file is part of The ManaPlus Client.
+ * This file is part of The ManaVerse Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,6 +53,7 @@
#include "utils/delete2.h"
#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/performance.h"
#include <sys/stat.h>
@@ -430,11 +431,11 @@ void UpdaterWindow::loadNews()
mScrollArea->setVerticalScrollAmount(0);
}
-void UpdaterWindow::loadPatch()
+void UpdaterWindow::checkClientVersion()
{
if (mMemoryBuffer == nullptr)
{
- logger->log1("Couldn't load patch");
+ logger->log1("Couldn't check client version: null buffer");
return;
}
@@ -443,13 +444,17 @@ void UpdaterWindow::loadPatch()
realloc(mMemoryBuffer, mDownloadedBytes + 1));
if (mMemoryBuffer == nullptr)
{
- logger->log1("Couldn't load patch");
+ logger->log1("Couldn't check client version: null buffer");
return;
}
mMemoryBuffer[mDownloadedBytes] = '\0';
std::string version;
+ // The version check file (latest.txt) is composed of two lines:
+ // first, the "machine readable" version (for alphanumeric comparison)
+ // and second, the human readable version, to be displayed.
+
// Tokenize and add each line separately
char *line = strtok(mMemoryBuffer, "\n");
if (line != nullptr)
@@ -460,6 +465,8 @@ void UpdaterWindow::loadPatch()
line = strtok(nullptr, "\n");
if (line != nullptr)
{
+ // if you wonder why this line is above the one below, it's
+ // because add to top is true.
mBrowserBox->addRow(strprintf("##9 Latest client version: "
"##6ManaVerse %s##0", line), true);
}
@@ -470,7 +477,7 @@ void UpdaterWindow::loadPatch()
#if defined(ANDROID)
const std::string url = "androidDownloadUrl";
const std::string text = "androidDownloadUrl";
-#elif defined(WIN32)
+#elif defined(_WIN32)
const std::string url = "windowsDownloadUrl";
const std::string text = "windowsDownloadUrl";
#else // defined(ANDROID)
@@ -588,15 +595,16 @@ void UpdaterWindow::download()
if (mDownloadStatus == UpdateDownloadStatus::UPDATE_PATCH)
{
mDownload = new Net::Download(this,
- branding.getStringValue("updateMirror1") + mCurrentFile,
+ urlJoin(branding.getStringValue("updateMirror1"), mCurrentFile),
&updateProgress,
true, false, mValidateXml);
+
for (int f = 2; f < 8; f ++)
{
const std::string url = branding.getStringValue(
"updateMirror" + toString(f));
if (!url.empty())
- mDownload->addMirror(url + mCurrentFile);
+ mDownload->addMirror(urlJoin(url, mCurrentFile));
}
}
else
@@ -610,17 +618,16 @@ void UpdaterWindow::download()
mDownloadStatus == UpdateDownloadStatus::UPDATE_RESOURCES2)
{
const std::string str = urlJoin(mUpdateServerPath, mCurrentFile);
- mDownload->addMirror(updateServer3 + str);
- mDownload->addMirror(updateServer4 + str);
- mDownload->addMirror(updateServer5 + str);
+ mDownload->addMirror(urlJoin(updateServer3, str));
+ mDownload->addMirror(urlJoin(updateServer4, str));
+ mDownload->addMirror(urlJoin(updateServer5, str));
}
else
{
const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mirrors)
{
- mDownload->addMirror(pathJoin(*it,
- mCurrentFile));
+ mDownload->addMirror(urlJoin(*it, mCurrentFile));
}
}
}
@@ -825,10 +832,9 @@ void UpdaterWindow::logic()
case UpdateDownloadStatus::UPDATE_PATCH:
if (mDownloadComplete)
{
- // Parse current memory buffer as news and dispose of the data
- loadPatch();
+ checkClientVersion();
- mUpdateHost = updateServer2 + mUpdateServerPath;
+ mUpdateHost = urlJoin(updateServer2, mUpdateServerPath);
mUpdatesDir = pathJoin(mUpdatesDir, "fix");
mCurrentFile = xmlUpdateFile;
mValidateXml = true;