From 13259028b1b097a7f44374126a6a81d4b3e87fd7 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 30 Jul 2007 10:24:04 +0000 Subject: [PATCH] (svn r10735) [0.5] -Fix [FS#1062]: trains being split into two pieces when loading an old savegame. --- oldloader.c | 15 --------------- openttd.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/oldloader.c b/oldloader.c index b07c92b17f..4338b4c8e7 100644 --- a/oldloader.c +++ b/oldloader.c @@ -357,21 +357,6 @@ static void FixOldVehicles(void) break; } } - - if (IsBridgeTile(v->tile) && IsBridgeRamp(v->tile) && - (v->z_pos & (TILE_HEIGHT - 1)) == (TILE_HEIGHT - 1)) { - /* Under some circumstances the trains going up a ramp can be one - * pixel too low when they enter the bridge. This causes the train - * to "disappear" under the bridge, which causes the train to - * break into two pieces and crash slightly later. - * - * This "hack" will make the trains on those positions on the - * ramps run one pixel higher. This offset will be automatically - * "fixed" when it enters the bridge middle parts or when it - * drives down the ramp of the bridge. - */ - v->z_pos++; - } } } diff --git a/openttd.c b/openttd.c index 6d3dcfd849..62069d1f8b 100644 --- a/openttd.c +++ b/openttd.c @@ -1592,6 +1592,26 @@ bool AfterLoadGame(void) SettingsDisableElrail(_patches.disable_elrails); } + if (CheckSavegameVersion(41)) { + Vehicle *v; + FOR_ALL_VEHICLES(v) { + if (IsBridgeTile(v->tile) && IsBridgeRamp(v->tile) && + (v->z_pos & (TILE_HEIGHT - 1)) == (TILE_HEIGHT - 1)) { + /* Under some circumstances the trains going up a ramp can be one + * pixel too low when they enter the bridge. This causes the train + * to "disappear" under the bridge, which causes the train to + * break into two pieces and crash slightly later. + * + * This "hack" will make the trains on those positions on the + * ramps run one pixel higher. This offset will be automatically + * "fixed" when it enters the bridge middle parts or when it + * drives down the ramp of the bridge. + */ + v->z_pos++; + } + } + } + /* Buoys do now store the owner of the previous water tile, which can never * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ if (CheckSavegameVersion(46)) {