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:
parent
7db47beb0e
commit
9b05b2f941
2 changed files with 29 additions and 16 deletions
|
@ -586,27 +586,39 @@ bool
|
|||
TCAS::ThreatDetector::checkTransponder(const SGPropertyNode* pModel, float velocityKt)
|
||||
{
|
||||
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
|
||||
return false;
|
||||
}
|
||||
|
||||
if (velocityKt < 40)
|
||||
{
|
||||
/* assume all pilots have their transponder switched off while taxiing/parking
|
||||
/* assume all non-MP and non-Swift aircraft have their transponder switched off while taxiing/parking
|
||||
* (at low speed) */
|
||||
return false;
|
||||
return velocityKt >= 40.0;
|
||||
}
|
||||
|
||||
if ((name == "multiplayer")&&
|
||||
(pModel->getBoolValue("controls/invisible")))
|
||||
else if (pModel->getIntValue("instrumentation/transponder/altitude", -9999) != -9999)
|
||||
{
|
||||
// must have Mode C (altitude) transponder to be visible.
|
||||
// "-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 false;
|
||||
return !(pModel->getBoolValue("controls/invisible"));
|
||||
}
|
||||
|
||||
if (name == "swift"){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// assume non-MP/non-AI planes (e.g. ships) have no transponder
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
|
@ -625,7 +637,7 @@ TCAS::ThreatDetector::checkThreat(int mode, const SGPropertyNode* pModel)
|
|||
return ThreatInvisible;
|
||||
|
||||
int threatLevel = ThreatNone;
|
||||
float altFt = pModel->getDoubleValue("position/altitude-ft");
|
||||
float altFt = getAltitude(pModel);
|
||||
currentThreat.relativeAltitudeFt = altFt - self.pressureAltFt;
|
||||
|
||||
// save computation time: don't care when relative altitude is excessive
|
||||
|
|
|
@ -317,6 +317,7 @@ class TCAS : public SGSubsystem
|
|||
void update (void);
|
||||
|
||||
bool checkTransponder (const SGPropertyNode* pModel, float velocityKt);
|
||||
float getAltitude (const SGPropertyNode* pModel);
|
||||
int checkThreat (int mode, const SGPropertyNode* pModel);
|
||||
void checkVerticalThreat (void);
|
||||
void horizontalThreat (float bearing, float distanceNm, float heading,
|
||||
|
|
Loading…
Reference in a new issue