From e0508185b2b7d22ab955ba3baa641246b21aac5c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 5 Feb 2015 18:03:25 +0200 Subject: [PATCH] Improve metrics_stale flag handling --- source/libr2c2/trainrouter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index a1582fd..cef98ee 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -354,6 +354,7 @@ void TrainRouter::train_advanced(Block &block) if(!wp.has_track(*t_iter)) { waypoints.erase(waypoints.begin()); + metrics_stale = true; signal_waypoint_reached.emit(&wp); signal_event.emit(Message("waypoint-reached", &wp)); break; @@ -390,6 +391,8 @@ void TrainRouter::create_metrics() delete *i; metrics.clear(); + metrics_stale = false; + if(!destination) return; @@ -399,8 +402,6 @@ void TrainRouter::create_metrics() for(unsigned i=metrics.size(); --i>0; ) metrics[i]->chain_to(*metrics[(i+1)%metrics.size()]); - - metrics_stale = false; } bool TrainRouter::create_lead_route() -- 2.45.2