mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T345, fixed bug: only one station must be updated with the new message
This commit is contained in:
@@ -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();
|
||||
|
||||
// for loop just to get reference
|
||||
bool unequal = false;
|
||||
for (CAtcStation &station : *this)
|
||||
{
|
||||
bool unequal = false;
|
||||
if (station.getCallsign() != callsign) { continue; }
|
||||
|
||||
const CInformationMessage m = station.getInformationMessage(t);
|
||||
if (m.getType() == CInformationMessage::Unspecified) { continue; }
|
||||
if (m.getType() == CInformationMessage::Unspecified) { break; }
|
||||
|
||||
if (m.getMessage() == im.getMessage())
|
||||
{
|
||||
if (!overrideWithNewer) { continue; }
|
||||
if (!im.isNewerThan(m)) { continue; }
|
||||
if (!overrideWithNewer) { break; }
|
||||
if (!im.isNewerThan(m)) { break; }
|
||||
}
|
||||
else
|
||||
{
|
||||
unequal = true;
|
||||
}
|
||||
station.setMessage(m);
|
||||
if (unequal) c++; // only count unequals
|
||||
station.setMessage(im);
|
||||
break; // only count unequals
|
||||
}
|
||||
return c;
|
||||
return unequal;
|
||||
}
|
||||
|
||||
int CAtcStationList::setOnline(const CCallsign &callsign, bool online)
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackMisc
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const;
|
||||
|
||||
//! Update if message changed
|
||||
int updateIfMessageChanged(const CInformationMessage &im, bool overrideWithNewer);
|
||||
bool updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer);
|
||||
|
||||
//! Set online status
|
||||
int setOnline(const CCallsign &callsign, bool online);
|
||||
|
||||
Reference in New Issue
Block a user