X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=218b6861da183b0d24c3279046c4dc122aaae9ba;hb=895f5a36ee5a4fcba95ad88b7a197bf61f1f501d;hp=0eaf1e9a0ec91fb62e6947ff15ae2a38851d378e;hpb=f4e02a59008181013e57cdf2a8cf1695e89b24bb;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 0eaf1e9..218b686 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -874,7 +874,10 @@ void Train::reserve_more() if(!block || block->get_endpoints().size()<2) { if(!blocking_train) + { good_end = blocks.end(); + end_of_route = true; + } break; } @@ -978,7 +981,7 @@ void Train::reserve_more() contested_blocks.push_back(block); continue; } - else if(divert_track && (entry_conflict || exit_conflict)) + else if(divert_track && (entry_conflict || exit_conflict || !other_train->is_active())) // We are blocked, but there's a diversion possibility try_divert = true; @@ -1177,10 +1180,10 @@ unsigned Train::find_speed_step(float real) const if(real_speed[i].weight) { last = i; - if(real_speed[i].speed=real) high = i; + else if(real_speed[i].speed>real_speed[low].speed) + low = i; } if(!high) { @@ -1291,7 +1294,7 @@ bool Train::is_valid_diversion(const Route &diversion, const TrackIter &from) track1 = track1.next(path); - if(track1.looped()) + if(!track1 || track1.looped()) return false; } @@ -1309,6 +1312,8 @@ bool Train::is_valid_diversion(const Route &diversion, const TrackIter &from) bool ok = (track2!=from && diversion.has_track(*track2)); track2 = track2.next(path); + if(!track2) + return false; if(ok) break;