mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T259, Ref T243 automatically update client gnd. capability by situation
Rational: If we receive a gnd flag from network, the client does have this capability
This commit is contained in:
@@ -792,9 +792,11 @@ namespace BlackCore
|
|||||||
const CCallsign callsign(situation.getCallsign());
|
const CCallsign callsign(situation.getCallsign());
|
||||||
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Empty callsign");
|
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Empty callsign");
|
||||||
|
|
||||||
|
// update client info
|
||||||
|
this->autoAdjustCientGndCapability(situation);
|
||||||
|
|
||||||
// store situation history
|
// store situation history
|
||||||
CAircraftSituation fullSituation(situation);
|
this->storeAircraftSituation(situation); // updates situation
|
||||||
this->storeAircraftSituation(fullSituation);
|
|
||||||
|
|
||||||
const bool existsInRange = this->isAircraftInRange(callsign);
|
const bool existsInRange = this->isAircraftInRange(callsign);
|
||||||
const bool hasFsInnPacket = m_tempFsInnPackets.contains(callsign);
|
const bool hasFsInnPacket = m_tempFsInnPackets.contains(callsign);
|
||||||
@@ -803,7 +805,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
CSimulatedAircraft aircraft;
|
CSimulatedAircraft aircraft;
|
||||||
aircraft.setCallsign(callsign);
|
aircraft.setCallsign(callsign);
|
||||||
aircraft.setSituation(fullSituation);
|
aircraft.setSituation(situation);
|
||||||
aircraft.setTransponder(transponder);
|
aircraft.setTransponder(transponder);
|
||||||
this->addNewAircraftInRange(aircraft);
|
this->addNewAircraftInRange(aircraft);
|
||||||
this->sendInitialPilotQueries(callsign, true, !hasFsInnPacket);
|
this->sendInitialPilotQueries(callsign, true, !hasFsInnPacket);
|
||||||
@@ -817,9 +819,9 @@ namespace BlackCore
|
|||||||
// update, aircraft already exists
|
// update, aircraft already exists
|
||||||
CPropertyIndexVariantMap vm;
|
CPropertyIndexVariantMap vm;
|
||||||
vm.addValue(CSimulatedAircraft::IndexTransponder, transponder);
|
vm.addValue(CSimulatedAircraft::IndexTransponder, transponder);
|
||||||
vm.addValue(CSimulatedAircraft::IndexSituation, fullSituation);
|
vm.addValue(CSimulatedAircraft::IndexSituation, situation);
|
||||||
vm.addValue(CSimulatedAircraft::IndexRelativeDistance, this->calculateDistanceToOwnAircraft(fullSituation));
|
vm.addValue(CSimulatedAircraft::IndexRelativeDistance, this->calculateDistanceToOwnAircraft(situation));
|
||||||
vm.addValue(CSimulatedAircraft::IndexRelativeBearing, this->calculateBearingToOwnAircraft(fullSituation));
|
vm.addValue(CSimulatedAircraft::IndexRelativeBearing, this->calculateBearingToOwnAircraft(situation));
|
||||||
this->updateAircraftInRange(callsign, vm);
|
this->updateAircraftInRange(callsign, vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "clientprovider.h"
|
#include "clientprovider.h"
|
||||||
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
@@ -83,6 +84,24 @@ namespace BlackMisc
|
|||||||
return m_clients.removeByCallsign(callsign);
|
return m_clients.removeByCallsign(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IClientProvider::autoAdjustCientGndCapability(const CAircraftSituation &situation)
|
||||||
|
{
|
||||||
|
if (situation.getCallsign().isEmpty()) { return false; } // no callsign
|
||||||
|
if (!situation.isOnGround()) { return false; } // nothing to adjust
|
||||||
|
if (situation.getOnGroundDetails() != CAircraftSituation::InFromNetwork) { return false; } // not from network
|
||||||
|
|
||||||
|
CClient client = this->getClientOrDefaultForCallsign(situation.getCallsign());
|
||||||
|
|
||||||
|
// need to change?
|
||||||
|
if (!client.isValid()) { return false; } // no client
|
||||||
|
if (client.hasGndFlagCapability()) { return false; } // already set
|
||||||
|
|
||||||
|
client.addCapability(CClient::FsdWithGroundFlag);
|
||||||
|
QWriteLocker l(&m_lockClient);
|
||||||
|
m_clients.replaceOrAddObjectByCallsign(client);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
CClientList CClientAware::getClients() const
|
CClientList CClientAware::getClients() const
|
||||||
{
|
{
|
||||||
if (this->provider()) { return this->provider()->getClients(); }
|
if (this->provider()) { return this->provider()->getClients(); }
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
namespace Aviation { class CAircraftSituation; }
|
||||||
namespace Network
|
namespace Network
|
||||||
{
|
{
|
||||||
//! Direct in memory access to client (network client) data
|
//! Direct in memory access to client (network client) data
|
||||||
@@ -61,6 +62,10 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
int removeClient(const Aviation::CCallsign &callsign);
|
int removeClient(const Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
|
//! Adjust gnd.flag capability from situation
|
||||||
|
//! \threadsafe
|
||||||
|
bool autoAdjustCientGndCapability(const Aviation::CAircraftSituation &situation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CClientList m_clients;
|
CClientList m_clients;
|
||||||
mutable QReadWriteLock m_lockClient; //!< lock clients: m_clients
|
mutable QReadWriteLock m_lockClient; //!< lock clients: m_clients
|
||||||
|
|||||||
Reference in New Issue
Block a user