1
0
Fork 0

src/Instrumentation/tcas.*: improved treatment of AI, MP and Swift aircraft.

Change the assumption that velocity < 40kt implies the transponder is off, to
only apply to AI aircraft, because exact information is available for other
(i.e. multiplayer and swift) aircraft.

Add new check for multiplayer/swift aircraft where if the altitude is -9999, we
treat the transponder as off.

With swift and multiplayer aircraft, use the transponder altitude information,
not the sim's internal altitude data for the aircraft.
This commit is contained in:
Michael Danilov 2021-09-19 10:38:18 +01:00 committed by Julian Smith
parent 7db47beb0e
commit 9b05b2f941
2 changed files with 29 additions and 16 deletions

View file

@ -586,27 +586,39 @@ bool
TCAS::ThreatDetector::checkTransponder(const SGPropertyNode* pModel, float velocityKt) TCAS::ThreatDetector::checkTransponder(const SGPropertyNode* pModel, float velocityKt)
{ {
const string name = pModel->getName(); const string name = pModel->getName();
if (name != "multiplayer" && name != "aircraft" && name != "swift") if (name == "aircraft")
{ {
// assume non-MP/non-AI planes (e.g. ships) have no transponder /* assume all non-MP and non-Swift aircraft have their transponder switched off while taxiing/parking
return false;
}
if (velocityKt < 40)
{
/* assume all pilots have their transponder switched off while taxiing/parking
* (at low speed) */ * (at low speed) */
return false; return velocityKt >= 40.0;
} }
else if (pModel->getIntValue("instrumentation/transponder/altitude", -9999) != -9999)
if ((name == "multiplayer")&&
(pModel->getBoolValue("controls/invisible")))
{ {
// ignored MP plane: pretend transponder is switched off // must have Mode C (altitude) transponder to be visible.
return false; // "-9999" is a special value used by src/Instrumentation/transponder.cxx to indicate the non-transmission of a value.
if (name == "multiplayer")
{
// ignored MP plane: pretend transponder is switched off
return !(pModel->getBoolValue("controls/invisible"));
}
if (name == "swift"){
return true;
}
} }
// assume non-MP/non-AI planes (e.g. ships) have no transponder
return false;
}
return true; /** Get altitude reported by transponder. */
float
TCAS::ThreatDetector::getAltitude(const SGPropertyNode* pModel)
{
const string name = pModel->getName();
if (name == "multiplayer" || name == "swift")
{
return pModel->getIntValue("instrumentation/transponder/altitude");
}
return pModel->getDoubleValue("position/altitude-ft");
} }
/** Check if plane is a threat. */ /** Check if plane is a threat. */
@ -625,7 +637,7 @@ TCAS::ThreatDetector::checkThreat(int mode, const SGPropertyNode* pModel)
return ThreatInvisible; return ThreatInvisible;
int threatLevel = ThreatNone; int threatLevel = ThreatNone;
float altFt = pModel->getDoubleValue("position/altitude-ft"); float altFt = getAltitude(pModel);
currentThreat.relativeAltitudeFt = altFt - self.pressureAltFt; currentThreat.relativeAltitudeFt = altFt - self.pressureAltFt;
// save computation time: don't care when relative altitude is excessive // save computation time: don't care when relative altitude is excessive

View file

@ -317,6 +317,7 @@ class TCAS : public SGSubsystem
void update (void); void update (void);
bool checkTransponder (const SGPropertyNode* pModel, float velocityKt); bool checkTransponder (const SGPropertyNode* pModel, float velocityKt);
float getAltitude (const SGPropertyNode* pModel);
int checkThreat (int mode, const SGPropertyNode* pModel); int checkThreat (int mode, const SGPropertyNode* pModel);
void checkVerticalThreat (void); void checkVerticalThreat (void);
void horizontalThreat (float bearing, float distanceNm, float heading, void horizontalThreat (float bearing, float distanceNm, float heading,