8
8
#include "rail_map.h"
9
9
#include "road_map.h"
10
10
#include "water_map.h"
11
#include "station_func.h"
12
#include "station_base.h"
14
15
typedef byte StationGfx;
17
/** Get Station ID from a tile
18
* @pre Tile \t must be part of the station
19
* @param t Tile to query station ID from
20
* @return Station ID of the station at \a t */
16
21
static inline StationID GetStationIndex(TileIndex t)
18
23
assert(IsTileType(t, MP_STATION));
49
54
return (StationType)GB(_m[t].m6, 3, 3);
52
static inline RoadStop::Type GetRoadStopType(TileIndex t)
57
static inline RoadStopType GetRoadStopType(TileIndex t)
54
59
assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
55
return GetStationType(t) == STATION_TRUCK ? RoadStop::TRUCK : RoadStop::BUS;
60
return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
58
63
static inline StationGfx GetStationGfx(TileIndex t)
75
static inline uint8 GetStationAnimationFrame(TileIndex t)
77
assert(IsTileType(t, MP_STATION));
81
static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
83
assert(IsTileType(t, MP_STATION));
70
87
static inline bool IsRailwayStation(TileIndex t)
72
89
return GetStationType(t) == STATION_RAIL;
85
102
bool IsHangar(TileIndex t);
105
* Is the station at \a t a truck stop?
106
* @param t Tile to check
107
* @return \c true if station is a truck stop, \c false otherwise */
87
108
static inline bool IsTruckStop(TileIndex t)
89
110
return GetStationType(t) == STATION_TRUCK;
114
* Is the station at \a t a bus stop?
115
* @param t Tile to check
116
* @return \c true if station is a bus stop, \c false otherwise */
92
117
static inline bool IsBusStop(TileIndex t)
94
119
return GetStationType(t) == STATION_BUS;
123
* Is the station at \a t a road station?
124
* @pre Tile at \a t is a station tile
125
* @param t Tile to check
126
* @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise */
97
127
static inline bool IsRoadStop(TileIndex t)
99
129
assert(IsTileType(t, MP_STATION));
185
213
!IsStationTileBlocked(t1);
217
* Get the reservation state of the rail station
218
* @pre IsRailwayStationTile(t)
219
* @param t the station tile
220
* @return reservation state
222
static inline bool GetRailwayStationReservation(TileIndex t)
224
assert(IsRailwayStationTile(t));
225
return HasBit(_m[t].m6, 2);
229
* Set the reservation state of the rail station
230
* @pre IsRailwayStationTile(t)
231
* @param t the station tile
232
* @param b the reservation state
234
static inline void SetRailwayStationReservation(TileIndex t, bool b)
236
assert(IsRailwayStationTile(t));
237
SB(_m[t].m6, 2, 1, b ? 1 : 0);
241
* Get the reserved track bits for a waypoint
242
* @pre IsRailwayStationTile(t)
244
* @return reserved track bits
246
static inline TrackBits GetRailStationReservation(TileIndex t)
248
return GetRailwayStationReservation(t) ? AxisToTrackBits(GetRailStationAxis(t)) : TRACK_BIT_NONE;
189
252
static inline DiagDirection GetDockDirection(TileIndex t)
253
316
_m[t].m5 = section;
317
SB(_m[t].m6, 2, 1, 0);
254
318
SB(_m[t].m6, 3, 3, st);
257
322
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
259
324
MakeStation(t, o, sid, STATION_RAIL, section + a);
260
325
SetRailType(t, rt);
263
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
265
MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), d);
269
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
271
MakeStation(t, o, sid, (rst == RoadStop::BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
272
SB(_m[t].m6, 2, 1, on_town_road);
326
SetRailwayStationReservation(t, false);
329
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
331
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
333
SetRoadOwner(t, ROADTYPE_ROAD, o);
334
SetRoadOwner(t, ROADTYPE_TRAM, o);
337
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadTypes rt, Axis a)
339
MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
341
SetRoadOwner(t, ROADTYPE_ROAD, road);
342
SetRoadOwner(t, ROADTYPE_TRAM, tram);
276
345
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
294
363
SetWaterClass(t + TileOffsByDiagDir(d), wc);
297
static inline void MakeOilrig(TileIndex t, StationID sid)
366
static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
299
368
MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
369
SetWaterClass(t, wc);
302
372
#endif /* STATION_MAP_H */