Ref T345, fixed bug: only one station must be updated with the new message

This commit is contained in:
Klaus Basan
2018-09-17 18:24:42 +02:00
parent 4913b93724
commit a9f0cebe13
3 changed files with 16 additions and 15 deletions

View File

@@ -604,16 +604,13 @@ namespace BlackCore
{ {
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this)); Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
if (!this->isConnectedAndNotShuttingDown() || callsign.isEmpty()) return; if (!this->isConnectedAndNotShuttingDown() || callsign.isEmpty()) return;
const int changedAtis = m_atcStationsOnline.updateIfMessageChanged(atisMessage, true); bool changedAtis = m_atcStationsOnline.updateIfMessageChanged(atisMessage, callsign, true);
// receiving an ATIS means station is online, update in bookings // receiving an ATIS means station is online, update in bookings
m_atcStationsBooked.setOnline(callsign, true); m_atcStationsBooked.setOnline(callsign, true);
// signal // signal
if (changedAtis > 0) if (changedAtis) { emit this->changedAtisReceived(callsign); }
{
emit this->changedAtisReceived(callsign);
}
} }
void CAirspaceMonitor::onAtisVoiceRoomReceived(const CCallsign &callsign, const QString &url) void CAirspaceMonitor::onAtisVoiceRoomReceived(const CCallsign &callsign, const QString &url)

View File

@@ -40,28 +40,32 @@ namespace BlackMisc
}); });
} }
int CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, bool overrideWithNewer) bool CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer)
{ {
int c = 0;
const CInformationMessage::InformationType t = im.getType(); const CInformationMessage::InformationType t = im.getType();
// for loop just to get reference
bool unequal = false;
for (CAtcStation &station : *this) for (CAtcStation &station : *this)
{ {
bool unequal = false; if (station.getCallsign() != callsign) { continue; }
const CInformationMessage m = station.getInformationMessage(t); const CInformationMessage m = station.getInformationMessage(t);
if (m.getType() == CInformationMessage::Unspecified) { continue; } if (m.getType() == CInformationMessage::Unspecified) { break; }
if (m.getMessage() == im.getMessage()) if (m.getMessage() == im.getMessage())
{ {
if (!overrideWithNewer) { continue; } if (!overrideWithNewer) { break; }
if (!im.isNewerThan(m)) { continue; } if (!im.isNewerThan(m)) { break; }
} }
else else
{ {
unequal = true; unequal = true;
} }
station.setMessage(m); station.setMessage(im);
if (unequal) c++; // only count unequals break; // only count unequals
} }
return c; return unequal;
} }
int CAtcStationList::setOnline(const CCallsign &callsign, bool online) int CAtcStationList::setOnline(const CCallsign &callsign, bool online)

View File

@@ -49,7 +49,7 @@ namespace BlackMisc
CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const; CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const;
//! Update if message changed //! Update if message changed
int updateIfMessageChanged(const CInformationMessage &im, bool overrideWithNewer); bool updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer);
//! Set online status //! Set online status
int setOnline(const CCallsign &callsign, bool online); int setOnline(const CCallsign &callsign, bool online);