equal
deleted
inserted
replaced
40 #include "yapf/yapf.h" |
40 #include "yapf/yapf.h" |
41 #include "date.h" |
41 #include "date.h" |
42 #include "cargotype.h" |
42 #include "cargotype.h" |
43 #include "group.h" |
43 #include "group.h" |
44 #include "table/sprites.h" |
44 #include "table/sprites.h" |
|
45 #include "tunnelbridge_map.h" |
|
46 |
45 |
47 |
46 static bool TrainCheckIfLineEnds(Vehicle *v); |
48 static bool TrainCheckIfLineEnds(Vehicle *v); |
47 static void TrainController(Vehicle *v, bool update_image); |
49 static void TrainController(Vehicle *v, bool update_image); |
48 |
50 |
49 static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8}; |
51 static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8}; |
3055 if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge |
3057 if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge |
3056 TileIndex endtile = IsTunnel(v->tile) ? GetOtherTunnelEnd(v->tile) : GetOtherBridgeEnd(v->tile); |
3058 TileIndex endtile = IsTunnel(v->tile) ? GetOtherTunnelEnd(v->tile) : GetOtherBridgeEnd(v->tile); |
3057 |
3059 |
3058 if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy |
3060 if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy |
3059 |
3061 |
3060 DiagDirection dir = IsTunnel(v->tile) ? GetTunnelDirection(v->tile) : GetBridgeRampDirection(v->tile); |
3062 DiagDirection dir = IsTunnel(v->tile) ? GetTunnelBridgeDirection(v->tile) : GetTunnelBridgeDirection(v->tile); |
3061 |
3063 |
3062 /* v->direction is "random", so it cannot be used to determine the direction of the track */ |
3064 /* v->direction is "random", so it cannot be used to determine the direction of the track */ |
3063 UpdateSignalsOnSegment(v->tile, dir); |
3065 UpdateSignalsOnSegment(v->tile, dir); |
3064 UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir)); |
3066 UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir)); |
3065 } |
3067 } |
3172 if (v->u.rail.track == TRACK_BIT_DEPOT) return true; // exit if inside a depot |
3174 if (v->u.rail.track == TRACK_BIT_DEPOT) return true; // exit if inside a depot |
3173 |
3175 |
3174 TileIndex tile = v->tile; |
3176 TileIndex tile = v->tile; |
3175 |
3177 |
3176 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
3178 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
3177 DiagDirection dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile); |
3179 DiagDirection dir = IsTunnel(tile) ? GetTunnelBridgeDirection(tile) : GetTunnelBridgeDirection(tile); |
3178 if (DiagDirToDir(dir) == v->direction) return true; |
3180 if (DiagDirToDir(dir) == v->direction) return true; |
3179 } |
3181 } |
3180 |
3182 |
3181 // depot? |
3183 // depot? |
3182 /* XXX -- When enabled, this makes it possible to crash trains of others |
3184 /* XXX -- When enabled, this makes it possible to crash trains of others |