summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-04-12 10:31:26 +0000
committertron <tron@openttd.org>2005-04-12 10:31:26 +0000
commit53d30138b2f852e0785226b1aed4c5551bb896eb (patch)
treebe6e75493ba88f6d4885bd8228137a4c769d583f
parentbeb185248bee0a2f8d04bb9e92608a8618c75970 (diff)
downloadopenttd-53d30138b2f852e0785226b1aed4c5551bb896eb.tar.xz
(svn r2189) Introduce and use IsCompatibleTrainStationTile()
This should prevent trains, which are longer than the station, to turn around without stopping under certain circumstances and fix speed limit for trains entering a station, when realistic accerlation is used
-rw-r--r--station.h9
-rw-r--r--station_cmd.c2
-rw-r--r--train_cmd.c2
3 files changed, 11 insertions, 2 deletions
diff --git a/station.h b/station.h
index f76eda227..2ac2e5403 100644
--- a/station.h
+++ b/station.h
@@ -276,6 +276,15 @@ static inline bool IsTrainStationTile(uint tile) {
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8);
}
+static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
+{
+ assert(IsTrainStationTile(ref));
+ return
+ IsTrainStationTile(tile) &&
+ (_map3_lo[tile] & 0x0F) == (_map3_lo[ref] & 0x0F) && // same rail type?
+ (_map5[tile] & 0x01) == (_map5[ref] & 0x01); // same direction?
+}
+
static inline bool IsRoadStationTile(uint tile) {
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0x43, 0x4B);
}
diff --git a/station_cmd.c b/station_cmd.c
index e6f65385c..aac4b928a 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2322,7 +2322,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
if (v->type == VEH_Train) {
if (IS_BYTE_INSIDE(_map5[tile], 0, 8) && v->subtype == TS_Front_Engine &&
- !IsTrainStationTile(tile + TileOffsByDir(v->direction >> 1))) {
+ !IsCompatibleTrainStationTile(tile + TileOffsByDir(v->direction >> 1), tile)) {
station_id = _map2[tile];
if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) ||
diff --git a/train_cmd.c b/train_cmd.c
index c2aa26eaa..b10090732 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -154,7 +154,7 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
do {
station_length++;
tile = TILE_ADD(tile, TileOffsByDir(v->direction / 2));
- } while (IsTrainStationTile(tile) && (_map5[tile] & 1) == (_map5[v->tile] & 1));
+ } while (IsCompatibleTrainStationTile(tile, v->tile));
delta_v = v->cur_speed / (station_length + 1);
if (v->max_speed > (v->cur_speed - delta_v))