station_map.h
author tron
Tue, 04 Apr 2006 06:04:54 +0000
changeset 3440 811c85e5ca0f
parent 3404 eb8ebfe5df67
child 3442 41d828e2d5ab
permissions -rw-r--r--
(svn r4270) Rename some bogus map5 to gfx
3315
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     1
/* $Id$ */
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     2
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     3
#ifndef STATION_MAP_H
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     4
#define STATION_MAP_H
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     5
3315
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     6
#include "station.h"
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     7
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     8
static inline StationID GetStationIndex(TileIndex t)
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     9
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    10
	assert(IsTileType(t, MP_STATION));
3315
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    11
	return (StationID)_m[t].m2;
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    12
}
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    13
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    14
static inline Station* GetStationByTile(TileIndex t)
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    15
{
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    16
	return GetStation(GetStationIndex(t));
c9d989783c55 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    17
}
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    18
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    19
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    20
enum {
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    21
	RAILWAY_BASE = 0x0,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    22
	AIRPORT_BASE = 0x8,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    23
	TRUCK_BASE = 0x43,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    24
	BUS_BASE = 0x47,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    25
	OILRIG_BASE = 0x4B,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    26
	DOCK_BASE = 0x4C,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    27
	DOCK_BASE_WATER_PART = 0x50,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    28
	BUOY_BASE = 0x52,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    29
	AIRPORT_BASE_EXTENDED = 0x53,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    30
3353
d7309672109b (svn r4143) -[FS#86]: Fixed and obi-wan error in station_map.h that would lead to assertions in the airport handling (of international airports)
celestar
parents: 3338
diff changeset
    31
	BASE_END = 0x73
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    32
};
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    33
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    34
enum {
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    35
	RAILWAY_SIZE = AIRPORT_BASE - RAILWAY_BASE,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    36
	AIRPORT_SIZE = TRUCK_BASE - AIRPORT_BASE,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    37
	TRUCK_SIZE = BUS_BASE - TRUCK_BASE,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    38
	BUS_SIZE = OILRIG_BASE - BUS_BASE,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    39
	DOCK_SIZE_TOTAL = BUOY_BASE - DOCK_BASE,
3353
d7309672109b (svn r4143) -[FS#86]: Fixed and obi-wan error in station_map.h that would lead to assertions in the airport handling (of international airports)
celestar
parents: 3338
diff changeset
    40
	AIRPORT_SIZE_EXTENDED = BASE_END - AIRPORT_BASE_EXTENDED
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    41
};
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    42
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    43
typedef enum HangarTiles {
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    44
	HANGAR_TILE_0 = 32,
3337
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    45
	HANGAR_TILE_1 = 65,
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    46
	HANGAR_TILE_2 = 86
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    47
} HangarTiles;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    48
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    49
typedef enum StationType {
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    50
	STATION_RAIL,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    51
	STATION_HANGAR,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    52
	STATION_AIRPORT,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    53
	STATION_TRUCK,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    54
	STATION_BUS,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    55
	STATION_OILRIG,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    56
	STATION_DOCK,
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    57
	STATION_BUOY
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    58
} StationType;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    59
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    60
StationType GetStationType(TileIndex);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    61
3360
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    62
static inline RoadStopType GetRoadStopType(TileIndex t)
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    63
{
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    64
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    65
	return GetStationType(t) == STATION_TRUCK ? RS_TRUCK : RS_BUS;
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    66
}
4fddbd48d36c (svn r4155) -Changed GetRoadStopByTile to use GetStationType and moved it. TODO: unify RS_TRUCK and STATION_TRUCK (same for bus)
celestar
parents: 3353
diff changeset
    67
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    68
static inline bool IsRailwayStation(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    69
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    70
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    71
	return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    72
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    73
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    74
static inline bool IsHangar(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    75
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    76
	assert(IsTileType(t, MP_STATION));
3337
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    77
	return
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    78
		_m[t].m5 == HANGAR_TILE_0 ||
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    79
		_m[t].m5 == HANGAR_TILE_1 ||
3a9b086c6369 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    80
		_m[t].m5 == HANGAR_TILE_2;
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    81
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    82
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    83
static inline bool IsAirport(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    84
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    85
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    86
	return
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    87
		IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) ||
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    88
		IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    89
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    90
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    91
static inline bool IsTruckStop(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    92
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    93
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    94
	return IS_INT_INSIDE(_m[t].m5, TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    95
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    96
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    97
static inline bool IsBusStop(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    98
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    99
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   100
	return IS_INT_INSIDE(_m[t].m5, BUS_BASE, BUS_BASE + BUS_SIZE);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   101
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   102
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   103
static inline bool IsRoadStop(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   104
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   105
	return IsTruckStop(t) || IsBusStop(t);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   106
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   107
3404
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   108
static inline bool IsRoadStopTile(TileIndex t)
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   109
{
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   110
	return IsTileType(t, MP_STATION) && IsRoadStop(t);
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   111
}
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   112
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   113
/**
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   114
 * Gets the direction the road stop entrance points towards.
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   115
 */
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   116
static inline DiagDirection GetRoadStopDir(TileIndex tile)
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   117
{
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   118
	assert(IsRoadStopTile(tile));
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   119
	return (_m[tile].m5 - TRUCK_BASE) & 3;
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   120
}
eb8ebfe5df67 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   121
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   122
static inline bool IsOilRig(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   123
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   124
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   125
	return _m[t].m5 == OILRIG_BASE;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   126
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   127
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   128
static inline bool IsDock(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   129
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   130
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   131
	return IS_INT_INSIDE(_m[t].m5, DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   132
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   133
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   134
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   135
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   136
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   137
	return _m[t].m5 == BUOY_BASE;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   138
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   139
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   140
3338
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   141
static inline bool IsHangarTile(TileIndex t)
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   142
{
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   143
	return IsTileType(t, MP_STATION) && IsHangar(t);
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   144
}
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   145
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   146
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   147
static inline Axis GetRailStationAxis(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   148
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   149
	assert(IsRailwayStation(t));
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   150
	return HASBIT(_m[t].m5, 0) ? AXIS_Y : AXIS_X;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   151
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   152
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   153
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   154
static inline Track GetRailStationTrack(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   155
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   156
	return GetRailStationAxis(t) == AXIS_X ? TRACK_X : TRACK_Y;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   157
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   158
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   159
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   160
static inline DiagDirection GetDockDirection(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   161
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   162
	assert(IsTileType(t, MP_STATION));
3370
d0c7cab7b5f4 (svn r4168) -Fix: Fixed a typo in previous commit
celestar
parents: 3369
diff changeset
   163
	assert(_m[t].m5 < DOCK_BASE_WATER_PART);
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   164
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   165
	return (DiagDirection)(_m[t].m5 - DOCK_BASE);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   166
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   167
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   168
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   169
static inline bool IsCustomStationSprite(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   170
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   171
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   172
	return HASBIT(_m[t].m3, 4);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   173
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   174
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   175
static inline void SetCustomStationSprite(TileIndex t, byte sprite)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   176
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   177
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   178
	SETBIT(_m[t].m3, 4);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   179
	_m[t].m4 = sprite;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   180
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   181
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   182
static inline uint GetCustomStationSprite(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   183
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   184
	assert(IsTileType(t, MP_STATION));
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   185
	return _m[t].m4;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   186
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   187
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   188
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   189
static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   190
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   191
	SetTileType(t, MP_STATION);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   192
	SetTileOwner(t, o);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   193
	_m[t].m2 = sid;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   194
	_m[t].m3 = 0;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   195
	_m[t].m4 = 0;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   196
	_m[t].m5 = m5;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   197
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   198
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   199
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   200
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   201
	MakeStation(t, o, sid, section + a);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   202
	SetRailType(t, rt);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   203
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   204
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   205
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, DiagDirection d)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   206
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   207
	MakeStation(t, o, sid, (rst == RS_BUS ? BUS_BASE : TRUCK_BASE) + d);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   208
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   209
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   210
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   211
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   212
	MakeStation(t, o, sid, section);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   213
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   214
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   215
static inline void MakeBuoy(TileIndex t, StationID sid)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   216
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   217
	MakeStation(t, OWNER_NONE, sid, BUOY_BASE);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   218
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   219
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   220
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   221
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   222
	MakeStation(t, o, sid, DOCK_BASE + d);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   223
	MakeStation(t + TileOffsByDir(d), o, sid, DOCK_BASE_WATER_PART + DiagDirToAxis(d));
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   224
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   225
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   226
static inline void MakeOilrig(TileIndex t, StationID sid)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   227
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   228
	MakeStation(t, OWNER_NONE, sid, OILRIG_BASE);
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   229
}
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   230
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   231
#endif