2006-03-24 08:55:08 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
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"
|
2006-03-24 08:55:08 +00:00
|
|
|
#include "station.h"
|
|
|
|
|
2006-04-14 01:54:07 +00:00
|
|
|
typedef byte StationGfx;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Station* GetStationByTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetStation(GetStationIndex(t));
|
|
|
|
}
|
2006-03-26 14:41:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum {
|
2006-04-14 01:54:07 +00:00
|
|
|
GFX_RAILWAY_BASE = 0,
|
|
|
|
GFX_AIRPORT_BASE = 8,
|
|
|
|
GFX_RADAR_LARGE_FIRST = 39,
|
|
|
|
GFX_RADAR_LARGE_LAST = 50,
|
|
|
|
GFX_WINDSACK_FIRST = 58,
|
|
|
|
GFX_WINDSACK_LAST = 61,
|
|
|
|
GFX_TRUCK_BASE = 67,
|
|
|
|
GFX_BUS_BASE = 71,
|
|
|
|
GFX_OILRIG_BASE = 75,
|
|
|
|
GFX_DOCK_BASE = 76,
|
|
|
|
GFX_DOCK_BASE_WATER_PART = 80,
|
|
|
|
GFX_BUOY_BASE = 82,
|
|
|
|
GFX_AIRPORT_BASE_EXTENDED = 83,
|
|
|
|
GFX_RADAR_INTERNATIONAL_FIRST = 90,
|
|
|
|
GFX_RADAR_INTERNATIONAL_LAST = 101,
|
|
|
|
GFX_RADAR_METROPOLITAN_FIRST = 102,
|
|
|
|
GFX_RADAR_METROPOLITAN_LAST = 113,
|
2006-06-23 22:05:40 +00:00
|
|
|
GFX_RADAR_DISTRICTWE_FIRST = 145,
|
|
|
|
GFX_RADAR_DISTRICTWE_LAST = 156,
|
2006-06-25 13:42:37 +00:00
|
|
|
GFX_WINDSACK_INTERCON_FIRST = 164,
|
|
|
|
GFX_WINDSACK_INTERCON_LAST = 167,
|
2006-07-14 09:02:53 +00:00
|
|
|
GFX_BASE_END = 168
|
2006-03-26 14:41:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2006-04-14 01:54:07 +00:00
|
|
|
RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
|
|
|
|
AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
|
|
|
|
TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
|
|
|
|
BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
|
|
|
|
DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
|
|
|
|
AIRPORT_SIZE_EXTENDED = GFX_BASE_END - GFX_AIRPORT_BASE_EXTENDED
|
2006-03-26 14:41:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum HangarTiles {
|
|
|
|
HANGAR_TILE_0 = 32,
|
2006-03-26 19:03:03 +00:00
|
|
|
HANGAR_TILE_1 = 65,
|
2006-06-23 22:05:40 +00:00
|
|
|
HANGAR_TILE_2 = 86,
|
|
|
|
HANGAR_TILE_3 = 129, // added for west facing hangar
|
|
|
|
HANGAR_TILE_4 = 130, // added for north facing hangar
|
|
|
|
HANGAR_TILE_5 = 131 // added for east facing hangar
|
2006-03-26 14:41:39 +00:00
|
|
|
} HangarTiles;
|
|
|
|
|
|
|
|
typedef enum StationType {
|
|
|
|
STATION_RAIL,
|
|
|
|
STATION_AIRPORT,
|
|
|
|
STATION_TRUCK,
|
|
|
|
STATION_BUS,
|
|
|
|
STATION_OILRIG,
|
|
|
|
STATION_DOCK,
|
|
|
|
STATION_BUOY
|
|
|
|
} StationType;
|
|
|
|
|
|
|
|
StationType GetStationType(TileIndex);
|
|
|
|
|
2006-03-29 19:37:18 +00:00
|
|
|
static inline RoadStopType GetRoadStopType(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
|
|
|
|
return GetStationType(t) == STATION_TRUCK ? RS_TRUCK : RS_BUS;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsRailwayStation(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return GetStationGfx(t) < GFX_RAILWAY_BASE + RAILWAY_SIZE;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-04 11:35:52 +00:00
|
|
|
static inline bool IsRailwayStationTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsRailwayStation(t);
|
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsHangar(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
StationGfx gfx = GetStationGfx(t);
|
2006-03-26 19:03:03 +00:00
|
|
|
return
|
2006-04-12 20:01:52 +00:00
|
|
|
gfx == HANGAR_TILE_0 ||
|
|
|
|
gfx == HANGAR_TILE_1 ||
|
2006-06-23 22:05:40 +00:00
|
|
|
gfx == HANGAR_TILE_2 ||
|
|
|
|
gfx == HANGAR_TILE_3 ||
|
|
|
|
gfx == HANGAR_TILE_4 ||
|
|
|
|
gfx == HANGAR_TILE_5;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsAirport(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
StationGfx gfx = GetStationGfx(t);
|
2006-03-26 14:41:39 +00:00
|
|
|
return
|
2006-04-14 01:54:07 +00:00
|
|
|
(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE, GFX_AIRPORT_BASE + AIRPORT_SIZE)) ||
|
|
|
|
(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsTruckStop(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsBusStop(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsRoadStop(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTruckStop(t) || IsBusStop(t);
|
|
|
|
}
|
|
|
|
|
2006-03-31 19:10:54 +00:00
|
|
|
static inline bool IsRoadStopTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsRoadStop(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the direction the road stop entrance points towards.
|
|
|
|
*/
|
2006-04-12 20:01:52 +00:00
|
|
|
static inline DiagDirection GetRoadStopDir(TileIndex t)
|
2006-03-31 19:10:54 +00:00
|
|
|
{
|
2006-04-12 20:01:52 +00:00
|
|
|
assert(IsRoadStopTile(t));
|
2006-05-27 16:12:16 +00:00
|
|
|
return (DiagDirection)((GetStationGfx(t) - GFX_TRUCK_BASE) & 3);
|
2006-03-31 19:10:54 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline bool IsOilRig(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return GetStationGfx(t) == GFX_OILRIG_BASE;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsDock(TileIndex t)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return IS_BYTE_INSIDE(GetStationGfx(t), GFX_DOCK_BASE, GFX_DOCK_BASE + DOCK_SIZE_TOTAL);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
return GetStationGfx(t) == GFX_BUOY_BASE;
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
2006-04-04 11:35:52 +00:00
|
|
|
static inline bool IsBuoyTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_STATION) && IsBuoy_(t);
|
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +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)
|
|
|
|
{
|
2006-04-12 20:33:01 +00:00
|
|
|
assert(IsRailwayStation(t));
|
2006-04-12 20:01:52 +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
|
|
|
}
|
|
|
|
|
2006-04-04 11:51:16 +00:00
|
|
|
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
|
|
|
{
|
|
|
|
assert(IsRailwayStationTile(t2));
|
|
|
|
return
|
|
|
|
IsRailwayStationTile(t1) &&
|
|
|
|
IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
|
2006-05-06 22:08:14 +00:00
|
|
|
GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
|
|
|
|
!IsStationTileBlocked(t1);
|
2006-04-04 11:51:16 +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);
|
|
|
|
assert(gfx < GFX_DOCK_BASE_WATER_PART);
|
|
|
|
return (DiagDirection)(gfx - GFX_DOCK_BASE);
|
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));
|
|
|
|
|
|
|
|
if (IsBuoy_(t)) return buoy_offset;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-03-26 14:41:39 +00:00
|
|
|
static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
|
|
|
|
{
|
|
|
|
SetTileType(t, MP_STATION);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = sid;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = m5;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
|
|
|
|
{
|
|
|
|
MakeStation(t, o, sid, section + a);
|
|
|
|
SetRailType(t, rt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, DiagDirection d)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
MakeStation(t, o, sid, (rst == RS_BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
|
|
|
|
{
|
|
|
|
MakeStation(t, o, sid, section);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeBuoy(TileIndex t, StationID sid)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
MakeStation(t, OWNER_NONE, sid, GFX_BUOY_BASE);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
MakeStation(t, o, sid, GFX_DOCK_BASE + d);
|
|
|
|
MakeStation(t + TileOffsByDir(d), o, sid, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeOilrig(TileIndex t, StationID sid)
|
|
|
|
{
|
2006-04-14 01:54:07 +00:00
|
|
|
MakeStation(t, OWNER_NONE, sid, GFX_OILRIG_BASE);
|
2006-03-26 14:41:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|