Skip to content

Commit dbe7bf6

Browse files
committed
refactor: Remove TerrainProbe from msfs2024 code
1 parent 0110146 commit dbe7bf6

File tree

6 files changed

+88
-386
lines changed

6 files changed

+88
-386
lines changed

src/core/airspacemonitor.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,12 @@ namespace swift::core
549549
if (!this->isConnectedAndNotShuttingDown()) { return; }
550550
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");
551551

552+
// TODO TZ remove when testing is done
553+
CLogMessage(this).info(u"CAirspaceMonitor::sendReadyForModelMatching "
554+
u"callsign %1 ")
555+
<< callsign;
556+
// TODO remove
557+
552558
// set flag and init ts
553559
Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf);
554560

@@ -769,12 +775,15 @@ namespace swift::core
769775
}
770776
}
771777

778+
// for request
779+
// #SBBER750:DAL483:FSIPIR:0:BER:A320:::::L2J:PMDG 737-800 AIRBERLIN (D-ABKM)
780+
// and also for information
781+
// #SBFSC751 : BER636 : FSIPI : 0 ::EC35:: :: : H2T : AIRBUS H135 NORSK LUFTAMBULANSE
772782
void CAirspaceMonitor::onCustomFSInnPacketReceived(const CCallsign &callsign, const QString &airlineIcaoDesignator,
773783
const QString &aircraftIcaoDesignator,
774784
const QString &combinedAircraftType, const QString &modelString)
775785
{
776786
// TODO TZ remove when testing is done
777-
// #SBBER750:DAL483:FSIPIR:0:BER:A320:::::L2J:PMDG 737-800 AIRBERLIN (D-ABKM)
778787
CLogMessage(this).info(u"CAirspaceMonitor::onCustomFSInnPacketReceived CHECK:"
779788
u"callsign %1 "
780789
u"airlineIcaoDesignator %2 "
@@ -853,11 +862,11 @@ namespace swift::core
853862
}
854863
}
855864

865+
// #SBDAL483:BER636:PI:GEN:EQUIPMENT=B738:AIRLINE=DAL:LIVERY=swift_l1855a1787m13853
856866
void CAirspaceMonitor::onIcaoCodesReceived(const CCallsign &callsign, const QString &aircraftIcaoDesignator,
857867
const QString &airlineIcaoDesignator, const QString &livery)
858868
{
859869
// TODO TZ remove logmessage when testing is done
860-
// #SBDAL483:BER636:PI:GEN:EQUIPMENT=B738:AIRLINE=DAL:LIVERY=swift_l1855a1787m13853
861870
CLogMessage(this).info(u"CAirspaceMonitor::onIcaoCodesReceived CHECK:"
862871
u"callsign %1 "
863872
u"aircraftIcaoDesignator %2 "
@@ -888,6 +897,8 @@ namespace swift::core
888897
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
889898
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(),
890899
CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages);
900+
901+
// we do not change manually assigned models
891902
if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet)
892903
{
893904
this->addReverseLookupMessages(callsign, reverseLookupMessages);
@@ -1211,6 +1222,7 @@ namespace swift::core
12111222
u"incomming modelType %4 ")
12121223
<< aircraft.getModelType() << callsign.toQString() << aircraftIcao << modelType;
12131224

1225+
// we do not change manually assigned models
12141226
if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet)
12151227
{
12161228

src/plugins/simulator/msfs2024/simconnectobjectmsfs2024.cpp

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace swift::simplugin::msfs2024common
3434
setupProvider, remoteAircraftProvider, logger))
3535
{
3636
this->resetCameraPositions();
37-
m_type = aircraft.isTerrainProbe() ? TerrainProbe : AircraftNonAtc;
37+
m_type = AircraftNonAtc;
3838
m_interpolator->initCorrespondingModel(aircraft.getModel());
3939
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
4040
}
@@ -43,7 +43,7 @@ namespace swift::simplugin::msfs2024common
4343
{
4444
m_aircraft = aircraft;
4545
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
46-
m_type = aircraft.isTerrainProbe() ? TerrainProbe : AircraftNonAtc;
46+
m_type = AircraftNonAtc;
4747
}
4848

