2006-03-24 08:55:08 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file station_map.h Maps accessors for stations. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
#ifndef STATION_MAP_H
|
|
|
|
#define STATION_MAP_H
|
|
|
|
|
2006-06-18 15:28:29 +00:00
|
|
|
#include "rail_map.h"
|
2007-05-20 19:14:08 +00:00
|
|
|
#include "road_map.h"
|
2008-02-02 09:28:43 +00:00
|
|
|
#include "water_map.h"
|
2008-03-31 00:06:17 +00:00
|
|
|
#include "station_func.h"
|
2007-12-25 23:42:52 +00:00
|
|
|
#include "rail.h"
|
2006-03-24 08:55:08 +00:00
|
|
|
|
2006-04-14 01:54:07 +00:00
|
|
|
typedef byte StationGfx;
|
|
|
|
|
2008-10-19 15:39:12 +00:00
|
|
|
/** Get Station ID from a tile
|
|
|
|
* @pre Tile \t must be part of the station
|
|
|
|
* @param t Tile to query station ID from
|
|
|
|
* @return Station ID of the station at \a t */
|
2006-03-24 08:55:08 +00:00
|
|
|
static inline StationID GetStationIndex(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-03-24 08:55:08 +00:00
|
|
|
return (StationID)_m[t].m2;
|
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
|
|
|
|
enum {
|
2007-07-16 23:55:22 +00:00
|
|
|
GFX_RADAR_LARGE_FIRST = 31,
|
|
|
|
GFX_RADAR_LARGE_LAST = 42,
|
|
|
|
GFX_WINDSACK_FIRST = 50,
|
|
|
|
GFX_WINDSACK_LAST = 53,
|
|
|
|
|
|
|
|
GFX_DOCK_BASE_WATER_PART = 4,
|
|
|
|
GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4,
|
|
|
|
|
|
|
|
GFX_RADAR_INTERNATIONAL_FIRST = 66,
|
|
|
|
GFX_RADAR_INTERNATIONAL_LAST = 77,
|
|
|
|
GFX_RADAR_METROPOLITAN_FIRST = 78,
|
|
|
|
GFX_RADAR_METROPOLITAN_LAST = 89,
|
|
|
|
GFX_RADAR_DISTRICTWE_FIRST = 121,
|
|
|
|
GFX_RADAR_DISTRICTWE_LAST = 132,
|
|
|
|
GFX_WINDSACK_INTERCON_FIRST = 140,
|
|
|
|
GFX_WINDSACK_INTERCON_LAST = 143,
|
2006-03-26 14:41:39 +00:00
|
|
|
};
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the station type of this tile
|
|
|
|
* @param t the tile to query
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return the station type
|
|
|
|
*/
|
2007-07-16 23:55:22 +00:00
|
|
|
static inline StationType GetStationType(TileIndex t)
|
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2007-07-16 23:55:22 +00:00
|
|
|
return (StationType)GB(_m[t].m6, 3, 3);
|
|
|
|
}
|
2006-03-26 14:41:39 +00:00
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the road stop type of this tile
|
|
|
|
* @param t the tile to query
|
|
|
|
* @pre GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS
|
|
|
|
* @return the road stop type
|
|
|
|
*/
|
2008-03-31 00:06:17 +00:00
|
|
|
static inline RoadStopType GetRoadStopType(TileIndex t)
|
2006-03-29 19:37:18 +00:00
|
|
|
{
|
|
|
|
assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
|
2008-03-31 00:06:17 +00:00
|
|
|
return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
|
2006-03-29 19:37:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the station graphics of this tile
|
|
|
|
* @param t the tile to query
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return the station graphics
|
|
|
|
*/
|
2006-04-14 01:54:07 +00:00
|
|
|
static inline StationGfx GetStationGfx(TileIndex t)
|
2006-04-12 20:01:52 +00:00
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
return _m[t].m5;
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Set the station graphics of this tile
|
|
|
|
* @param t the tile to update
|
|
|
|
* @param gfx the new graphics
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
*/
|
2006-04-14 01:54:07 +00:00
|
|
|
static inline void SetStationGfx(TileIndex t, StationGfx gfx)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-04-12 20:01:52 +00:00
|
|
|
_m[t].m5 = gfx;
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Get the station's animation frame of this tile
|
|
|
|
* @param t the tile to query
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return the station's animation frame
|
|
|
|
*/
|
2008-04-17 06:52:56 +00:00
|
|
|
static inline uint8 GetStationAnimationFrame(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
return _me[t].m7;
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Set the station's animation frame of this tile
|
|
|
|
* @param t the tile to update
|
|
|
|
* @param frame the new frame
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
*/
|
2008-04-17 06:52:56 +00:00
|
|
|
static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
_me[t].m7 = frame;
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is this station tile a rail station?
|
|
|
|
* @param t the tile to get the information from
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return true if and only if the tile is a rail station
|
|
|
|
*/
|
2009-07-24 11:47:12 +00:00
|
|
|
static inline bool IsRailStation(TileIndex t)
|
2006-04-12 20:01:52 +00:00
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_RAIL;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is this tile a station tile and a rail station?
|
|
|
|
* @param t the tile to get the information from
|
|
|
|
* @return true if and only if the tile is a rail station
|
|
|
|
*/
|
2009-07-24 11:47:12 +00:00
|
|
|
static inline bool IsRailStationTile(TileIndex t)
|
2006-04-04 11:35:52 +00:00
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
return IsTileType(t, MP_STATION) && IsRailStation(t);
|
2006-04-04 11:35:52 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 08:59:57 +00:00
|
|
|
/**
|
|
|
|
* Is this station tile a rail waypoint?
|
|
|
|
* @param t the tile to get the information from
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return true if and only if the tile is a rail waypoint
|
|
|
|
*/
|
|
|
|
static inline bool IsRailWaypoint(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetStationType(t) == STATION_WAYPOINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this tile a station tile and a rail waypoint?
|
|
|
|
* @param t the tile to get the information from
|
|
|
|
* @return true if and only if the tile is a rail waypoint
|
|
|
|
*/
|
|
|
|
static inline bool IsRailWaypointTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
|
|
|
|
}
|
|
|
|
|
2009-07-24 11:15:11 +00:00
|
|
|
/**
|
|
|
|
* Has this station tile a rail? In other words, is this station
|
|
|
|
* tile a rail station or rail waypoint?
|
|
|
|
* @param t the tile to check
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return true if and only if the tile has rail
|
|
|
|
*/
|
|
|
|
static inline bool HasStationRail(TileIndex t)
|
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
return IsRailStation(t) || IsRailWaypoint(t);
|
2009-07-24 11:15:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Has this station tile a rail? In other words, is this station
|
|
|
|
* tile a rail station or rail waypoint?
|
|
|
|
* @param t the tile to check
|
|
|
|
* @return true if and only if the tile is a station tile and has rail
|
|
|
|
*/
|
|
|
|
static inline bool HasStationTileRail(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && HasStationRail(t);
|
|
|
|
}
|
2009-07-22 08:59:57 +00:00
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is this station tile an airport?
|
|
|
|
* @param t the tile to get the information from
|
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return true if and only if the tile is an airport
|
|
|
|
*/
|
2007-07-16 23:55:22 +00:00
|
|
|
static inline bool IsAirport(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetStationType(t) == STATION_AIRPORT;
|
|
|
|
}
|
|
|
|
|
2007-07-24 21:48:50 +00:00
|
|
|
bool IsHangar(TileIndex t);
|
2006-03-26 14:41:39 +00:00
|
|
|
|
2008-10-19 15:39:12 +00:00
|
|
|
/**
|
|
|
|
* Is the station at \a t a truck stop?
|
|
|
|
* @param t Tile to check
|
2009-07-24 15:27:31 +00:00
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return \c true if station is a truck stop, \c false otherwise
|
|
|
|
*/
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsTruckStop(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_TRUCK;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-10-19 15:39:12 +00:00
|
|
|
/**
|
|
|
|
* Is the station at \a t a bus stop?
|
|
|
|
* @param t Tile to check
|
2009-07-24 15:27:31 +00:00
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return \c true if station is a bus stop, \c false otherwise
|
|
|
|
*/
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsBusStop(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_BUS;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-10-19 15:39:12 +00:00
|
|
|
/**
|
|
|
|
* Is the station at \a t a road station?
|
|
|
|
* @param t Tile to check
|
2009-07-24 15:27:31 +00:00
|
|
|
* @pre IsTileType(t, MP_STATION)
|
|
|
|
* @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise
|
|
|
|
*/
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsRoadStop(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-03-26 14:41:39 +00:00
|
|
|
return IsTruckStop(t) || IsBusStop(t);
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is tile \a t a road stop station?
|
|
|
|
* @param t Tile to check
|
|
|
|
* @return \c true if the tile is a station tile and a road stop
|
|
|
|
*/
|
2006-03-31 19:10:54 +00:00
|
|
|
static inline bool IsRoadStopTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsRoadStop(t);
|
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is tile \a t a standard (non-drive through) road stop station?
|
|
|
|
* @param t Tile to check
|
|
|
|
* @return \c true if the tile is a station tile and a standard road stop
|
|
|
|
*/
|
2007-02-14 16:37:16 +00:00
|
|
|
static inline bool IsStandardRoadStopTile(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 15:27:31 +00:00
|
|
|
/**
|
|
|
|
* Is tile \a t a drive through road stop station?
|
|
|
|
* @param t Tile to check
|
|
|
|
* @return \c true if the tile is a station tile and a drive through road stop
|
|
|
|
*/
|
2007-02-14 16:37:16 +00:00
|
|
|
static inline bool IsDriveThroughStopTile(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 19:10:54 +00:00
|
|
|
/**
|
|
|
|
* Gets the direction the road stop entrance points towards.
|
2009-07-24 15:27:31 +00:00
|
|
|
* @param t the tile of the road stop
|
|
|
|
* @pre IsRoadStopTile(t)
|
|
|
|
* @return the direction of the entrance
|
2006-03-31 19:10:54 +00:00
|
|
|
*/
|
2006-04-12 20:01:52 +00:00
|
|
|
static inline DiagDirection GetRoadStopDir(TileIndex t)
|
2006-03-31 19:10:54 +00:00
|
|
|
{
|
2007-02-14 16:37:16 +00:00
|
|
|
StationGfx gfx = GetStationGfx(t);
|
2006-04-12 20:01:52 +00:00
|
|
|
assert(IsRoadStopTile(t));
|
2007-07-16 23:55:22 +00:00
|
|
|
if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
|
|
|
|
return (DiagDirection)(gfx);
|
2007-02-14 16:37:16 +00:00
|
|
|
} else {
|
2007-07-16 23:55:22 +00:00
|
|
|
return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
|
2007-02-14 16:37:16 +00:00
|
|
|
}
|
2006-03-31 19:10:54 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsOilRig(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_OILRIG;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsDock(TileIndex t)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_DOCK;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 20:09:29 +00:00
|
|
|
static inline bool IsDockTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
|
|
|
|
}
|
|
|
|
|
2007-02-02 07:48:06 +00:00
|
|
|
static inline bool IsBuoy(TileIndex t)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
return GetStationType(t) == STATION_BUOY;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-04 11:35:52 +00:00
|
|
|
static inline bool IsBuoyTile(TileIndex t)
|
|
|
|
{
|
2007-02-02 07:48:06 +00:00
|
|
|
return IsTileType(t, MP_STATION) && IsBuoy(t);
|
2006-04-04 11:35:52 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 19:20:15 +00:00
|
|
|
static inline bool IsHangarTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsHangar(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline Axis GetRailStationAxis(TileIndex t)
|
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
assert(HasStationRail(t));
|
2007-11-19 21:02:30 +00:00
|
|
|
return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline Track GetRailStationTrack(TileIndex t)
|
|
|
|
{
|
2006-07-22 08:59:52 +00:00
|
|
|
return AxisToTrack(GetRailStationAxis(t));
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2009-05-26 22:03:16 +00:00
|
|
|
static inline TrackBits GetRailStationTrackBits(TileIndex t)
|
|
|
|
{
|
|
|
|
return AxisToTrackBits(GetRailStationAxis(t));
|
|
|
|
}
|
|
|
|
|
2006-04-04 11:51:16 +00:00
|
|
|
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
assert(IsRailStationTile(t2));
|
2006-04-04 11:51:16 +00:00
|
|
|
return
|
2009-07-24 11:47:12 +00:00
|
|
|
IsRailStationTile(t1) &&
|
2006-04-04 11:51:16 +00:00
|
|
|
IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
|
2006-05-06 22:08:14 +00:00
|
|
|
GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
|
2008-01-27 02:09:46 +00:00
|
|
|
GetStationIndex(t1) == GetStationIndex(t2) &&
|
2006-05-06 22:08:14 +00:00
|
|
|
!IsStationTileBlocked(t1);
|
2006-04-04 11:51:16 +00:00
|
|
|
}
|
|
|
|
|
2008-08-02 22:47:20 +00:00
|
|
|
/**
|
|
|
|
* Get the reservation state of the rail station
|
2009-07-24 11:47:12 +00:00
|
|
|
* @pre HasStationRail(t)
|
2008-08-02 22:47:20 +00:00
|
|
|
* @param t the station tile
|
|
|
|
* @return reservation state
|
|
|
|
*/
|
2009-07-21 22:37:10 +00:00
|
|
|
static inline bool HasStationReservation(TileIndex t)
|
2008-08-02 22:47:20 +00:00
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
assert(HasStationRail(t));
|
2008-08-02 22:47:20 +00:00
|
|
|
return HasBit(_m[t].m6, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the reservation state of the rail station
|
2009-07-24 11:47:12 +00:00
|
|
|
* @pre HasStationRail(t)
|
2008-08-02 22:47:20 +00:00
|
|
|
* @param t the station tile
|
|
|
|
* @param b the reservation state
|
|
|
|
*/
|
2009-07-24 11:47:12 +00:00
|
|
|
static inline void SetRailStationReservation(TileIndex t, bool b)
|
2008-08-02 22:47:20 +00:00
|
|
|
{
|
2009-07-24 11:47:12 +00:00
|
|
|
assert(HasStationRail(t));
|
2008-08-02 22:47:20 +00:00
|
|
|
SB(_m[t].m6, 2, 1, b ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the reserved track bits for a waypoint
|
2009-07-24 11:47:12 +00:00
|
|
|
* @pre HasStationRail(t)
|
2008-08-02 22:47:20 +00:00
|
|
|
* @param t the tile
|
|
|
|
* @return reserved track bits
|
|
|
|
*/
|
2009-07-21 22:37:10 +00:00
|
|
|
static inline TrackBits GetStationReservationTrackBits(TileIndex t)
|
2008-08-02 22:47:20 +00:00
|
|
|
{
|
2009-07-21 22:37:10 +00:00
|
|
|
return HasStationReservation(t) ? GetRailStationTrackBits(t) : TRACK_BIT_NONE;
|
2008-08-02 22:47:20 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
|
|
|
|
static inline DiagDirection GetDockDirection(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
StationGfx gfx = GetStationGfx(t);
|
2007-07-16 23:55:22 +00:00
|
|
|
assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
|
|
|
|
return (DiagDirection)(gfx);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-07 15:57:03 +00:00
|
|
|
static inline TileIndexDiffC GetDockOffset(TileIndex t)
|
|
|
|
{
|
|
|
|
static const TileIndexDiffC buoy_offset = {0, 0};
|
|
|
|
static const TileIndexDiffC oilrig_offset = {2, 0};
|
|
|
|
static const TileIndexDiffC dock_offset[DIAGDIR_END] = {
|
|
|
|
{-2, 0},
|
|
|
|
{ 0, 2},
|
|
|
|
{ 2, 0},
|
|
|
|
{ 0, -2},
|
|
|
|
};
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
|
2007-02-02 07:48:06 +00:00
|
|
|
if (IsBuoy(t)) return buoy_offset;
|
2006-04-07 15:57:03 +00:00
|
|
|
if (IsOilRig(t)) return oilrig_offset;
|
|
|
|
|
|
|
|
assert(IsDock(t));
|
|
|
|
|
|
|
|
return dock_offset[GetDockDirection(t)];
|
|
|
|
}
|
2006-03-26 14:41:39 +00:00
|
|
|
|
2006-04-16 17:29:37 +00:00
|
|
|
static inline bool IsCustomStationSpecIndex(TileIndex t)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-04-16 17:29:37 +00:00
|
|
|
return _m[t].m4 != 0;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-16 17:29:37 +00:00
|
|
|
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-04-16 17:29:37 +00:00
|
|
|
_m[t].m4 = specindex;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-16 17:29:37 +00:00
|
|
|
static inline uint GetCustomStationSpecIndex(TileIndex t)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_STATION));
|
2006-03-26 14:41:39 +00:00
|
|
|
return _m[t].m4;
|
|
|
|
}
|
|
|
|
|
2006-05-03 21:25:49 +00:00
|
|
|
static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
SB(_m[t].m3, 4, 4, random_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline byte GetStationTileRandomBits(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_STATION));
|
|
|
|
return GB(_m[t].m3, 4, 4);
|
|
|
|
}
|
|
|
|
|
2007-07-16 23:55:22 +00:00
|
|
|
static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_STATION);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = sid;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0;
|
2007-07-16 23:55:22 +00:00
|
|
|
_m[t].m5 = section;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 1, 0);
|
2007-07-16 23:55:22 +00:00
|
|
|
SB(_m[t].m6, 3, 3, st);
|
2009-03-08 16:10:39 +00:00
|
|
|
_me[t].m7 = 0;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
MakeStation(t, o, sid, STATION_RAIL, section + a);
|
2006-03-26 14:41:39 +00:00
|
|
|
SetRailType(t, rt);
|
2009-07-24 11:47:12 +00:00
|
|
|
SetRailStationReservation(t, false);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 08:59:57 +00:00
|
|
|
static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
|
|
|
|
{
|
|
|
|
MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
|
|
|
|
SetRailType(t, rt);
|
2009-07-24 11:47:12 +00:00
|
|
|
SetRailStationReservation(t, false);
|
2009-07-22 08:59:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-31 00:06:17 +00:00
|
|
|
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2008-03-31 00:06:17 +00:00
|
|
|
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
|
2007-05-20 19:14:08 +00:00
|
|
|
SetRoadTypes(t, rt);
|
2009-03-02 22:57:47 +00:00
|
|
|
SetRoadOwner(t, ROADTYPE_ROAD, o);
|
|
|
|
SetRoadOwner(t, ROADTYPE_TRAM, o);
|
2007-02-21 19:46:37 +00:00
|
|
|
}
|
|
|
|
|
2009-03-02 22:57:47 +00:00
|
|
|
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a)
|
2007-02-21 19:46:37 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
|
2007-05-20 19:14:08 +00:00
|
|
|
SetRoadTypes(t, rt);
|
2009-03-02 22:57:47 +00:00
|
|
|
SetRoadOwner(t, ROADTYPE_ROAD, road);
|
|
|
|
SetRoadOwner(t, ROADTYPE_TRAM, tram);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
|
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
MakeStation(t, o, sid, STATION_AIRPORT, section);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2007-02-07 17:52:21 +00:00
|
|
|
/* Make the owner of the buoy tile the same as the current owner of the
|
|
|
|
* water tile. In this way, we can reset the owner of the water to its
|
|
|
|
* original state when the buoy gets removed. */
|
2007-07-16 23:55:22 +00:00
|
|
|
MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0);
|
2008-02-02 09:28:43 +00:00
|
|
|
SetWaterClass(t, wc);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-02-02 09:28:43 +00:00
|
|
|
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
MakeStation(t, o, sid, STATION_DOCK, d);
|
|
|
|
MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
|
2008-02-02 09:28:43 +00:00
|
|
|
SetWaterClass(t + TileOffsByDiagDir(d), wc);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2008-07-26 16:14:10 +00:00
|
|
|
static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
|
2006-03-26 14:41:39 +00:00
|
|
|
{
|
2007-07-16 23:55:22 +00:00
|
|
|
MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
|
2008-07-26 16:14:10 +00:00
|
|
|
SetWaterClass(t, wc);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* STATION_MAP_H */
|