(svn r7628) -Fix: [YAPF] suppress 'Train is lost' message if pathfinding ended on the first two-way red signal due to yapf.rail_firstred_twoway_eol option.
authorKUDr
Fri, 29 Dec 2006 23:06:00 +0000
changeset 5424 34b624b01ae1
parent 5423 bf943b53358e
child 5425 69d019397b5c
(svn r7628) -Fix: [YAPF] suppress 'Train is lost' message if pathfinding ended on the first two-way red signal due to yapf.rail_firstred_twoway_eol option.
yapf/yapf_costrail.hpp
yapf/yapf_rail.cpp
--- a/yapf/yapf_costrail.hpp	Fri Dec 29 21:46:21 2006 +0000
+++ b/yapf/yapf_costrail.hpp	Fri Dec 29 23:06:00 2006 +0000
@@ -19,10 +19,15 @@
 protected:
 	int           m_max_cost;
 	CBlobT<int>   m_sig_look_ahead_costs;
+public:
+	bool          m_stopped_on_first_two_way_signal;
+protected:
 
 	static const int s_max_segment_cost = 10000;
 
-	CYapfCostRailT() : m_max_cost(0)
+	CYapfCostRailT()
+		: m_max_cost(0)
+		, m_stopped_on_first_two_way_signal(false)
 	{
 		// pre-compute look-ahead penalties into array
 		int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
@@ -116,6 +121,7 @@
 					if (Yapf().TreatFirstRedTwoWaySignalAsEOL() && n.flags_u.flags_s.m_choice_seen && has_signal_against && n.m_num_signals_passed == 0) {
 						// yes, the first signal is two-way red signal => DEAD END
 						n.m_segment->flags_u.flags_s.m_end_of_line = true;
+						Yapf().m_stopped_on_first_two_way_signal = true;
 						return -1;
 					}
 					SignalType sig_type = GetSignalType(tile);
--- a/yapf/yapf_rail.cpp	Fri Dec 29 21:46:21 2006 +0000
+++ b/yapf/yapf_rail.cpp	Fri Dec 29 23:06:00 2006 +0000
@@ -118,9 +118,10 @@
 
 		// find the best path
 		bool path_found = Yapf().FindPath(v);
-		if (!path_found && path_not_found != NULL) {
+		if (path_not_found != NULL) {
 			// tell controller that the path was only 'guessed'
-			*path_not_found = !path_found;
+			// treat the path as found if stopped on the first two way signal(s)
+			*path_not_found = !(path_found || Yapf().m_stopped_on_first_two_way_signal);
 		}
 
 		// if path not found - return INVALID_TRACKDIR