From 45c326a733cf4b5bf4f5da47100b2791c3863ba8 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:20:20 +0200 Subject: [PATCH] Changed: Keep other servers when upgrading ryzom_installer.ini --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index bbd399b97..b09fa4e44 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -106,22 +106,25 @@ bool CConfigFile::load(const QString &filename) m_productHelpUrl = settings.value("url_help").toString(); m_productComments = settings.value("comments").toString(); settings.endGroup(); + } - settings.beginGroup("servers"); - int serversCount = settings.value("size").toInt(); - m_defaultServerIndex = settings.value("default").toInt(); + settings.beginGroup("servers"); + int serversCount = settings.value("size").toInt(); + m_defaultServerIndex = settings.value("default").toInt(); + settings.endGroup(); + + // only resize if added servers in local ryzom_installer.ini + int oldServersCount = m_servers.size(); + + if (serversCount > oldServersCount) m_servers.resize(serversCount); + + for (int i = oldServersCount; i < serversCount; ++i) + { + CServer &server = m_servers[i]; + + settings.beginGroup(QString("server_%1").arg(i)); + server.loadFromSettings(settings); settings.endGroup(); - - m_servers.resize(serversCount); - - for (int i = 0; i < serversCount; ++i) - { - CServer &server = m_servers[i]; - - settings.beginGroup(QString("server_%1").arg(i)); - server.loadFromSettings(settings); - settings.endGroup(); - } } // custom choices, always keep them