From e3291f999cd8e3d42abf278374d754e93bd32236 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 19 Oct 2016 17:06:25 +0200 Subject: [PATCH] Fixed: When incrementing version of ini file, check servers by ID not by index --- .../client/ryzom_installer/src/configfile.cpp | 20 +++++++++--- .../client/ryzom_installer/src/server.cpp | 32 +++++++++++++++++++ .../tools/client/ryzom_installer/src/server.h | 8 +++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 08b485773..6dadeb5cd 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -114,16 +114,26 @@ bool CConfigFile::load(const QString &filename) settings.endGroup(); // only resize if added servers in local ryzom_installer.ini - int oldServersCount = m_servers.size(); + CServers defaultServers = m_servers; - if (serversCount > oldServersCount) m_servers.resize(serversCount); + m_servers.resize(serversCount); - for (int i = oldServersCount; i < serversCount; ++i) + for (int i = 0; i < serversCount; ++i) { + settings.beginGroup(QString("server_%1").arg(i)); + CServer &server = m_servers[i]; - settings.beginGroup(QString("server_%1").arg(i)); - server.loadFromSettings(settings); + if (useDefaultValues) + { + // search server with same ID and use these values + server.loadFromServers(defaultServers); + } + else + { + server.loadFromSettings(settings); + } + settings.endGroup(); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/server.cpp b/code/ryzom/tools/client/ryzom_installer/src/server.cpp index 88932fa0c..9514c8df9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/server.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/server.cpp @@ -52,6 +52,38 @@ void CServer::loadFromSettings(const QSettings &settings) comments = settings.value("comments").toString(); } +void CServer::loadFromServers(const CServers &servers) +{ + foreach(const CServer &server, servers) + { + if (server.id == id) + { + // found the same server + loadFromServer(server); + break; + } + } +} + +void CServer::loadFromServer(const CServer &server) +{ + // copy all members + id = server.id; + name = server.name; + displayUrl = server.displayUrl; + filesListUrl = server.filesListUrl; + dataDownloadUrl = server.dataDownloadUrl; + dataDownloadFilename = server.dataDownloadFilename; + dataCompressedSize = server.dataCompressedSize; + dataUncompressedSize = server.dataUncompressedSize; + clientDownloadUrl = server.clientDownloadUrl; + clientDownloadFilename = server.clientDownloadFilename; + clientFilename = server.clientFilename; + clientFilenameOld = server.clientFilenameOld; + configurationFilename = server.configurationFilename; + comments = server.comments; +} + void CServer::saveToSettings(QSettings &settings) const { settings.setValue("id", id); diff --git a/code/ryzom/tools/client/ryzom_installer/src/server.h b/code/ryzom/tools/client/ryzom_installer/src/server.h index 33fbbb49e..afde10b55 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/server.h +++ b/code/ryzom/tools/client/ryzom_installer/src/server.h @@ -19,6 +19,10 @@ #include "operation.h" +class CServer; + +typedef QVector CServers; + class CServer { public: @@ -44,6 +48,8 @@ public: QString comments; void loadFromSettings(const QSettings &settings); + void loadFromServers(const CServers &servers); + void loadFromServer(const CServer &server); void saveToSettings(QSettings &settings) const; // helpers @@ -55,6 +61,4 @@ public: extern const CServer NoServer; -typedef QVector CServers; - #endif