Allow to select server type in FSD settings

Summary:
With this change the server type is a dynamic setting per server and
replaces the hardcoded global server type in CNetworkVatlib. This allows
the user to select the server type in settings ui and configures
the vatlib session accordingly.
This also removes the command line argument to set the server type since
it doesn't make sense anymore.

Reviewers: msutcliffe

Reviewed By: msutcliffe

Subscribers: jenkins

Differential Revision: https://dev.swift-project.org/D24
This commit is contained in:
Roland Winklmeier
2017-05-16 16:06:40 +02:00
parent f1f7ee4709
commit 5d1b5dba38
7 changed files with 157 additions and 111 deletions

View File

@@ -125,8 +125,11 @@ namespace BlackCore
}
VatServerType serverType;
bool success = getCmdLineServerType(serverType);
if (!success) { serverType = CBuildConfig::isVatsimVersion() ? vatServerVatsim : vatServerLegacyFsd; }
switch (m_server.getServerType())
{
case CServer::ServerVatsim: serverType = vatServerVatsim; break;
default: serverType = vatServerLegacyFsd; break;
}
m_net.reset(Vat_CreateNetworkSession(serverType, sApp->swiftVersionChar(),
CBuildConfig::getVersion().majorVersion(), CBuildConfig::getVersion().minorVersion(),
@@ -389,6 +392,10 @@ namespace BlackCore
void CNetworkVatlib::presetServer(const CServer &server)
{
Q_ASSERT_X(isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
// If the server type changed, we need to destroy the existing vatlib session
if (m_server.getServerType() != server.getServerType()) { m_net.reset(); }
m_server = server;
const QString codecName(server.getFsdSetup().getTextCodec());
Q_ASSERT_X(!codecName.isEmpty(), Q_FUNC_INFO, "Missing code name");
@@ -697,9 +704,7 @@ namespace BlackCore
static const QList<QCommandLineOption> opts
{
QCommandLineOption({ "idAndKey", "clientIdAndKey" },
QCoreApplication::translate("networkvatlib", "Client id and key pair separated by ':', e.g. <id>:<key>."), "clientIdAndKey"),
QCommandLineOption({ "s", "serverType" },
QCoreApplication::translate("networkvatlib", "FSD server type. Possible values: vatsim, fsd"), "serverType")
QCoreApplication::translate("networkvatlib", "Client id and key pair separated by ':', e.g. <id>:<key>."), "clientIdAndKey")
};
// only in not officially shipped versions
@@ -719,23 +724,6 @@ namespace BlackCore
return true;
}
bool CNetworkVatlib::getCmdLineServerType(VatServerType &serverType) const
{
QString serverTypeAsString = sApp->getParserValue("serverType").toLower();
if (QString::compare(serverTypeAsString, "vatsim", Qt::CaseInsensitive) == 0)
{
serverType = vatServerVatsim;
return true;
}
if (QString::compare(serverTypeAsString, "fsd", Qt::CaseInsensitive) == 0)
{
serverType = vatServerLegacyFsd;
return true;
}
return false;
}
void CNetworkVatlib::sendCustomFsinnQuery(const BlackMisc::Aviation::CCallsign &callsign)
{
Q_ASSERT_X(isConnected(), Q_FUNC_INFO, "Can't send to server when disconnected");

View File

@@ -128,7 +128,6 @@ namespace BlackCore
private:
bool getCmdLineClientIdAndKey(int &id, QString &key) const;
bool getCmdLineServerType(VatServerType &serverType) const;
private slots:
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);