diff options
author | rubidium <rubidium@openttd.org> | 2011-03-06 09:22:11 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-03-06 09:22:11 +0000 |
commit | 18a918808162717335ae86ab9b1982539ff8228b (patch) | |
tree | a207702067fc746301c3d6b74fba4dc751e07a9a | |
parent | e34c42de32a3a7dca800a250747ec41d485f42a3 (diff) | |
download | openttd-18a918808162717335ae86ab9b1982539ff8228b.tar.xz |
(svn r22206) -Revert-ish (r14526) / Unfix-ish [FS#3569] / Fix [FS#4545]: the "center" (for movement) of vehicles is (currently still) always at 4/8th original vehicle length from the front, so trains should stop at the same location regardless of the length of the front engine
-rw-r--r-- | src/train_cmd.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 853c0ee58..b090837ee 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -313,8 +313,11 @@ int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, i } /* Subtract half the front vehicle length of the train so we get the real - * stop location of the train. */ - return stop - (v->gcache.cached_veh_length + 1) / 2; + * stop location of the train. + * Actually, the center of all vehicles is half a normal vehicle's length + * from the front of the vehicle, so even in case the vehicle is 1/8th + * long, the center is still at 1/2 of VEHICLE_LENGTH. Basically FS#3569. */ + return stop - VEHICLE_LENGTH / 2; } @@ -3403,8 +3406,13 @@ static bool TrainApproachingLineEnd(Train *v, bool signal) default: break; } - /* do not reverse when approaching red signal */ - if (!signal && x + (v->gcache.cached_veh_length + 1) / 2 >= TILE_SIZE) { + /* Do not reverse when approaching red signal. Make sure the vehicle's front + * does not cross the tile boundary when we do reverse, but as the vehicle's + * location is based on their center, use half a vehicle's length as offset. + * Actually, the center of all vehicles is half a normal vehicle's length + * from the front of the vehicle, so even in case the vehicle is 1/8th + * long, the center is still at 1/2 of VEHICLE_LENGTH. Basically FS#3569. */ + if (!signal && x + VEHICLE_LENGTH / 2 >= TILE_SIZE) { /* we are too near the tile end, reverse now */ v->cur_speed = 0; ReverseTrainDirection(v); |