mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
Set simulator info when connecting to network
This commit is contained in:
@@ -8,7 +8,7 @@ TEMPLATE = app
|
|||||||
|
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
CONFIG += blackmisc blackcore
|
CONFIG += blackmisc blackcore blacksim
|
||||||
|
|
||||||
DEPENDPATH += . ../../src
|
DEPENDPATH += . ../../src
|
||||||
INCLUDEPATH += . ../../src
|
INCLUDEPATH += . ../../src
|
||||||
@@ -17,9 +17,11 @@ SOURCES += *.cpp
|
|||||||
HEADERS += *.h
|
HEADERS += *.h
|
||||||
|
|
||||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||||
../../lib/blackcore.lib
|
../../lib/blackcore.lib \
|
||||||
|
../../lib/blacksim.lib
|
||||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||||
../../lib/libblackcore.a
|
../../lib/libblackcore.a \
|
||||||
|
../../lib/blacksim.a
|
||||||
|
|
||||||
DESTDIR = ../../bin
|
DESTDIR = ../../bin
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ using namespace BlackMisc::Network;
|
|||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Audio;
|
using namespace BlackMisc::Audio;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackSim;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -176,6 +177,14 @@ namespace BlackCore
|
|||||||
this->m_network->presetLoginMode(mode);
|
this->m_network->presetLoginMode(mode);
|
||||||
this->m_network->presetCallsign(ownAircraft.getCallsign());
|
this->m_network->presetCallsign(ownAircraft.getCallsign());
|
||||||
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo());
|
this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo());
|
||||||
|
if (getIContextSimulator())
|
||||||
|
{
|
||||||
|
this->m_network->presetSimulatorInfo(getIContextSimulator()->getSimulatorInfo());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_network->presetSimulatorInfo(CSimulatorInfo::UnspecifiedSim());
|
||||||
|
}
|
||||||
this->m_network->initiateConnection();
|
this->m_network->initiateConnection();
|
||||||
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection pending " + server.getAddress() + " " + QString::number(server.getPort()));
|
return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection pending " + server.getAddress() + " " + QString::number(server.getPort()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKCORE_NETWORK_H
|
#ifndef BLACKCORE_NETWORK_H
|
||||||
#define BLACKCORE_NETWORK_H
|
#define BLACKCORE_NETWORK_H
|
||||||
|
|
||||||
|
#include "blacksim/simulatorinfo.h"
|
||||||
#include "blackmisc/avaircraft.h"
|
#include "blackmisc/avaircraft.h"
|
||||||
#include "blackmisc/pqfrequency.h"
|
#include "blackmisc/pqfrequency.h"
|
||||||
#include "blackmisc/coordinategeodetic.h"
|
#include "blackmisc/coordinategeodetic.h"
|
||||||
@@ -177,6 +178,12 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
virtual void presetLoginMode(LoginMode mode) = 0;
|
virtual void presetLoginMode(LoginMode mode) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set simulator info before connecting.
|
||||||
|
* \pre Network must be disconnected when calling this function.
|
||||||
|
*/
|
||||||
|
virtual void presetSimulatorInfo(const BlackSim::CSimulatorInfo &simInfo) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Initiate a connection to the network server.
|
* Initiate a connection to the network server.
|
||||||
* \pre Network must be disconnected when calling this function.
|
* \pre Network must be disconnected when calling this function.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackSim;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -254,6 +255,15 @@ namespace BlackCore
|
|||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VatSimType CNetworkVatlib::convertToSimType(CSimulatorInfo &simInfo)
|
||||||
|
{
|
||||||
|
if (simInfo.isUnspecified()) { return vatSimTypeUnknown; }
|
||||||
|
if (CSimulatorInfo::FS9().isSameSimulator(simInfo)) { return vatSimTypeMSCFS; }
|
||||||
|
if (CSimulatorInfo::FSX().isSameSimulator(simInfo)) { return vatSimTypeMSCFS; }
|
||||||
|
if (CSimulatorInfo::XP().isSameSimulator(simInfo)) { return vatSimTypeXPLANE; }
|
||||||
|
return vatSimTypeUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
||||||
/********************************** INetwork slots ************************************/
|
/********************************** INetwork slots ************************************/
|
||||||
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
/********************************** * * * * * * * * * * * * * * * * * * * ************************************/
|
||||||
@@ -264,6 +274,12 @@ namespace BlackCore
|
|||||||
m_server = server;
|
m_server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNetworkVatlib::presetSimulatorInfo(const CSimulatorInfo &simInfo)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(isDisconnected(), "CNetworkVatlib", "Can't change server details while still connected");
|
||||||
|
m_simulatorInfo = simInfo;
|
||||||
|
}
|
||||||
|
|
||||||
void CNetworkVatlib::presetCallsign(const BlackMisc::Aviation::CCallsign &callsign)
|
void CNetworkVatlib::presetCallsign(const BlackMisc::Aviation::CCallsign &callsign)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(isDisconnected(), "CNetworkVatlib", "Can't change callsign while still connected");
|
Q_ASSERT_X(isDisconnected(), "CNetworkVatlib", "Can't change callsign while still connected");
|
||||||
@@ -318,7 +334,7 @@ namespace BlackCore
|
|||||||
info.callsign = callsign.data();
|
info.callsign = callsign.data();
|
||||||
info.name = name.data();
|
info.name = name.data();
|
||||||
info.rating = vatPilotRatingStudent; //TODO
|
info.rating = vatPilotRatingStudent; //TODO
|
||||||
info.simType = vatSimTypeMSFS98; //TODO
|
info.simType = convertToSimType(m_simulatorInfo);
|
||||||
Vat_SpecifyPilotLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(),
|
Vat_SpecifyPilotLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(),
|
||||||
toFSD(m_server.getUser().getId()),
|
toFSD(m_server.getUser().getId()),
|
||||||
toFSD(m_server.getUser().getPassword()),
|
toFSD(m_server.getUser().getPassword()),
|
||||||
@@ -856,7 +872,7 @@ namespace BlackCore
|
|||||||
default:
|
default:
|
||||||
case vatFlightTypeVFR: rules = BlackMisc::Aviation::CFlightPlan::VFR; break;
|
case vatFlightTypeVFR: rules = BlackMisc::Aviation::CFlightPlan::VFR; break;
|
||||||
case vatFlightTypeIFR: rules = BlackMisc::Aviation::CFlightPlan::IFR; break;
|
case vatFlightTypeIFR: rules = BlackMisc::Aviation::CFlightPlan::IFR; break;
|
||||||
// case Cvatlib_Network::fpRuleType_SVFR: rules = BlackMisc::Aviation::CFlightPlan::SVFR; break;
|
// case Cvatlib_Network::fpRuleType_SVFR: rules = BlackMisc::Aviation::CFlightPlan::SVFR; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cruiseAltString = cbvar_cast(cbvar)->fromFSD(fp->cruiseAltitude);
|
auto cruiseAltString = cbvar_cast(cbvar)->fromFSD(fp->cruiseAltitude);
|
||||||
@@ -868,7 +884,6 @@ namespace BlackCore
|
|||||||
BlackMisc::Aviation::CAltitude cruiseAlt;
|
BlackMisc::Aviation::CAltitude cruiseAlt;
|
||||||
cruiseAlt.parseFromString(cruiseAltString);
|
cruiseAlt.parseFromString(cruiseAltString);
|
||||||
|
|
||||||
|
|
||||||
QString depTimePlanned = QString("0000").append(QString::number(fp->departTime)).right(4);
|
QString depTimePlanned = QString("0000").append(QString::number(fp->departTime)).right(4);
|
||||||
QString depTimeActual = QString("0000").append(QString::number(fp->departTimeActual)).right(4);
|
QString depTimeActual = QString("0000").append(QString::number(fp->departTimeActual)).right(4);
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace BlackCore
|
|||||||
virtual void presetServer(const BlackMisc::Network::CServer &server) override;
|
virtual void presetServer(const BlackMisc::Network::CServer &server) override;
|
||||||
virtual void presetCallsign(const BlackMisc::Aviation::CCallsign &callsign) override;
|
virtual void presetCallsign(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||||
virtual void presetIcaoCodes(const BlackMisc::Aviation::CAircraftIcao &icao) override;
|
virtual void presetIcaoCodes(const BlackMisc::Aviation::CAircraftIcao &icao) override;
|
||||||
|
virtual void presetSimulatorInfo(const BlackSim::CSimulatorInfo &simInfo) override;
|
||||||
virtual void initiateConnection() override;
|
virtual void initiateConnection() override;
|
||||||
virtual void terminateConnection() override;
|
virtual void terminateConnection() override;
|
||||||
virtual void sendPing(const BlackMisc::Aviation::CCallsign &callsign) override;
|
virtual void sendPing(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||||
@@ -129,7 +130,8 @@ namespace BlackCore
|
|||||||
void initializeSession();
|
void initializeSession();
|
||||||
void changeConnectionStatus(VatConnectionStatus newStatus);
|
void changeConnectionStatus(VatConnectionStatus newStatus);
|
||||||
bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; }
|
bool isDisconnected() const { return m_status != vatStatusConnecting && m_status != vatStatusConnected; }
|
||||||
QString convertToUnicodeEscaped(const QString &str);
|
static QString convertToUnicodeEscaped(const QString &str);
|
||||||
|
static VatSimType convertToSimType(BlackSim::CSimulatorInfo &simInfo);
|
||||||
static void networkErrorHandler(const char *message);
|
static void networkErrorHandler(const char *message);
|
||||||
|
|
||||||
struct JsonPackets
|
struct JsonPackets
|
||||||
@@ -158,6 +160,7 @@ namespace BlackCore
|
|||||||
LoginMode m_loginMode;
|
LoginMode m_loginMode;
|
||||||
VatConnectionStatus m_status;
|
VatConnectionStatus m_status;
|
||||||
BlackMisc::Network::CServer m_server;
|
BlackMisc::Network::CServer m_server;
|
||||||
|
BlackSim::CSimulatorInfo m_simulatorInfo;
|
||||||
BlackMisc::Aviation::CCallsign m_callsign; //!< "buffered callsign", as this must not change when connected
|
BlackMisc::Aviation::CCallsign m_callsign; //!< "buffered callsign", as this must not change when connected
|
||||||
BlackMisc::Aviation::CAircraftIcao m_icaoCode; //!< "buffered icao", as this must not change when connected
|
BlackMisc::Aviation::CAircraftIcao m_icaoCode; //!< "buffered icao", as this must not change when connected
|
||||||
bool m_sendInterimPositions = false; //!< send interim positions
|
bool m_sendInterimPositions = false; //!< send interim positions
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackSim::CSimulatorInfo, (
|
|||||||
o.m_fullName,
|
o.m_fullName,
|
||||||
o.m_shortName,
|
o.m_shortName,
|
||||||
attr(o.m_simsetup, flags<DisabledForComparison>())
|
attr(o.m_simsetup, flags<DisabledForComparison>())
|
||||||
))
|
))
|
||||||
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
Q_DECLARE_METATYPE(BlackSim::CSimulatorInfo)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ TEMPLATE = app
|
|||||||
|
|
||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
CONFIG += blackmisc blackcore
|
CONFIG += blackmisc blackcore blacksim
|
||||||
CONFIG += testcase
|
CONFIG += testcase
|
||||||
|
|
||||||
DEPENDPATH += . ../../src
|
DEPENDPATH += . ../../src
|
||||||
@@ -18,9 +18,11 @@ HEADERS += *.h
|
|||||||
SOURCES += *.cpp
|
SOURCES += *.cpp
|
||||||
|
|
||||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||||
../../lib/blackcore.lib
|
../../lib/blackcore.lib \
|
||||||
|
../../lib/blacksim.lib
|
||||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||||
../../lib/libblackcore.a
|
../../lib/libblackcore.a \
|
||||||
|
../../lib/libblacksim.a
|
||||||
|
|
||||||
DESTDIR = ../../bin
|
DESTDIR = ../../bin
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user