4949
void CSimConnectObject::setAircraftModelString(const QString &modelString)
@@ -78,7 +78,6 @@ namespace swift::simplugin::msfs2024common
7878
DWORD os = 0;
7979
switch (this->getType())
8080
{
81-
case TerrainProbe: os = static_cast<DWORD>(CSimulatorMsfs2024::offsetSimObjTerrainProbe(offset)); break;
8281
case AircraftNonAtc:
8382
case AircraftSimulatedObject:
8483
default: os = static_cast<DWORD>(CSimulatorMsfs2024::offsetSimObjAircraft(offset)); break;
@@ -233,7 +232,6 @@ namespace swift::simplugin::msfs2024common
233232

234233
CSimConnectObject::SimObjectType CSimConnectObject::requestIdToType(DWORD requestId)
235234
{
236-
if (CSimulatorMsfs2024::isRequestForSimObjTerrainProbe(requestId)) { return TerrainProbe; }
237235
if (CSimulatorMsfs2024::isRequestForSimObjAircraft(requestId)) { return AircraftNonAtc; }
238236
Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong range");
239237
return AircraftNonAtc;
@@ -243,13 +241,12 @@ namespace swift::simplugin::msfs2024common
243241
{
244242
static const QString a1("aircraft (non ATC)");
245243
static const QString a2("aircraft (sim.object)");
246-
static const QString p("probe");
244+
// static const QString p("probe");
247245
static const QString u("unknown");
248246
switch (type)
249247
{
250248
case AircraftNonAtc: return a1;
251249
case AircraftSimulatedObject: return a2;
252-
case TerrainProbe: return p;
253250
default: break;
254251
}
255252
return u;
@@ -296,6 +293,7 @@ namespace swift::simplugin::msfs2024common
296293
return this->getSimObjectForObjectId(objectId).getCallsign();
297294
}
298295

296+
// TODO TZ optimize?
299297
CCallsignSet CSimConnectObjects::getAllCallsigns(bool withoutProbes) const
300298
{
301299
if (this->isEmpty()) { return CCallsignSet(); }
@@ -308,6 +306,7 @@ namespace swift::simplugin::msfs2024common
308306
return callsigns;
309307
}
310308

309+
// TODO TZ optimize?
311310
QStringList CSimConnectObjects::getAllCallsignStrings(bool sorted, bool withoutProbes) const
312311
{
313312
return this->getAllCallsigns(withoutProbes).getCallsignStrings(sorted);
@@ -382,17 +381,17 @@ namespace swift::simplugin::msfs2024common
382381
return c > 0;
383382
}
384383

385-
int CSimConnectObjects::removeAllProbes()
386-
{
387-
const QList<CSimConnectObject> probes = this->getProbes();
388-
int c = 0;
389-
for (const CSimConnectObject &probe : probes)
390-
{
391-
this->remove(probe.getCallsign());
392-
c++;
393-
}
394-
return c;
395-
}
384+
// int CSimConnectObjects::removeAllProbes()
385+
//{
386+
// const QList<CSimConnectObject> probes = this->getProbes();
387+
// int c = 0;
388+
// for (const CSimConnectObject &probe : probes)
389+
// {
390+
// this->remove(probe.getCallsign());
391+
// c++;
392+
// }
393+
// return c;
394+
// }
396395

397396
bool CSimConnectObjects::containsPendingAdded() const
398397
{
@@ -479,32 +478,6 @@ namespace swift::simplugin::msfs2024common
479478
return l;
480479
}
481480

482-
CSimConnectObject CSimConnectObjects::getNotPendingProbe() const
483-
{
484-
for (const CSimConnectObject &simObject : *this)
485-
{
486-
if (simObject.getType() == CSimConnectObject::TerrainProbe && !simObject.isPending()) { return simObject; }
487-
}
488-
return CSimConnectObject();
489-
}
490-
491-
CSimConnectObject CSimConnectObjects::getOldestNotPendingProbe() const
492-
{
493-
CSimConnectObject oldestProbe;
494-
for (const CSimConnectObject &simObject : *this)
495-
{
496-
if (simObject.getType() == CSimConnectObject::TerrainProbe && !simObject.isPending())
497-
{
498-
if (!oldestProbe.hasCreatedTimestamp() ||
499-
oldestProbe.getCreatedTimestamp() > simObject.getCreatedTimestamp())
500-
{
501-
oldestProbe = simObject;
502-
}
503-
}
504-
}
505-
return oldestProbe;
506-
}
507-
508481
bool CSimConnectObjects::containsType(CSimConnectObject::SimObjectType type) const
509482
{
510483
for (const CSimConnectObject &simObject : *this)

src/plugins/simulator/msfs2024/simconnectobjectmsfs2024.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ namespace swift::simplugin::msfs2024common
2727
{
2828
AircraftNonAtc,
2929
AircraftSimulatedObject,
30-
TerrainProbe,
3130
AllTypes
3231
};
3332

@@ -80,9 +79,6 @@ namespace swift::simplugin::msfs2024common
8079
//! Aircraft NON ATC?
8180
bool isAircraftNonAtc() const { return this->getType() == AircraftNonAtc; }
8281

83-
//! Probe?
84-
bool isTerrainProbe() const { return this->getType() == TerrainProbe; }
85-
8682
//! Set the type
8783
void setType(SimObjectType type) { m_type = type; }
8884

@@ -424,9 +420,6 @@ namespace swift::simplugin::msfs2024common
424420
//! Get by type
425421
QList<CSimConnectObject> getByType(CSimConnectObject::SimObjectType type) const;
426422

427-
//! All probes
428-
QList<CSimConnectObject> getProbes() const { return this->getByType(CSimConnectObject::TerrainProbe); }
429-
430423
//! All aircraft
431424
QList<CSimConnectObject> getAircraft() const;
432425

@@ -439,9 +432,6 @@ namespace swift::simplugin::msfs2024common
439432
//! Contains object of type
440433
bool containsType(CSimConnectObject::SimObjectType type) const;
441434

442-
//! Probe?
443-
bool containsProbe() const { return this->containsType(CSimConnectObject::TerrainProbe); }
444-
445435
//! Aircraft?
446436
bool containsAircraft() const;
447437
};

0 commit comments

Comments
 (0)