]> git.mxchange.org Git - flightgear.git/commitdiff
Merge branch 'jmt/track-bug' into next
authorTim Moore <timoore33@gmail.com>
Sun, 21 Feb 2010 21:24:53 +0000 (22:24 +0100)
committerTim Moore <timoore33@gmail.com>
Sun, 21 Feb 2010 21:24:53 +0000 (22:24 +0100)
1  2 
src/AIModel/AIAircraft.cxx

index eb8469fdece8dd419a721b5c7262caf3ddc9a6af,c2acde2e826d468afdfecea46b690942f63adea7..2bf71b3b18b96b35a66462bce9f0fe2c9e282e97
@@@ -51,9 -51,6 +51,6 @@@ using std::string
  
  static string tempReg;
  
- class AI_OutOfSight{};
- class FP_Inactive{};
  FGAIAircraft::FGAIAircraft(FGAISchedule *ref) : FGAIBase(otAircraft) {
      trafficRef = ref;
      if (trafficRef) {
@@@ -148,16 -145,16 +145,16 @@@ void FGAIAircraft::setPerformance(cons
  
   void FGAIAircraft::Run(double dt) {
        FGAIAircraft::dt = dt;
-      try {
-          updatePrimaryTargetValues(); // target hdg, alt, speed
-      }
-      catch (AI_OutOfSight) {
-          return;
+     
+      bool outOfSight = false, 
+         flightplanActive = true;
+      updatePrimaryTargetValues(flightplanActive, outOfSight); // target hdg, alt, speed
+      if (outOfSight) {
+         return;
       }
-      catch (FP_Inactive) {
-          //return;
-          groundTargetSpeed = 0;
+      if (!flightplanActive) {
+         groundTargetSpeed = 0;
       }
  
       handleATCRequests(); // ATC also has a word to say
@@@ -447,6 -444,15 +444,6 @@@ void FGAIAircraft::announcePositionToCo
          case 4:              //Take off tower controller
              if (trafficRef->getDepartureAirport()->getDynamics()) {
                  controller = trafficRef->getDepartureAirport()->getDynamics()->getTowerController();
 -                //if (trafficRef->getDepartureAirport()->getId() == "EHAM") {
 -                //string trns = trafficRef->getCallSign() + " at runway " + fp->getRunway() + 
 -                //              ". Ready for departure. " + trafficRef->getFlightType() + " to " +
 -                //              trafficRef->getArrivalAirport()->getId();
 -                //fgSetString("/sim/messages/atc", trns.c_str());
 -                //  if (controller == 0) {
 -                //cerr << "Error in assigning controller at " << trafficRef->getDepartureAirport()->getId() << endl;
 -                //}
 -                //}
              } else {
                  cerr << "Error: Could not find Dynamics at airport : " << trafficRef->getDepartureAirport()->getId() << endl;
              }
@@@ -739,7 -745,7 +736,7 @@@ void FGAIAircraft::controlSpeed(FGAIFli
  /**
   * Update target values (heading, alt, speed) depending on flight plan or control properties
   */
- void FGAIAircraft::updatePrimaryTargetValues() {
+ void FGAIAircraft::updatePrimaryTargetValues(bool& flightplanActive, bool& aiOutOfSight) {
      if (fp)                      // AI object has a flightplan
      {
          //TODO make this a function of AIBase
          }
          if (trafficRef) {
             //cerr << trafficRef->getRegistration() << " Setting altitude to " << altitude_ft;
-             if (! aiTrafficVisible()) {
+             aiOutOfSight = !aiTrafficVisible();
+             if (aiOutOfSight) {
                  setDie(true);
                  //cerr << trafficRef->getRegistration() << " is set to die " << endl;
-                 throw AI_OutOfSight();
+                 aiOutOfSight = true;
+                 return;
              }
          }
          timeElapsed = now - fp->getStartTime();
-         if (! fp->isActive(now)) { 
-             throw FP_Inactive();
-         }
+         flightplanActive = fp->isActive(now);
      } else {
          // no flight plan, update target heading, speed, and altitude
          // from control properties.  These default to the initial