From c19664291f3a12ab2518978d0b51a8ad52fd53b5 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 25 Jun 2011 20:44:44 +0200 Subject: [PATCH] #221, #242: Fix/work-around for AI traffic issues Move the disable-HOT feature from the MP aircraft to the a/c base class, disable HOT for all AIaircraft, since that's a fix/work-around for #242: AI aircraft respect the user a/c only when HOT is _disabled_ for them #221: AI aircraft don't stack at parking positions when HOT is disabled Also generally disables HOT for ballistic and other models (suggested by vivian), allowing it for ship/carrier models only. --- src/AIModel/AIAircraft.cxx | 8 ++++++-- src/AIModel/AIBallistic.cxx | 2 +- src/AIModel/AIBase.cxx | 6 +++++- src/AIModel/AIBase.hxx | 2 +- src/AIModel/AIMultiplayer.cxx | 6 +++--- src/AIModel/AIShip.cxx | 3 ++- src/AIModel/AIStatic.cxx | 2 +- src/AIModel/AIStorm.cxx | 4 +++- src/AIModel/AIThermal.cxx | 4 +++- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index d0e319705..1c904b79b 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -52,11 +52,15 @@ using std::string; static string tempReg; -FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : FGAIBase(otAircraft) { +FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : + /* HOT must be disabled for AI Aircraft, + * otherwise traffic detection isn't working as expected.*/ + FGAIBase(otAircraft, false) +{ trafficRef = ref; if (trafficRef) { groundOffset = trafficRef->getGroundOffset(); - setCallSign(trafficRef->getCallSign()); + setCallSign(trafficRef->getCallSign()); } else groundOffset = 0; diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 69e090e3d..74b882821 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -40,7 +40,7 @@ const double FGAIBallistic::slugs_to_kgs = 14.5939029372; const double FGAIBallistic::slugs_to_lbs = 32.1740485564; FGAIBallistic::FGAIBallistic(object_type ot) : -FGAIBase(ot), +FGAIBase(ot, false), _height(0.0), _speed(0), _ht_agl_ft(0.0), diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 33cb073cb..ac907c2e3 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -52,7 +52,7 @@ const double FGAIBase::lbs_to_slugs = 0.031080950172; //conversion factor using namespace simgear; -FGAIBase::FGAIBase(object_type ot) : +FGAIBase::FGAIBase(object_type ot, bool enableHot) : _max_speed(300), _name(""), _parent(""), @@ -121,6 +121,10 @@ FGAIBase::FGAIBase(object_type ot) : p = 1e5; a = 340; Mach = 0; + + // explicitly disable HOT for (most) AI models + if (!enableHot) + aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); } FGAIBase::~FGAIBase() { diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 2f8362331..61351adbb 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -52,7 +52,7 @@ public: otEscort, otMultiplayer, MAX_OBJECTS }; // Needs to be last!!! - FGAIBase(object_type ot); + FGAIBase(object_type ot, bool enableHot); virtual ~FGAIBase(); virtual void readFromScenario(SGPropertyNode* scFileNode); diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index a9635c5f7..08f5afb40 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -29,18 +29,18 @@ #include "AIMultiplayer.hxx" -#include // #define SG_DEBUG SG_ALERT -FGAIMultiplayer::FGAIMultiplayer() : FGAIBase(otMultiplayer) { +FGAIMultiplayer::FGAIMultiplayer() : + FGAIBase(otMultiplayer, false) +{ no_roll = false; mTimeOffsetSet = false; mAllowExtrapolation = true; mLagAdjustSystemSpeed = 10; mLastTimestamp = 0; - aip.getSceneGraph()->setNodeMask(~SG_NODEMASK_TERRAIN_BIT); lastUpdateTime = 0; } diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 9b6a04705..b5df3d145 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -42,7 +42,8 @@ FGAIShip::FGAIShip(object_type ot) : -FGAIBase(ot), +// allow HOT to be enabled +FGAIBase(ot, true), _waiting(false), diff --git a/src/AIModel/AIStatic.cxx b/src/AIModel/AIStatic.cxx index 83be7c8d6..5ac1f4ce3 100644 --- a/src/AIModel/AIStatic.cxx +++ b/src/AIModel/AIStatic.cxx @@ -33,7 +33,7 @@ using std::string; #include "AIStatic.hxx" -FGAIStatic::FGAIStatic() : FGAIBase(otStatic) { +FGAIStatic::FGAIStatic() : FGAIBase(otStatic, false) { } diff --git a/src/AIModel/AIStorm.cxx b/src/AIModel/AIStorm.cxx index fded8012d..a4241df46 100644 --- a/src/AIModel/AIStorm.cxx +++ b/src/AIModel/AIStorm.cxx @@ -35,7 +35,9 @@ using std::string; #include "AIStorm.hxx" -FGAIStorm::FGAIStorm() : FGAIBase(otStorm) { +FGAIStorm::FGAIStorm() : + FGAIBase(otStorm, false) +{ delay = 3.6; subflashes = 1; timer = 0.0; diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index 172d1e68a..f47ba2356 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -35,7 +35,9 @@ using std::string; #include "AIThermal.hxx" -FGAIThermal::FGAIThermal() : FGAIBase(otThermal) { +FGAIThermal::FGAIThermal() : + FGAIBase(otThermal, false) +{ max_strength = 6.0; diameter = 0.5; strength = factor = 0.0; -- 2.39.5