mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
[FSD] Send correct pilot rating, use threadsafe getters in some places
The thread safety is still premature for the FSD client class. However, most likely no critical as those values have to be preset and never change.
This commit is contained in:
committed by
Mat Sutcliffe
parent
000d0da92a
commit
388138203e
@@ -247,8 +247,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
this->updateConnectionStatus(CConnectionStatus::Connecting);
|
this->updateConnectionStatus(CConnectionStatus::Connecting);
|
||||||
|
|
||||||
const QString host = m_server.getAddress();
|
const CServer s = this->getServer();
|
||||||
const quint16 port = static_cast<quint16>(m_server.getPort());
|
const QString host = s.getAddress();
|
||||||
|
const quint16 port = static_cast<quint16>(s.getPort());
|
||||||
m_socket.connectToHost(host, port);
|
m_socket.connectToHost(host, port);
|
||||||
this->startPositionTimers();
|
this->startPositionTimers();
|
||||||
}
|
}
|
||||||
@@ -261,10 +262,11 @@ namespace BlackCore
|
|||||||
this->updateConnectionStatus(CConnectionStatus::Disconnecting);
|
this->updateConnectionStatus(CConnectionStatus::Disconnecting);
|
||||||
|
|
||||||
// allow also to close if broken
|
// allow also to close if broken
|
||||||
|
CLoginMode mode = this->getLoginMode();
|
||||||
if (m_socket.isOpen())
|
if (m_socket.isOpen())
|
||||||
{
|
{
|
||||||
if (m_loginMode.isPilot()) { this->sendDeletePilot(); }
|
if (mode.isPilot()) { this->sendDeletePilot(); }
|
||||||
else if (m_loginMode.isObserver()) { this->sendDeleteAtc(); }
|
else if (mode.isObserver()) { this->sendDeleteAtc(); }
|
||||||
}
|
}
|
||||||
m_socket.close();
|
m_socket.close();
|
||||||
|
|
||||||
@@ -274,18 +276,20 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CFSDClient::sendLogin()
|
void CFSDClient::sendLogin()
|
||||||
{
|
{
|
||||||
const QString cid = m_server.getUser().getId();
|
const CServer s = this->getServer();
|
||||||
const QString password = m_server.getUser().getPassword();
|
const QString cid = s.getUser().getId();
|
||||||
const QString name = m_server.getUser().getRealNameAndHomeBase(); // m_server.getUser().getRealName();
|
const QString password = s.getUser().getPassword();
|
||||||
|
const QString name = s.getUser().getRealNameAndHomeBase(); // m_server.getUser().getRealName();
|
||||||
const QString callsign = m_ownCallsign.asString();
|
const QString callsign = m_ownCallsign.asString();
|
||||||
|
|
||||||
if (m_loginMode.isPilot())
|
const CLoginMode m = this->getLoginMode();
|
||||||
|
if (m.isPilot())
|
||||||
{
|
{
|
||||||
const AddPilot pilotLogin(callsign, cid, password, m_pilotRating, m_protocolRevision, m_simType, name);
|
const AddPilot pilotLogin(callsign, cid, password, m_pilotRating, m_protocolRevision, m_simType, name);
|
||||||
sendQueudedMessage(pilotLogin);
|
sendQueudedMessage(pilotLogin);
|
||||||
CStatusMessage(this).info(u"Sending login as '%1' '%2' '%3' '%4' '%5' '%6'") << callsign << cid << toQString(m_pilotRating) << m_protocolRevision << toQString(m_simType) << name;
|
CStatusMessage(this).info(u"Sending login as '%1' '%2' '%3' '%4' '%5' '%6'") << callsign << cid << toQString(m_pilotRating) << m_protocolRevision << toQString(m_simType) << name;
|
||||||
}
|
}
|
||||||
else if (m_loginMode.isObserver())
|
else if (m.isObserver())
|
||||||
{
|
{
|
||||||
const AddAtc addAtc(callsign, name, cid, password, m_atcRating, m_protocolRevision);
|
const AddAtc addAtc(callsign, name, cid, password, m_atcRating, m_protocolRevision);
|
||||||
sendQueudedMessage(addAtc);
|
sendQueudedMessage(addAtc);
|
||||||
@@ -295,14 +299,14 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CFSDClient::sendDeletePilot()
|
void CFSDClient::sendDeletePilot()
|
||||||
{
|
{
|
||||||
const QString cid = m_server.getUser().getId();
|
const QString cid = this->getServer().getUser().getId();
|
||||||
const DeletePilot deletePilot(m_ownCallsign.getFsdCallsignString(), cid);
|
const DeletePilot deletePilot(m_ownCallsign.getFsdCallsignString(), cid);
|
||||||
sendQueudedMessage(deletePilot);
|
sendQueudedMessage(deletePilot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFSDClient::sendDeleteAtc()
|
void CFSDClient::sendDeleteAtc()
|
||||||
{
|
{
|
||||||
const QString cid = m_server.getUser().getId();
|
const QString cid = this->getServer().getUser().getId();
|
||||||
const DeleteAtc deleteAtc(getOwnCallsignAsString(), cid);
|
const DeleteAtc deleteAtc(getOwnCallsignAsString(), cid);
|
||||||
sendQueudedMessage(deleteAtc);
|
sendQueudedMessage(deleteAtc);
|
||||||
}
|
}
|
||||||
@@ -317,10 +321,11 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
PilotRating r = this->getPilotRating();
|
||||||
PilotDataUpdate pilotDataUpdate(myAircraft.getTransponderMode(),
|
PilotDataUpdate pilotDataUpdate(myAircraft.getTransponderMode(),
|
||||||
getOwnCallsignAsString(),
|
getOwnCallsignAsString(),
|
||||||
static_cast<qint16>(myAircraft.getTransponderCode()),
|
static_cast<qint16>(myAircraft.getTransponderCode()),
|
||||||
PilotRating::Unknown,
|
r,
|
||||||
myAircraft.latitude().value(CAngleUnit::deg()),
|
myAircraft.latitude().value(CAngleUnit::deg()),
|
||||||
myAircraft.longitude().value(CAngleUnit::deg()),
|
myAircraft.longitude().value(CAngleUnit::deg()),
|
||||||
myAircraft.getAltitude().valueInteger(CLengthUnit::ft()),
|
myAircraft.getAltitude().valueInteger(CLengthUnit::ft()),
|
||||||
|
|||||||
@@ -113,21 +113,32 @@ namespace BlackCore
|
|||||||
void setAtcRating(AtcRating rating) { QWriteLocker l(&m_lockUserClientBuffered); m_atcRating = rating; }
|
void setAtcRating(AtcRating rating) { QWriteLocker l(&m_lockUserClientBuffered); m_atcRating = rating; }
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
// ------ thread safe access to preset values -----
|
||||||
|
|
||||||
//! Get the server
|
//! Get the server
|
||||||
|
//! \threadsafe
|
||||||
const BlackMisc::Network::CServer &getServer() const { QReadLocker l(&m_lockUserClientBuffered); return m_server; }
|
const BlackMisc::Network::CServer &getServer() const { QReadLocker l(&m_lockUserClientBuffered); return m_server; }
|
||||||
|
|
||||||
//! List of all preset values
|
//! List of all preset values
|
||||||
|
//! \threadsafe
|
||||||
QStringList getPresetValues() const;
|
QStringList getPresetValues() const;
|
||||||
|
|
||||||
//! Callsign if any
|
//! Callsign if any
|
||||||
|
//! \threadsafe
|
||||||
BlackMisc::Aviation::CCallsign getPresetCallsign() const { QReadLocker l(&m_lockUserClientBuffered); return m_ownCallsign; }
|
BlackMisc::Aviation::CCallsign getPresetCallsign() const { QReadLocker l(&m_lockUserClientBuffered); return m_ownCallsign; }
|
||||||
|
|
||||||
//! Partner callsign if any
|
//! Partner callsign if any
|
||||||
|
//! \threadsafe
|
||||||
BlackMisc::Aviation::CCallsign getPresetPartnerCallsign() const { QReadLocker l(&m_lockUserClientBuffered); return m_partnerCallsign; }
|
BlackMisc::Aviation::CCallsign getPresetPartnerCallsign() const { QReadLocker l(&m_lockUserClientBuffered); return m_partnerCallsign; }
|
||||||
|
|
||||||
//! Mode
|
//! Mode
|
||||||
|
//! \threadsafe
|
||||||
BlackMisc::Network::CLoginMode getLoginMode() const { QReadLocker l(&m_lockUserClientBuffered); return m_loginMode; }
|
BlackMisc::Network::CLoginMode getLoginMode() const { QReadLocker l(&m_lockUserClientBuffered); return m_loginMode; }
|
||||||
|
|
||||||
|
//! Rating
|
||||||
|
//! \threadsafe
|
||||||
|
PilotRating getPilotRating() const { QReadLocker l(&m_lockUserClientBuffered); return m_pilotRating; }
|
||||||
|
|
||||||
//! Connenct/disconnect @{
|
//! Connenct/disconnect @{
|
||||||
void connectToServer();
|
void connectToServer();
|
||||||
void disconnectFromServer();
|
void disconnectFromServer();
|
||||||
|
|||||||
@@ -38,17 +38,17 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Properties @{
|
//! Properties @{
|
||||||
BlackMisc::Aviation::CTransponder::TransponderMode m_transponderMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
BlackMisc::Aviation::CTransponder::TransponderMode m_transponderMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||||
int m_transponderCode = 0;
|
int m_transponderCode = 0;
|
||||||
PilotRating m_rating = PilotRating::Unknown;
|
PilotRating m_rating = PilotRating::Unknown;
|
||||||
double m_latitude = 0.0;
|
double m_latitude = 0.0;
|
||||||
double m_longitude = 0.0;
|
double m_longitude = 0.0;
|
||||||
int m_altitudeTrue = 0.0;
|
int m_altitudeTrue = 0.0;
|
||||||
int m_altitudePressure = 0.0;
|
int m_altitudePressure = 0.0;
|
||||||
int m_groundSpeed = 0;
|
int m_groundSpeed = 0;
|
||||||
double m_pitch = 0.0;
|
double m_pitch = 0.0;
|
||||||
double m_bank = 0.0;
|
double m_bank = 0.0;
|
||||||
double m_heading = 0.0;
|
double m_heading = 0.0;
|
||||||
bool m_onGround = false;
|
bool m_onGround = false;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user