src/station_map.h
author Tero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 21:51:14 +0300
changeset 11180 982e9f814f97
parent 10690 2a363031721a
permissions -rw-r--r--
scan for tarfiles in CACHE_DIR, remember what Subdirectory a tar was found in, set the GCF_FLAG on GRFs loaded from there, and hide those in the NewGRF GUI
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     1
/* $Id$ */
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 10214
diff changeset
     3
/** @file station_map.h Maps accessors for stations. */
6916
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6574
diff changeset
     4
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     5
#ifndef STATION_MAP_H
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     6
#define STATION_MAP_H
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     7
4041
caf4fcb4e05b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3900
diff changeset
     8
#include "rail_map.h"
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6916
diff changeset
     9
#include "road_map.h"
8967
0b56f973bcf0 (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents: 8918
diff changeset
    10
#include "water_map.h"
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
    11
#include "station_func.h"
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
    12
#include "station_base.h"
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8424
diff changeset
    13
#include "rail.h"
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    14
3545
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    15
typedef byte StationGfx;
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    16
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    17
static inline StationID GetStationIndex(TileIndex t)
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    18
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    19
	assert(IsTileType(t, MP_STATION));
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    20
	return (StationID)_m[t].m2;
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    21
}
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    22
7814
fe643468ad64 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents: 7768
diff changeset
    23
static inline Station *GetStationByTile(TileIndex t)
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    24
{
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    25
	return GetStation(GetStationIndex(t));
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    26
}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    27
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    28
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    29
enum {
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    30
	GFX_RADAR_LARGE_FIRST             =  31,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    31
	GFX_RADAR_LARGE_LAST              =  42,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    32
	GFX_WINDSACK_FIRST                =  50,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    33
	GFX_WINDSACK_LAST                 =  53,
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    34
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    35
	GFX_DOCK_BASE_WATER_PART          =  4,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    36
	GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET =  4,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    37
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    38
	GFX_RADAR_INTERNATIONAL_FIRST     =  66,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    39
	GFX_RADAR_INTERNATIONAL_LAST      =  77,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    40
	GFX_RADAR_METROPOLITAN_FIRST      =  78,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    41
	GFX_RADAR_METROPOLITAN_LAST       =  89,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    42
	GFX_RADAR_DISTRICTWE_FIRST        = 121,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    43
	GFX_RADAR_DISTRICTWE_LAST         = 132,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    44
	GFX_WINDSACK_INTERCON_FIRST       = 140,
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    45
	GFX_WINDSACK_INTERCON_LAST        = 143,
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    46
};
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    47
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    48
static inline StationType GetStationType(TileIndex t)
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    49
{
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    50
	return (StationType)GB(_m[t].m6, 3, 3);
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    51
}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    52
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
    53
