diff options
-rw-r--r-- | npf.c | 2 | ||||
-rw-r--r-- | rail.c | 4 | ||||
-rw-r--r-- | ship_cmd.c | 1 | ||||
-rw-r--r-- | station.h | 19 | ||||
-rw-r--r-- | station_map.h | 19 |
5 files changed, 23 insertions, 22 deletions
@@ -457,7 +457,7 @@ static void NPFSaveTargetData(AyStar* as, OpenListNode* current) static bool VehicleMayEnterTile(Owner owner, TileIndex tile, DiagDirection enterdir) { if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */ - IsTrainStationTile(tile) || /* Rail station tile */ + IsRailwayStationTile(tile) || /* Rail station tile */ IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */ IsRoadStopTile(tile) || /* Road station tile */ IsTileDepotType(tile, TRANSPORT_WATER)) { /* Water depot tile */ @@ -4,7 +4,7 @@ #include "openttd.h" #include "bridge_map.h" #include "rail.h" -#include "station.h" +#include "station_map.h" #include "tunnel_map.h" /* XXX: Below 3 tables store duplicate data. Maybe remove some? */ @@ -119,7 +119,7 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir) break; case MP_STATION: - if (IsTrainStationTile(tile)) return GetRailType(tile); + if (IsRailwayStationTile(tile)) return GetRailType(tile); break; case MP_TUNNELBRIDGE: diff --git a/ship_cmd.c b/ship_cmd.c index 0fd9387c0..c3da57ab0 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -9,6 +9,7 @@ #include "vehicle.h" #include "command.h" #include "pathfind.h" +#include "station_map.h" #include "station.h" #include "news.h" #include "engine.h" @@ -198,20 +198,6 @@ uint GetNumRoadStops(const Station* st, RoadStopType type); RoadStop * AllocateRoadStop( void ); void ClearSlot(Vehicle *v); -static inline bool IsTrainStationTile(TileIndex tile) -{ - return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8); -} - -static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref) -{ - assert(IsTrainStationTile(ref)); - return - IsTrainStationTile(tile) && - GB(_m[tile].m3, 0, 4) == GB(_m[ref].m3, 0, 4) && // same rail type? - GB(_m[tile].m5, 0, 1) == GB(_m[ref].m5, 0, 1); // same direction? -} - /** * Check if a station really exists. */ @@ -225,9 +211,4 @@ static inline bool IsBuoy(const Station* st) return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */ } -static inline bool IsBuoyTile(TileIndex tile) -{ - return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52; -} - #endif /* STATION_H */ diff --git a/station_map.h b/station_map.h index e0ed3def0..c60a69b39 100644 --- a/station_map.h +++ b/station_map.h @@ -71,6 +71,20 @@ static inline bool IsRailwayStation(TileIndex t) return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE; } +static inline bool IsRailwayStationTile(TileIndex t) +{ + return IsTileType(t, MP_STATION) && IsRailwayStation(t); +} + +static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2) +{ + assert(IsRailwayStationTile(t2)); + return + IsRailwayStationTile(t1) && + GB(_m[t1].m3, 0, 4) == GB(_m[t2].m3, 0, 4) && // same rail type? + GB(_m[t1].m5, 0, 1) == GB(_m[t2].m5, 0, 1); // same direction? +} + static inline bool IsHangar(TileIndex t) { assert(IsTileType(t, MP_STATION)); @@ -137,6 +151,11 @@ static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict return _m[t].m5 == BUOY_BASE; } +static inline bool IsBuoyTile(TileIndex t) +{ + return IsTileType(t, MP_STATION) && IsBuoy_(t); +} + static inline bool IsHangarTile(TileIndex t) { |