diff options
author | smatz <smatz@openttd.org> | 2008-07-23 18:23:12 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-07-23 18:23:12 +0000 |
commit | c0e11a797c3ad92dabf3348d7246cc069aff76e9 (patch) | |
tree | e64aed3b3cd4bb8ef39bfed97da3f8e6cf052a08 | |
parent | 32ab467e97c3e4d76cad6ea924d749dfd49053fb (diff) | |
download | openttd-c0e11a797c3ad92dabf3348d7246cc069aff76e9.tar.xz |
(svn r13806) -Fix [FS#2162]: checking for train waiting at other side of two-way signal was broken
-rw-r--r-- | src/train_cmd.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index cb923e81d..fd7c17127 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2905,13 +2905,13 @@ static void CheckTrainCollision(Vehicle *v) static void *CheckVehicleAtSignal(Vehicle *v, void *data) { - Direction dir = *(Direction*)data; + DiagDirection exitdir = *(DiagDirection *)data; - if (v->type == VEH_TRAIN && IsFrontEngine(v)) { - DirDiff diff = ChangeDirDiff(DirDifference(v->direction, dir), DIRDIFF_90RIGHT); - - if (diff == DIRDIFF_90RIGHT || (v->cur_speed <= 5 && diff <= DIRDIFF_REVERSE)) return v; + /* front engine of a train, not inside wormhole or depot */ + if (v->type == VEH_TRAIN && IsFrontEngine(v) && (v->u.rail.track & TRACK_BIT_MASK) != 0) { + if (v->cur_speed <= 5 && TrainExitDir(v->direction, v->u.rail.track) == exitdir) return v; } + return NULL; } @@ -3004,11 +3004,13 @@ static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image) v->subspeed = 0; v->progress = 255 - 10; if (++v->load_unload_time_rem < _settings_game.pf.wait_twoway_signal * 73) { - TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); - Direction rdir = ReverseDir(dir); + DiagDirection exitdir = TrackdirToExitdir(i); + TileIndex o_tile = TileAddByDiagDir(gp.new_tile, exitdir); + + exitdir = ReverseDiagDir(exitdir); /* check if a train is waiting on the other side */ - if (VehicleFromPos(o_tile, &rdir, &CheckVehicleAtSignal) == NULL) return; + if (VehicleFromPos(o_tile, &exitdir, &CheckVehicleAtSignal) == NULL) return; } } goto reverse_train_direction; |