Mercurial > hg > openttd
changeset 3442:911176578d1b draft
(svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
author | celestar <celestar@openttd.org> |
---|---|
date | Tue, 04 Apr 2006 11:35:52 +0000 |
parents | 19e6251b72ba |
children | 32d5a01e3738 |
files | npf.c rail.c ship_cmd.c station.h station_map.h |
diffstat | 5 files changed, 23 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/npf.c +++ b/npf.c @@ -457,7 +457,7 @@ 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 */
--- a/rail.c +++ b/rail.c @@ -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 @@ break; case MP_STATION: - if (IsTrainStationTile(tile)) return GetRailType(tile); + if (IsRailwayStationTile(tile)) return GetRailType(tile); break; case MP_TUNNELBRIDGE:
--- 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"
--- a/station.h +++ b/station.h @@ -198,20 +198,6 @@ 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 @@ 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 */
--- a/station_map.h +++ b/station_map.h @@ -71,6 +71,20 @@ 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 @@ 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) {