summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-01-23 21:05:05 +0000
committerpeter1138 <peter1138@openttd.org>2006-01-23 21:05:05 +0000
commit0f28e74e3ea0fd5b3bd937dd09466d05eeace213 (patch)
tree6016bdaa28e28e9fabecc6038fc8fe0463d3c623
parent70efa805cb835fed82b2d8acb6277a556cea2bc9 (diff)
downloadopenttd-0f28e74e3ea0fd5b3bd937dd09466d05eeace213.tar.xz
(svn r3422) - Fix: If an engine reaches the rear of a depot, make the engine turn around before it reaches the tile end (same as a normal end of line.) This fixes a bug whereby the engine could poke into the depot and crash with another engine just leaving it.
-rw-r--r--train_cmd.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 424e53b5a..114741b23 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -3294,7 +3294,7 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
TileIndex tile;
uint x,y;
uint16 break_speed;
- int t;
+ DiagDirection t;
uint32 ts;
byte trackdir;
@@ -3368,8 +3368,11 @@ static bool TrainCheckIfLineEnds(Vehicle *v)
}
if (GB(ts, 0, 16) != 0) {
- /* If we approach a rail-piece which we can't enter, don't enter it! */
- if (x + 4 > 15 && !CheckCompatibleRail(v, tile)) {
+ /* If we approach a rail-piece which we can't enter, or the back of a depot, don't enter it! */
+ if (x + 4 > 15 &&
+ (!CheckCompatibleRail(v, tile) ||
+ (IsTileDepotType(tile, TRANSPORT_RAIL) &&
+ GetDepotDirection(tile, TRANSPORT_RAIL) == t))) {
v->cur_speed = 0;
ReverseTrainDirection(v);
return false;