From 2c0a478641a10a739557d055f80354a28936ced1 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 20 Feb 2011 19:47:57 +0000 Subject: [PATCH] Fix formatting of goto sensor row type Make sure not to dereference an invalid TrackIter --- source/libr2c2/timetable.cpp | 2 +- source/libr2c2/train.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libr2c2/timetable.cpp b/source/libr2c2/timetable.cpp index 836dc39..4a78bca 100644 --- a/source/libr2c2/timetable.cpp +++ b/source/libr2c2/timetable.cpp @@ -249,7 +249,7 @@ string Timetable::Row::str() const switch(type) { case GOTO_SENSOR: - return "set route to sensor "+get_param(0); + return format("set route to sensor %d", get_param(0)); case GOTO_ZONE: return "set route to "+get_param(0); case TRAVEL_TO: diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 1447ca5..ea4599f 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -538,7 +538,7 @@ float Train::get_reserved_distance() const float margin = 0; TrackIter next = blocks.back().next().track_iter(); - if(next->get_type().is_turnout()) + if(next && next->get_type().is_turnout()) margin = 15*layout.get_catalogue().get_scale(); return max(get_reserved_distance_until(0, false)-margin, 0.0f); -- 2.45.2