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:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "clientprovider.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
@@ -83,6 +84,24 @@ namespace BlackMisc
|
||||
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
|
||||
{
|
||||
if (this->provider()) { return this->provider()->getClients(); }
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation { class CAircraftSituation; }
|
||||
namespace Network
|
||||
{
|
||||
//! Direct in memory access to client (network client) data
|
||||
@@ -61,6 +62,10 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
int removeClient(const Aviation::CCallsign &callsign);
|
||||
|
||||
//! Adjust gnd.flag capability from situation
|
||||
//! \threadsafe
|
||||
bool autoAdjustCientGndCapability(const Aviation::CAircraftSituation &situation);
|
||||
|
||||
private:
|
||||
CClientList m_clients;
|
||||
mutable QReadWriteLock m_lockClient; //!< lock clients: m_clients
|
||||
|
||||
Reference in New Issue
Block a user