mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
protocol type -MD added
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "blackcore/fsd/planeinformation.h"
|
||||
#include "blackcore/fsd/planeinforequestfsinn.h"
|
||||
#include "blackcore/fsd/planeinformationfsinn.h"
|
||||
#include "blackcore/fsd/revbclientparts.h"
|
||||
|
||||
#include "blackmisc/aviation/flightplan.h"
|
||||
#include "blackmisc/network/rawfsdmessage.h"
|
||||
@@ -907,6 +908,8 @@ namespace BlackCore
|
||||
// IVAO only
|
||||
// Ref: https://github.com/DemonRem/X-IvAP/blob/1b0a14880532a0f5c8fe84be44e462c6892a5596/src/XIvAp/FSDprotocol.h
|
||||
m_messageTypeMapping["!R"] = MessageType::RegistrationInfo;
|
||||
m_messageTypeMapping["-MD"] = MessageType::RevBClientParts;
|
||||
m_messageTypeMapping["-PD"] = MessageType::RevBPilotDescription; // not handled, to avoid error messages
|
||||
|
||||
// IVAO parts
|
||||
// https://discordapp.com/channels/539048679160676382/695961646992195644/707915838845485187
|
||||
@@ -1360,6 +1363,23 @@ namespace BlackCore
|
||||
if (serverError.isFatalError()) { disconnectFromServer(); }
|
||||
}
|
||||
|
||||
void CFSDClient::handleRevBClientPartsPacket(const QStringList &tokens)
|
||||
{
|
||||
CLogMessage(this).debug(u"handleRevBClientPartsPacket");
|
||||
|
||||
const RevBClientParts RevBClientParts = RevBClientParts::fromTokens(tokens);
|
||||
const CCallsign callsign(RevBClientParts.sender(), CCallsign::Aircraft);
|
||||
|
||||
const bool inRange = isAircraftInRange(callsign);
|
||||
|
||||
if (!inRange) { return; } // sort out all broadcasted we DO NOT NEED
|
||||
if (!getSetupForServer().receiveAircraftParts()) { return; }
|
||||
|
||||
const qint64 offsetTimeMs = currentOffsetTime(callsign);
|
||||
emit revbAircraftConfigReceived(RevBClientParts.sender(), RevBClientParts.m_partsval1, offsetTimeMs);
|
||||
CLogMessage(this).debug(u"Set Config at %1 ") << offsetTimeMs ;
|
||||
}
|
||||
|
||||
void CFSDClient::handleCustomPilotPacket(const QStringList &tokens)
|
||||
{
|
||||
const QString subType = tokens.at(2);
|
||||
@@ -1922,6 +1942,8 @@ namespace BlackCore
|
||||
case MessageType::ProController:
|
||||
case MessageType::ClientIdentification:
|
||||
case MessageType::RegistrationInfo:
|
||||
case MessageType::RevBPilotDescription:
|
||||
|
||||
break;
|
||||
|
||||
// handled ones
|
||||
@@ -1941,6 +1963,10 @@ namespace BlackCore
|
||||
case MessageType::ServerError: handleServerError(tokens); break;
|
||||
case MessageType::TextMessage: handleTextMessage(tokens); break;
|
||||
case MessageType::PilotClientCom: handleCustomPilotPacket(tokens); break;
|
||||
case MessageType::RevBClientParts: handleRevBClientPartsPacket(tokens); break;
|
||||
|
||||
|
||||
|
||||
|
||||
// normally we should not get here
|
||||
default:
|
||||
|
||||
@@ -219,6 +219,8 @@ namespace BlackCore
|
||||
void interimPilotDataUpdatedReceived(const BlackMisc::Aviation::CAircraftSituation &situation);
|
||||
void rawFsdMessage(const BlackMisc::Network::CRawFsdMessage &rawFsdMessage);
|
||||
void planeInformationFsinnReceived(const BlackMisc::Aviation::CCallsign &callsign, const QString &airlineIcaoDesignator, const QString &aircraftDesignator, const QString &combinedAircraftType, const QString &modelString);
|
||||
void revbAircraftConfigReceived(const QString &sender, const QString &config, qint64 currentOffsetTimeMs);
|
||||
|
||||
//! @}
|
||||
|
||||
//! We received a reply to one of our ATIS queries.
|
||||
@@ -361,6 +363,8 @@ namespace BlackCore
|
||||
void handleServerError(const QStringList &tokens);
|
||||
void handleCustomPilotPacket(const QStringList &tokens);
|
||||
void handleFsdIdentification(const QStringList &tokens);
|
||||
void handleRevBClientPartsPacket(const QStringList &tokens);
|
||||
|
||||
//
|
||||
void handleUnknownPacket(const QString &line);
|
||||
void handleUnknownPacket(const QStringList &tokens);
|
||||
|
||||
@@ -45,6 +45,8 @@ enum class MessageType
|
||||
RegistrationInfo, // IVAO only
|
||||
TextMessage,
|
||||
PilotClientCom,
|
||||
RevBClientParts, // IVAO only
|
||||
RevBPilotDescription, // -PD IVAO only not handled in swift
|
||||
};
|
||||
|
||||
namespace BlackCore
|
||||
|
||||
53
src/blackcore/fsd/revbclientparts.cpp
Normal file
53
src/blackcore/fsd/revbclientparts.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* Copyright (C) 2020
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "revbclientparts.h"
|
||||
#include "serializer.h"
|
||||
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Fsd
|
||||
{
|
||||
RevBClientParts::RevBClientParts()
|
||||
{ }
|
||||
|
||||
RevBClientParts::RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval2, const QString &partsval3)
|
||||
: MessageBase(sender),
|
||||
m_partsval1(partsval1),
|
||||
m_partsval2(partsval2),
|
||||
m_partsval3(partsval3)
|
||||
|
||||
{ }
|
||||
|
||||
QStringList RevBClientParts::toTokens() const
|
||||
{
|
||||
QStringList tokens;
|
||||
tokens.push_back(m_sender);
|
||||
tokens.push_back(m_partsval1);
|
||||
tokens.push_back(m_partsval2);
|
||||
tokens.push_back(m_partsval3);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
||||
RevBClientParts RevBClientParts::fromTokens(const QStringList &tokens)
|
||||
{
|
||||
if (tokens.size() < 4)
|
||||
{
|
||||
BlackMisc::CLogMessage(static_cast<RevBClientParts *>(nullptr)).debug(u"Wrong number of arguments.");
|
||||
return {};
|
||||
}
|
||||
return RevBClientParts(tokens[0], tokens[1], tokens[2], tokens[3]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
75
src/blackcore/fsd/revbclientparts.h
Normal file
75
src/blackcore/fsd/revbclientparts.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* Copyright (C) 2020
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_FSD_REVBCLIENTPARTS_H
|
||||
#define BLACKCORE_FSD_REVBCLIENTPARTS_H
|
||||
|
||||
#include "messagebase.h"
|
||||
#include "enums.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Fsd
|
||||
{
|
||||
//! This packet is used to translate client’s parts from RevB IVAO -MD.
|
||||
//! -MDMDN0104:262396:262396:262396
|
||||
//!
|
||||
class BLACKCORE_EXPORT RevBClientParts : public MessageBase
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
RevBClientParts(const QString &sender, const QString &partsval1, const QString &partsval3, const QString &partsval2);
|
||||
|
||||
|
||||
//! Message converted to tokens
|
||||
QStringList toTokens() const;
|
||||
|
||||
|
||||
//! Construct from tokens
|
||||
static RevBClientParts fromTokens(const QStringList &tokens);
|
||||
|
||||
//! PDU identifier
|
||||
static QString pdu() { return "-MD"; }
|
||||
|
||||
//! Properties @{
|
||||
ClientQueryType m_queryType = ClientQueryType::Unknown;
|
||||
QStringList m_queryData;
|
||||
//! @}
|
||||
|
||||
|
||||
//! Properties @{
|
||||
QString m_partsval1;
|
||||
QString m_partsval2;
|
||||
QString m_partsval3;
|
||||
//! @
|
||||
|
||||
private:
|
||||
RevBClientParts();
|
||||
};
|
||||
|
||||
//! Equal to operator
|
||||
inline bool operator==(const RevBClientParts &lhs, const RevBClientParts &rhs)
|
||||
{
|
||||
return lhs.sender() == rhs.sender() &&
|
||||
lhs.m_partsval1 == rhs.m_partsval1 &&
|
||||
lhs.m_partsval2 == rhs.m_partsval2 &&
|
||||
lhs.m_partsval3 == rhs.m_partsval3;
|
||||
}
|
||||
|
||||
//! Not equal to operator
|
||||
inline bool operator!=(const RevBClientParts &lhs, const RevBClientParts &rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user