From 2fec8b40d8cd953e36362773e440e50cc4f94a91 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 3 Feb 2015 16:23:01 +0200 Subject: [PATCH] Avoid going past the end of route when a new one is set Calling stop_at(0) causes the block allocator to immediately resume allocating blocks. In certain circumstances this would cause an allocation past the end of the route. --- source/libr2c2/trainrouter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index ca3e93d..d1cb6ff 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -111,8 +111,9 @@ void TrainRouter::route_changed() { // We are not at the end of the route now, but might have been before. arrival = ON_THE_WAY; - train.stop_at(0); train.refresh_blocks_from(*fncb); + if(!arrival) + train.stop_at(0); } else if(!arrival) { -- 2.45.2