diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index ca851881e..0ef6e72c2 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -746,7 +746,7 @@ bool FGRouteMgr::activate() return false; } - _plan->setCurrentIndex(0); + _plan->activate(); active->setBoolValue(true); SG_LOG(SG_AUTOPILOT, SG_INFO, "route-manager, activate route ok"); return true; diff --git a/src/Navaids/FlightPlan.cxx b/src/Navaids/FlightPlan.cxx index ee1e90815..339ae0a19 100644 --- a/src/Navaids/FlightPlan.cxx +++ b/src/Navaids/FlightPlan.cxx @@ -333,7 +333,21 @@ void FlightPlan::setCurrentIndex(int index) _currentWaypointChanged = true; unlockDelegate(); } - + +void FlightPlan::activate() +{ + lockDelegate(); + + _currentIndex = 0; + _currentWaypointChanged = true; + + if (_delegate) { + _delegate->runActivated(); + } + + unlockDelegate(); +} + void FlightPlan::finish() { if (_currentIndex == -1) { @@ -1362,6 +1376,12 @@ void FlightPlan::Delegate::runFinished() endOfFlightPlan(); } +void FlightPlan::Delegate::runActivated() +{ + if (_inner) _inner->runActivated(); + activated(); +} + void FlightPlan::setFollowLegTrackToFixes(bool tf) { _followLegTrackToFix = tf; diff --git a/src/Navaids/FlightPlan.hxx b/src/Navaids/FlightPlan.hxx index 50747b6df..34630e829 100644 --- a/src/Navaids/FlightPlan.hxx +++ b/src/Navaids/FlightPlan.hxx @@ -121,6 +121,7 @@ public: virtual void arrivalChanged() { } virtual void waypointsChanged() { } virtual void cleared() { } + virtual void activated() { } virtual void currentWaypointChanged() { } virtual void endOfFlightPlan() { } protected: @@ -135,7 +136,8 @@ public: void runCurrentWaypointChanged(); void runCleared(); void runFinished(); - + void runActivated(); + friend class FlightPlan; bool _deleteWithPlan; @@ -153,7 +155,9 @@ public: { return _currentIndex; } void setCurrentIndex(int index); - + + void activate(); + void finish(); Leg* currentLeg() const; diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index b642d3def..6a52a0847 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -1807,6 +1807,11 @@ public: { callDelegateMethod("endOfFlightPlan"); } + + virtual void activated() + { + callDelegateMethod("activated"); + } private: void callDelegateMethod(const char* method)