static inline RoadStopType GetRoadStopType(TileIndex t)
3360
edef9ad64773 (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
    54
{
edef9ad64773 (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
    55
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
    56
	return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
3360
edef9ad64773 (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
    57
}
edef9ad64773 (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
    58
3545
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    59
static inline StationGfx GetStationGfx(TileIndex t)
3540
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    60
{
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    61
	assert(IsTileType(t, MP_STATION));
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    62
	return _m[t].m5;
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    63
}
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    64
3545
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    65
static inline void SetStationGfx(TileIndex t, StationGfx gfx)
3540
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    66
{
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    67
	assert(IsTileType(t, MP_STATION));
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    68
	_m[t].m5 = gfx;
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    69
}
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
    70
10214
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    71
static inline uint8 GetStationAnimationFrame(TileIndex t)
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    72
{
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    73
	assert(IsTileType(t, MP_STATION));
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    74
	return _me[t].m7;
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    75
}
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    76
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    77
static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    78
{
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    79
	assert(IsTileType(t, MP_STATION));
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    80
	_me[t].m7 = frame;
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    81
}
bac84ea64833 (svn r12746) -Codechange: Add map storage for station animation frame
peter1138
parents: 9283
diff changeset
    82
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    83
static inline bool IsRailwayStation(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    84
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    85
	return GetStationType(t) == STATION_RAIL;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    86
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    87
3442
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
    88
static inline bool IsRailwayStationTile(TileIndex t)
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
    89
{
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
    90
	return IsTileType(t, MP_STATION) && IsRailwayStation(t);
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
    91
}
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
    92
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    93
static inline bool IsAirport(TileIndex t)
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    94
{
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    95
	return GetStationType(t) == STATION_AIRPORT;
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    96
}
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
    97
7816
207d11ff7fda (svn r10681) -Codechange: do not determine whether a tile is a hangar based on the graphics index to be drawn on the given tile, but do it based on the specification of the location of hangars of the airport.
rubidium
parents: 7814
diff changeset
    98
bool IsHangar(TileIndex t);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    99
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   100
static inline bool IsTruckStop(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   101
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   102
	return GetStationType(t) == STATION_TRUCK;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   103
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   104
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   105
static inline bool IsBusStop(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   106
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   107
	return GetStationType(t) == STATION_BUS;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   108
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   109
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   110
static inline bool IsRoadStop(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   111
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   112
	assert(IsTileType(t, MP_STATION));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   113
	return IsTruckStop(t) || IsBusStop(t);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   114
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   115
3404
3ac4f7fedfb5 (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 bool IsRoadStopTile(TileIndex t)
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   117
{
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   118
	return IsTileType(t, MP_STATION) && IsRoadStop(t);
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   119
}
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   120
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   121
static inline bool IsStandardRoadStopTile(TileIndex t)
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   122
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   123
	return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   124
}
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   125
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   126
static inline bool IsDriveThroughStopTile(TileIndex t)
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   127
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   128
	return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   129
}
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   130
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   131
static inline bool GetStopBuiltOnTownRoad(TileIndex t)
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   132
{
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   133
	assert(IsDriveThroughStopTile(t));
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8235
diff changeset
   134
	return HasBit(_m[t].m6, 2);
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   135
}
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   136
10690
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   137
static inline void SetStopBuiltOnTownRoad(TileIndex t, bool on_town_road)
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   138
{
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   139
	assert(IsDriveThroughStopTile(t));
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   140
	SB(_m[t].m6, 2, 1, on_town_road);
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   141
}
2a363031721a (svn r13234) -Fix: Check/affect town rating when removing/bulldozing town-owned road under drivethrough stops.
frosch
parents: 10429
diff changeset
   142
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   143
3404
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   144
/**
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   145
 * Gets the direction the road stop entrance points towards.
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   146
 */
3540
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
   147
static inline DiagDirection GetRoadStopDir(TileIndex t)
3404
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   148
{
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   149
	StationGfx gfx = GetStationGfx(t);
3540
83bd858fe9fe (svn r4403) CodeChange : Add GetStationGfx and make use of [G|S]etStationGfx accessors. Also, use GetStationGfx instead of directly accessing the map for functions in station_map.h
belugas
parents: 3474
diff changeset
   150
	assert(IsRoadStopTile(t));
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   151
	if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   152
		return (DiagDirection)(gfx);
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   153
	} else {
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   154
		return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6204
diff changeset
   155
	}
3404
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   156
}
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   157
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   158
static inline bool IsOilRig(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   159
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   160
	return GetStationType(t) == STATION_OILRIG;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   161
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   162
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   163
static inline bool IsDock(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   164
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   165
	return GetStationType(t) == STATION_DOCK;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   166
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   167
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   168
static inline bool IsBuoy(TileIndex t)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   169
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   170
	return GetStationType(t) == STATION_BUOY;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   171
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   172
3442
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   173
static inline bool IsBuoyTile(TileIndex t)
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   174
{
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   175
	return IsTileType(t, MP_STATION) && IsBuoy(t);
3442
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   176
}
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   177
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   178
static inline bool IsHangarTile(TileIndex t)
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   179
{
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   180
	return IsTileType(t, MP_STATION) && IsHangar(t);
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   181
}
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   182
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   183
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   184
static inline Axis GetRailStationAxis(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   185
{
3541
5e680cec018c (svn r4404) Reverted part of r4403. GetRailStationAxis need assertion on IsRailwayStation. Thanks glx for spotting it
belugas
parents: 3540
diff changeset
   186
	assert(IsRailwayStation(t));
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8235
diff changeset
   187
	return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   188
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   189
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   190
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   191
static inline Track GetRailStationTrack(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   192
{
4158
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4136
diff changeset
   193
	return AxisToTrack(GetRailStationAxis(t));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   194
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   195
3444
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   196
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   197
{
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   198
	assert(IsRailwayStationTile(t2));
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   199
	return
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   200
		IsRailwayStationTile(t1) &&
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   201
		IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
3766
f0077e6b6f99 (svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
peter1138
parents: 3742
diff changeset
   202
		GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
8918
fce0efd046ff (svn r11992) -Fix (r9905): When building two rail stations close to each other (with control) so they looked like one long track trains would see them as one (spotted and fixed by eddi)
bjarni
parents: 8634
diff changeset
   203
		GetStationIndex(t1) == GetStationIndex(t2) &&
3766
f0077e6b6f99 (svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
peter1138
parents: 3742
diff changeset
   204
		!IsStationTileBlocked(t1);
3444
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   205
}
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   206
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   207
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   208
static inline DiagDirection GetDockDirection(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   209
{
3545
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
   210
	StationGfx gfx = GetStationGfx(t);
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   211
	assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   212
	return (DiagDirection)(gfx);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   213
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   214
3472
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   215
static inline TileIndexDiffC GetDockOffset(TileIndex t)
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   216
{
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   217
	static const TileIndexDiffC buoy_offset = {0, 0};
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   218
	static const TileIndexDiffC oilrig_offset = {2, 0};
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   219
	static const TileIndexDiffC dock_offset[DIAGDIR_END] = {
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   220
		{-2,  0},
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   221
		{ 0,  2},
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   222
		{ 2,  0},
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   223
		{ 0, -2},
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   224
	};
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   225
	assert(IsTileType(t, MP_STATION));
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   226
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   227
	if (IsBuoy(t)) return buoy_offset;
3472
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   228
	if (IsOilRig(t)) return oilrig_offset;
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   229
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   230
	assert(IsDock(t));
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   231
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   232
	return dock_offset[GetDockDirection(t)];
7ef2b2d6a632 (svn r4317) -Codechange: More map accessors for ship_cmd. it is now map-access free, but still requires a huge cleanup
celestar
parents: 3444
diff changeset
   233
}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   234
3568
c1abc31df35b (svn r4450) - NewStations, rename *CustomStationSprite() to *CustomStationSpecIndex() to reflect their use, and alter the test for determining if a station has customised graphics.
peter1138
parents: 3545
diff changeset
   235
static inline bool IsCustomStationSpecIndex(TileIndex t)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   236
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   237
	assert(IsTileType(t, MP_STATION));
3568
c1abc31df35b (svn r4450) - NewStations, rename *CustomStationSprite() to *CustomStationSpecIndex() to reflect their use, and alter the test for determining if a station has customised graphics.
peter1138
parents: 3545
diff changeset
   238
	return _m[t].m4 != 0;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   239
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   240
3568
c1abc31df35b (svn r4450) - NewStations, rename *CustomStationSprite() to *CustomStationSpecIndex() to reflect their use, and alter the test for determining if a station has customised graphics.
peter1138
parents: 3545
diff changeset
   241
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   242
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   243
	assert(IsTileType(t, MP_STATION));
3568
c1abc31df35b (svn r4450) - NewStations, rename *CustomStationSprite() to *CustomStationSpecIndex() to reflect their use, and alter the test for determining if a station has customised graphics.
peter1138
parents: 3545
diff changeset
   244
	_m[t].m4 = specindex;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   245
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   246
3568
c1abc31df35b (svn r4450) - NewStations, rename *CustomStationSprite() to *CustomStationSpecIndex() to reflect their use, and alter the test for determining if a station has customised graphics.
peter1138
parents: 3545
diff changeset
   247
static inline uint GetCustomStationSpecIndex(TileIndex t)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   248
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   249
	assert(IsTileType(t, MP_STATION));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   250
	return _m[t].m4;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   251
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   252
3742
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   253
static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   254
{
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   255
	assert(IsTileType(t, MP_STATION));
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   256
	SB(_m[t].m3, 4, 4, random_bits);
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   257
}
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   258
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   259
static inline byte GetStationTileRandomBits(TileIndex t)
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   260
{
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   261
	assert(IsTileType(t, MP_STATION));
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   262
	return GB(_m[t].m3, 4, 4);
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   263
}
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   264
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   265
static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   266
{
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   267
	SetTileType(t, MP_STATION);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   268
	SetTileOwner(t, o);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   269
	_m[t].m2 = sid;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   270
	_m[t].m3 = 0;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   271
	_m[t].m4 = 0;
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   272
	_m[t].m5 = section;
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   273
	SB(_m[t].m6, 3, 3, st);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   274
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   275
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   276
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   277
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   278
	MakeStation(t, o, sid, STATION_RAIL, section + a);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   279
	SetRailType(t, rt);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   280
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   281
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
   282
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   283
{
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
   284
	MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6916
diff changeset
   285
	SetRoadTypes(t, rt);
6424
65bf2bbe789d (svn r8833) -Fix
tron
parents: 6338
diff changeset
   286
}
65bf2bbe789d (svn r8833) -Fix
tron
parents: 6338
diff changeset
   287
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
   288
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, Axis a, bool on_town_road)
6424
65bf2bbe789d (svn r8833) -Fix
tron
parents: 6338
diff changeset
   289
{
9281
d8cd9ac52a68 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents: 8967
diff changeset
   290
	MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   291
	SB(_m[t].m6, 2, 1, on_town_road);
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6916
diff changeset
   292
	SetRoadTypes(t, rt);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   293
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   294
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   295
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   296
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   297
	MakeStation(t, o, sid, STATION_AIRPORT, section);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   298
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   299
8967
0b56f973bcf0 (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents: 8918
diff changeset
   300
static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   301
{
6204
c237d8081b58 (svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium
parents: 6156
diff changeset
   302
	/* Make the owner of the buoy tile the same as the current owner of the
c237d8081b58 (svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium
parents: 6156
diff changeset
   303
	 * water tile. In this way, we can reset the owner of the water to its
c237d8081b58 (svn r8619) -Fix: store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. This solves the issue of removing ownership from canal tiles thus making is possible for other players to remove the canal tile.
rubidium
parents: 6156
diff changeset
   304
	 * original state when the buoy gets removed. */
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   305
	MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0);
8967
0b56f973bcf0 (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents: 8918
diff changeset
   306
	SetWaterClass(t, wc);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   307
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   308
8967
0b56f973bcf0 (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents: 8918
diff changeset
   309
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   310
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   311
	MakeStation(t, o, sid, STATION_DOCK, d);
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   312
	MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
8967
0b56f973bcf0 (svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents: 8918
diff changeset
   313
	SetWaterClass(t + TileOffsByDiagDir(d), wc);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   314
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   315
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   316
static inline void MakeOilrig(TileIndex t, StationID sid)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   317
{
7768
2060e8d65a72 (svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium
parents: 7157
diff changeset
   318
	MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   319
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   320
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4559
diff changeset
   321
#endif /* STATION_MAP_H */