]> git.tdb.fi Git - r2c2.git/commitdiff
Fix formatting of goto sensor row type
authorMikko Rasa <tdb@tdb.fi>
Sun, 20 Feb 2011 19:47:57 +0000 (19:47 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 20 Feb 2011 19:47:57 +0000 (19:47 +0000)
Make sure not to dereference an invalid TrackIter

source/libr2c2/timetable.cpp
source/libr2c2/train.cpp

index 836dc3933f8ec5bedc2e1eb4ef4040a825b60af6..4a78bcafadab289f5e2f88a4004d449b4e32fe06 100644 (file)
@@ -249,7 +249,7 @@ string Timetable::Row::str() const
        switch(type)
        {
        case GOTO_SENSOR:
-               return "set route to sensor "+get_param<unsigned>(0);
+               return format("set route to sensor %d", get_param<unsigned>(0));
        case GOTO_ZONE:
                return "set route to "+get_param<string>(0);
        case TRAVEL_TO:
index 1447ca58df834c86f7a14d27610e0959bb38c560..ea4599fa9545eb2465d9ba2d0a1a5c85efc583d5 100644 (file)
@@ -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);