mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Add new command line argument 'serverType'
ServerType allows to override the ServerType at runtime refs #872
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c260af7b11
commit
1401b2f956
@@ -117,7 +117,10 @@ namespace BlackCore
|
||||
clientKey = CBuildConfig::vatsimPrivateKey();
|
||||
}
|
||||
|
||||
VatServerType serverType = CBuildConfig::isVatsimVersion() ? vatServerVatsim : vatServerLegacyFsd;
|
||||
VatServerType serverType;
|
||||
bool success = getCmdLineServerType(serverType);
|
||||
if(!success) { serverType = CBuildConfig::isVatsimVersion() ? vatServerVatsim : vatServerLegacyFsd; }
|
||||
|
||||
m_net.reset(Vat_CreateNetworkSession(serverType, sApp->swiftVersionChar(),
|
||||
CVersion::versionMajor(), CVersion::versionMinor(),
|
||||
"None", clientId, clientKey.toLocal8Bit().constData(),
|
||||
@@ -683,8 +686,11 @@ namespace BlackCore
|
||||
static const QList<QCommandLineOption> opts
|
||||
{
|
||||
QCommandLineOption({ "idAndKey", "clientIdAndKey" },
|
||||
QCoreApplication::translate("application", "Client id and key pair separated by ':', e.g. <id>:<key>."),
|
||||
"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")
|
||||
};
|
||||
|
||||
// only in not officially shipped versions
|
||||
@@ -704,6 +710,23 @@ 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");
|
||||
|
||||
@@ -121,8 +121,9 @@ namespace BlackCore
|
||||
//! Cmd. line options this library can handle
|
||||
static const QList<QCommandLineOption> &getCmdLineOptions();
|
||||
|
||||
//! Client id and key if any from command line arguments
|
||||
private:
|
||||
bool getCmdLineClientIdAndKey(int &id, QString &key) const;
|
||||
bool getCmdLineServerType(VatServerType &serverType) const;
|
||||
|
||||
private slots:
|
||||
void replyToFrequencyQuery(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
Reference in New Issue
Block a user