X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FAIModel%2FAIAircraft.cxx;h=2bf71b3b18b96b35a66462bce9f0fe2c9e282e97;hb=9d00d55f483ad2fb252d998e26e52fa9a768493b;hp=eb8469fdece8dd419a721b5c7262caf3ddc9a6af;hpb=4ae8c90f7668724576df3ffa1f253da84b89ab0e;p=flightgear.git diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index eb8469fde..2bf71b3b1 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -51,9 +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 @@ void FGAIAircraft::setPerformance(const std::string& acclass) { 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 @@ -739,7 +736,7 @@ void FGAIAircraft::controlSpeed(FGAIFlightPlan::waypoint* curr, FGAIFlightPlan:: /** * 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 @@ -760,16 +757,16 @@ void FGAIAircraft::updatePrimaryTargetValues() { } 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