diff options
-rw-r--r-- | rail.h | 8 | ||||
-rw-r--r-- | train_cmd.c | 3 | ||||
-rw-r--r-- | train_gui.c | 4 |
3 files changed, 11 insertions, 4 deletions
@@ -505,7 +505,13 @@ static inline TransportType GetCrossingTransportType(TileIndex tile, Track track */ static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype) { - return enginetype == tiletype; + static const bool EquivRailTypes[RAILTYPE_END][RAILTYPE_END] = { + { true, false, false }, + { false, true, false }, + { false, false, true }, + }; + + return EquivRailTypes[enginetype][tiletype]; } #endif // RAIL_H diff --git a/train_cmd.c b/train_cmd.c index d8ac7a051..b23c6e9e4 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -2542,7 +2542,8 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile) return IsTileOwner(tile, v->owner) && - (v->subtype != TS_Front_Engine || (_map3_lo[tile] & 0xF) == v->u.rail.railtype); + (v->subtype != TS_Front_Engine || + IsCompatibleRail(v->u.rail.railtype, GetRailType(tile))); } typedef struct { diff --git a/train_gui.c b/train_gui.c index fe0492646..5d070244d 100644 --- a/train_gui.c +++ b/train_gui.c @@ -160,7 +160,7 @@ static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, const Engine *e = GetEngine(i); const RailVehicleInfo *rvi = RailVehInfo(i); - if (e->railtype != railtype || !(rvi->flags & RVI_WAGON) != is_engine || + if (!IsCompatibleRail(railtype, e->railtype) || !(rvi->flags & RVI_WAGON) != is_engine || !HASBIT(e->player_avail, _local_player)) continue; @@ -192,7 +192,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) for (i = 0; i < NUM_TRAIN_ENGINES; i++) { const Engine *e = GetEngine(i); - if (e->railtype == railtype + if (IsCompatibleRail(railtype, e->railtype) && HASBIT(e->player_avail, _local_player)) count++; } |