Ref T397, Ref T297 split "isInterimPositionUpdateEnabledForServer" into 2 functions and ignore incoming interim positions if disabled

This commit is contained in:
Klaus Basan
2018-10-24 00:03:59 +02:00
parent 19b591dce8
commit 259aab3c10
2 changed files with 20 additions and 11 deletions

View File

@@ -362,10 +362,16 @@ namespace BlackCore
return qstrList; return qstrList;
} }
bool CNetworkVatlib::isInterimPositionUpdateEnabledForServer() const bool CNetworkVatlib::isInterimPositionSendingEnabledForServer() const
{ {
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails(); const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
return (d & CFsdSetup::SendInterimPositions) || (d & CFsdSetup::ReceiveInterimPositions); return (d & CFsdSetup::SendInterimPositions);
}
bool CNetworkVatlib::isInterimPositionReceivingEnabledForServer() const
{
const CFsdSetup::SendReceiveDetails d = this->getSetupForServer().getSendReceiveDetails();
return (d & CFsdSetup::ReceiveInterimPositions);
} }
const CFsdSetup &CNetworkVatlib::getSetupForServer() const const CFsdSetup &CNetworkVatlib::getSetupForServer() const
@@ -376,7 +382,7 @@ namespace BlackCore
void CNetworkVatlib::startPositionTimers() void CNetworkVatlib::startPositionTimers()
{ {
m_positionUpdateTimer.start(c_updatePostionIntervalMsec); m_positionUpdateTimer.start(c_updatePostionIntervalMsec);
if (isInterimPositionUpdateEnabledForServer()) { m_interimPositionUpdateTimer.start(c_updateInterimPostionIntervalMsec); } if (this->isInterimPositionSendingEnabledForServer()) { m_interimPositionUpdateTimer.start(c_updateInterimPostionIntervalMsec); }
} }
void CNetworkVatlib::stopPositionTimers() void CNetworkVatlib::stopPositionTimers()
@@ -490,13 +496,13 @@ namespace BlackCore
{ {
// Observer mode // Observer mode
VatAtcConnection info; VatAtcConnection info;
name = toFSD(m_server.getUser().getRealName()); name = toFSDnoColon(m_server.getUser().getRealName());
info.name = name.data(); info.name = name.data();
info.rating = vatAtcRatingObserver; info.rating = vatAtcRatingObserver;
info.callsign = callsign.data(); info.callsign = callsign.data();
Vat_SpecifyATCLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(), Vat_SpecifyATCLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(),
toFSD(m_server.getUser().getId()), toFSDnoColon(m_server.getUser().getId()),
toFSD(m_server.getUser().getPassword()), toFSDnoColon(m_server.getUser().getPassword()),
&info); &info);
} }
else else
@@ -504,13 +510,13 @@ namespace BlackCore
// normal scenario, also used in STEALTH // normal scenario, also used in STEALTH
VatPilotConnection info; VatPilotConnection info;
info.callsign = callsign.data(); info.callsign = callsign.data();
name = toFSD(m_server.getUser().getRealNameAndHomeBase()); name = toFSDnoColon(m_server.getUser().getRealNameAndHomeBase());
info.name = name.data(); info.name = name.data();
info.rating = vatPilotRatingStudent; // as documented, expected to be vatPilotRatingStudent only info.rating = vatPilotRatingStudent; // as documented, expected to be vatPilotRatingStudent only
info.simType = convertToSimType(m_simulatorInfo); info.simType = convertToSimType(m_simulatorInfo);
Vat_SpecifyPilotLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(), Vat_SpecifyPilotLogon(m_net.data(), toFSD(m_server.getAddress()), m_server.getPort(),
toFSD(m_server.getUser().getId()), toFSDnoColon(m_server.getUser().getId()),
toFSD(m_server.getUser().getPassword()), toFSDnoColon(m_server.getUser().getPassword()),
&info); &info);
} }
@@ -1012,7 +1018,9 @@ namespace BlackCore
void CNetworkVatlib::onInterimPilotPositionUpdate(VatFsdClient *, const char *sender, const VatInterimPilotPosition *position, void *cbvar) void CNetworkVatlib::onInterimPilotPositionUpdate(VatFsdClient *, const char *sender, const VatInterimPilotPosition *position, void *cbvar)
{ {
auto *self = cbvar_cast(cbvar); CNetworkVatlib *self = cbvar_cast(cbvar);
if (!self->isInterimPositionReceivingEnabledForServer()) { return; }
CAircraftSituation situation( CAircraftSituation situation(
CCallsign(self->fromFSD(sender), CCallsign::Aircraft), CCallsign(self->fromFSD(sender), CCallsign::Aircraft),
CCoordinateGeodetic(position->latitude, position->longitude, position->altitudeTrue), CCoordinateGeodetic(position->latitude, position->longitude, position->altitudeTrue),

View File

@@ -179,7 +179,8 @@ namespace BlackCore
QString fromFSD(const char *cstr) const; QString fromFSD(const char *cstr) const;
QString getNetworkHostApplicationString() const; //!< simulator version and details info string QString getNetworkHostApplicationString() const; //!< simulator version and details info string
QStringList fromFSD(const char **cstrArray, int size) const; QStringList fromFSD(const char **cstrArray, int size) const;
bool isInterimPositionUpdateEnabledForServer() const; bool isInterimPositionSendingEnabledForServer() const;
bool isInterimPositionReceivingEnabledForServer() const;
const BlackMisc::Network::CFsdSetup &getSetupForServer() const; const BlackMisc::Network::CFsdSetup &getSetupForServer() const;
void startPositionTimers(); void startPositionTimers();
void stopPositionTimers(); void stopPositionTimers();