mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 17:30:12 +08:00
[FSD] Overload prevention
* only allow aircraft to be added based on new positions, NOT on received ICAO data anymore * hardcoded max.range Discussion: https://discordapp.com/channels/539048679160676382/539925070550794240/643163521999306832
This commit is contained in:
committed by
Mat Sutcliffe
parent
911b23e29d
commit
857d5eb005
@@ -822,6 +822,8 @@ namespace BlackCore
|
|||||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
||||||
if (CBuildConfig::isLocalDeveloperDebugBuild()) { BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); }
|
if (CBuildConfig::isLocalDeveloperDebugBuild()) { BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); }
|
||||||
if (!callsign.isValid()) { return; }
|
if (!callsign.isValid()) { return; }
|
||||||
|
if (!this->isAircraftInRange(callsign)) { return; } // FSD overload issue, do not do anything if unknown
|
||||||
|
|
||||||
const ReverseLookupLogging reverseLookupEnabled = this->isReverseLookupMessagesEnabled();
|
const ReverseLookupLogging reverseLookupEnabled = this->isReverseLookupMessagesEnabled();
|
||||||
CStatusMessageList reverseLookupMessages;
|
CStatusMessageList reverseLookupMessages;
|
||||||
CStatusMessageList *pReverseLookupMessages = reverseLookupEnabled.testFlag(RevLogEnabled) ? &reverseLookupMessages : nullptr;
|
CStatusMessageList *pReverseLookupMessages = reverseLookupEnabled.testFlag(RevLogEnabled) ? &reverseLookupMessages : nullptr;
|
||||||
@@ -1104,15 +1106,20 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* FSD overload issue, do NOT to add new aircraft other than from positions
|
||||||
const CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao, livery, modelString, modelType, log);
|
const CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao, livery, modelString, modelType, log);
|
||||||
const CSimulatedAircraft initAircraft(model);
|
const CSimulatedAircraft initAircraft(model);
|
||||||
this->addNewAircraftInRange(initAircraft);
|
this->addNewAircraftInRange(initAircraft);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return aircraft;
|
return aircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAirspaceMonitor::onAircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
|
void CAirspaceMonitor::onAircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
|
||||||
{
|
{
|
||||||
|
static constexpr int MaxDistanceNM = 125;
|
||||||
|
static constexpr int MaxDistanceNMHysteresis = qRound(1.1 * MaxDistanceNM);
|
||||||
|
|
||||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");
|
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");
|
||||||
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
if (!this->isConnectedAndNotShuttingDown()) { return; }
|
||||||
|
|
||||||
@@ -1120,6 +1127,16 @@ namespace BlackCore
|
|||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Empty callsign");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Empty callsign");
|
||||||
|
|
||||||
if (this->isCopilotAircraft(callsign)) { return; }
|
if (this->isCopilotAircraft(callsign)) { return; }
|
||||||
|
const bool existsInRange = this->isAircraftInRange(callsign);
|
||||||
|
|
||||||
|
// hardcoded range (FSD overload issue)
|
||||||
|
const int distanceNM = this->getOwnAircraft().calculateGreatCircleDistance(situation).valueInteger(CLengthUnit::NM());
|
||||||
|
if (existsInRange && distanceNM > MaxDistanceNMHysteresis)
|
||||||
|
{
|
||||||
|
this->removeClient(callsign);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (distanceNM > MaxDistanceNM) { return; }
|
||||||
|
|
||||||
// update client info
|
// update client info
|
||||||
this->autoAdjustCientGndCapability(situation);
|
this->autoAdjustCientGndCapability(situation);
|
||||||
@@ -1127,11 +1144,10 @@ namespace BlackCore
|
|||||||
// store situation history
|
// store situation history
|
||||||
this->storeAircraftSituation(situation); // updates situation
|
this->storeAircraftSituation(situation); // updates situation
|
||||||
|
|
||||||
const bool existsInRange = this->isAircraftInRange(callsign);
|
|
||||||
const bool hasFsInnPacket = m_tempFsInnPackets.contains(callsign);
|
|
||||||
|
|
||||||
if (!existsInRange)
|
if (!existsInRange)
|
||||||
{
|
{
|
||||||
|
const bool hasFsInnPacket = m_tempFsInnPackets.contains(callsign);
|
||||||
|
|
||||||
CSimulatedAircraft aircraft;
|
CSimulatedAircraft aircraft;
|
||||||
aircraft.setCallsign(callsign);
|
aircraft.setCallsign(callsign);
|
||||||
aircraft.setSituation(situation);
|
aircraft.setSituation(situation);
|
||||||
|
|||||||
@@ -643,14 +643,14 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
AuthResponse pduAuthResponse(m_ownCallsign.asString(), "SERVER", response);
|
AuthResponse pduAuthResponse(m_ownCallsign.asString(), "SERVER", response);
|
||||||
sendMessage(pduAuthResponse);
|
sendMessage(pduAuthResponse);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendAuthResponse"));
|
increaseStatisticsValue(QStringLiteral("sendAuthResponse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFSDClient::sendPong(const QString &receiver, const QString ×tamp)
|
void CFSDClient::sendPong(const QString &receiver, const QString ×tamp)
|
||||||
{
|
{
|
||||||
const Pong pong(m_ownCallsign.asString(), receiver, timestamp);
|
const Pong pong(m_ownCallsign.asString(), receiver, timestamp);
|
||||||
sendMessage(pong);
|
sendMessage(pong);
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendPong"));
|
increaseStatisticsValue(QStringLiteral("sendPong"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFSDClient::sendClientResponse(ClientQueryType queryType, const QString &receiver)
|
void CFSDClient::sendClientResponse(ClientQueryType queryType, const QString &receiver)
|
||||||
@@ -664,22 +664,14 @@ namespace BlackCore
|
|||||||
else if (queryType == ClientQueryType::Capabilities)
|
else if (queryType == ClientQueryType::Capabilities)
|
||||||
{
|
{
|
||||||
responseData.clear();
|
responseData.clear();
|
||||||
if (m_capabilities & Capabilities::AtcInfo)
|
if (m_capabilities & Capabilities::AtcInfo) responseData.push_back(toQString(Capabilities::AtcInfo) % "=1");
|
||||||
responseData.push_back(toQString(Capabilities::AtcInfo) % "=1");
|
if (m_capabilities & Capabilities::SecondaryPos) responseData.push_back(toQString(Capabilities::SecondaryPos) % "=1");
|
||||||
if (m_capabilities & Capabilities::SecondaryPos)
|
if (m_capabilities & Capabilities::AircraftInfo) responseData.push_back(toQString(Capabilities::AircraftInfo) % "=1");
|
||||||
responseData.push_back(toQString(Capabilities::SecondaryPos) % "=1");
|
if (m_capabilities & Capabilities::OngoingCoord) responseData.push_back(toQString(Capabilities::OngoingCoord) % "=1");
|
||||||
if (m_capabilities & Capabilities::AircraftInfo)
|
if (m_capabilities & Capabilities::InterminPos) responseData.push_back(toQString(Capabilities::InterminPos) % "=1");
|
||||||
responseData.push_back(toQString(Capabilities::AircraftInfo) % "=1");
|
if (m_capabilities & Capabilities::FastPos) responseData.push_back(toQString(Capabilities::FastPos) % "=1");
|
||||||
if (m_capabilities & Capabilities::OngoingCoord)
|
if (m_capabilities & Capabilities::Stealth) responseData.push_back(toQString(Capabilities::Stealth) % "=1");
|
||||||
responseData.push_back(toQString(Capabilities::OngoingCoord) % "=1");
|
if (m_capabilities & Capabilities::AircraftConfig) responseData.push_back(toQString(Capabilities::AircraftConfig) % "=1");
|
||||||
if (m_capabilities & Capabilities::InterminPos)
|
|
||||||
responseData.push_back(toQString(Capabilities::InterminPos) % "=1");
|
|
||||||
if (m_capabilities & Capabilities::FastPos)
|
|
||||||
responseData.push_back(toQString(Capabilities::FastPos) % "=1");
|
|
||||||
if (m_capabilities & Capabilities::Stealth)
|
|
||||||
responseData.push_back(toQString(Capabilities::Stealth) % "=1");
|
|
||||||
if (m_capabilities & Capabilities::AircraftConfig)
|
|
||||||
responseData.push_back(toQString(Capabilities::AircraftConfig) % "=1");
|
|
||||||
const ClientResponse clientResponse(m_ownCallsign.asString(), receiver, ClientQueryType::Capabilities, responseData);
|
const ClientResponse clientResponse(m_ownCallsign.asString(), receiver, ClientQueryType::Capabilities, responseData);
|
||||||
sendMessage(clientResponse);
|
sendMessage(clientResponse);
|
||||||
}
|
}
|
||||||
@@ -713,12 +705,10 @@ namespace BlackCore
|
|||||||
else if (queryType == ClientQueryType::ATIS)
|
else if (queryType == ClientQueryType::ATIS)
|
||||||
{
|
{
|
||||||
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::ATIS)));
|
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::ATIS)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (queryType == ClientQueryType::PublicIP)
|
else if (queryType == ClientQueryType::PublicIP)
|
||||||
{
|
{
|
||||||
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::PublicIP)));
|
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::PublicIP)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (queryType == ClientQueryType::INF)
|
else if (queryType == ClientQueryType::INF)
|
||||||
{
|
{
|
||||||
@@ -743,12 +733,10 @@ namespace BlackCore
|
|||||||
else if (queryType == ClientQueryType::FP)
|
else if (queryType == ClientQueryType::FP)
|
||||||
{
|
{
|
||||||
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::FP)));
|
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::FP)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (queryType == ClientQueryType::AircraftConfig)
|
else if (queryType == ClientQueryType::AircraftConfig)
|
||||||
{
|
{
|
||||||
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::AircraftConfig)));
|
this->handleIllegalFsdState(QStringLiteral("Dont send '%1' as pilot client!").arg(toQString(ClientQueryType::AircraftConfig)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this->increaseStatisticsValue(QStringLiteral("sendClientResponse"), toQString(queryType));
|
this->increaseStatisticsValue(QStringLiteral("sendClientResponse"), toQString(queryType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ namespace BlackCore
|
|||||||
case ClientQueryType::INF: return "INF";
|
case ClientQueryType::INF: return "INF";
|
||||||
case ClientQueryType::FP: return "FP";
|
case ClientQueryType::FP: return "FP";
|
||||||
case ClientQueryType::AircraftConfig: return "ACC";
|
case ClientQueryType::AircraftConfig: return "ACC";
|
||||||
case ClientQueryType::Unknown: qFatal("Don't serialize ClientQueryType::Unknown!");
|
case ClientQueryType::Unknown: return "Unknown query type";
|
||||||
}
|
}
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
Reference in New Issue
Block a user