src/station_map.h
author KUDr
Sun, 18 Feb 2007 14:17:28 +0000
branchcpp_gui
changeset 6258 a2f86b8fd99b
parent 6254 abc6ad7c035c
child 6268 4b5241e5dd10
permissions -rw-r--r--
(svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
-Window related AllocateXxx() functions turned into Window methods
-current Widget renamed to OldWidget
-Widget base class added (still not used)
-CompositeWidget added (also not used)
-Widget rectangle/point handling moved to new file: misc/rect.hpp
-18 new .cpp files added in new dir for several widget types (most of them not used yet)
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
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     3
#ifndef STATION_MAP_H
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     4
#define STATION_MAP_H
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
     5
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
     6
#include "rail_map.h"
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     7
#include "station.h"
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
     8
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
     9
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
    10
3315
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    11
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
    12
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
    13
	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
    14
	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
    15
}
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    16
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 Station* GetStationByTile(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
{
1f65f8260092 (svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
diff changeset
    19
	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
    20
}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    21
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    22
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    23
enum {
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
    24
	GFX_RAILWAY_BASE              =   0,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    25
	GFX_AIRPORT_BASE              =   8,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    26
	GFX_RADAR_LARGE_FIRST         =  39,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    27
	GFX_RADAR_LARGE_LAST          =  50,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    28
	GFX_WINDSACK_FIRST            =  58,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    29
	GFX_WINDSACK_LAST             =  61,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    30
	GFX_TRUCK_BASE                =  67,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    31
	GFX_BUS_BASE                  =  71,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    32
	GFX_OILRIG_BASE               =  75,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    33
	GFX_DOCK_BASE                 =  76,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    34
	GFX_DOCK_BASE_WATER_PART      =  80,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    35
	GFX_BUOY_BASE                 =  82,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    36
	GFX_AIRPORT_BASE_EXTENDED     =  83,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    37
	GFX_RADAR_INTERNATIONAL_FIRST =  90,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    38
	GFX_RADAR_INTERNATIONAL_LAST  = 101,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    39
	GFX_RADAR_METROPOLITAN_FIRST  = 102,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    40
	GFX_RADAR_METROPOLITAN_LAST   = 113,
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    41
	GFX_RADAR_DISTRICTWE_FIRST    = 145,
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    42
	GFX_RADAR_DISTRICTWE_LAST     = 156,
4066
108eb446f1ae (svn r5362) - Fix: Updated sprites in New Airports to be allow cleaner replacement by newgrf graphics. All tiles now use SPR_AIRPORT_APRON as the tarmac. Created two new sprites in airports.grf for half-grass half-tarmac tiles on Intercontinental airport.
richk
parents: 4059
diff changeset
    43
	GFX_WINDSACK_INTERCON_FIRST   = 164,
108eb446f1ae (svn r5362) - Fix: Updated sprites in New Airports to be allow cleaner replacement by newgrf graphics. All tiles now use SPR_AIRPORT_APRON as the tarmac. Created two new sprites in airports.grf for half-grass half-tarmac tiles on Intercontinental airport.
richk
parents: 4059
diff changeset
    44
	GFX_WINDSACK_INTERCON_LAST    = 167,
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    45
	GFX_TRUCK_BASE_EXT            = 168,
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    46
	GFX_BUS_BASE_EXT              = 170,
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    47
	GFX_BASE_END                  = 172
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    48
};
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    49
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    50
enum {
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
    51
	RAILWAY_SIZE = GFX_AIRPORT_BASE - GFX_RAILWAY_BASE,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    52
	AIRPORT_SIZE = GFX_TRUCK_BASE - GFX_AIRPORT_BASE,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    53
	TRUCK_SIZE = GFX_BUS_BASE - GFX_TRUCK_BASE,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    54
	BUS_SIZE = GFX_OILRIG_BASE - GFX_BUS_BASE,
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
    55
	DOCK_SIZE_TOTAL = GFX_BUOY_BASE - GFX_DOCK_BASE,
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    56
	AIRPORT_SIZE_EXTENDED = GFX_TRUCK_BASE_EXT - GFX_AIRPORT_BASE_EXTENDED,
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    57
	TRUCK_SIZE_EXT = GFX_BUS_BASE_EXT - GFX_TRUCK_BASE_EXT,
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
    58
	BUS_SIZE_EXT = GFX_BASE_END - GFX_BUS_BASE_EXT,
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    59
};
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    60
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    61
typedef enum HangarTiles {
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    62
	HANGAR_TILE_0 = 32,
3337
07e476ea35b5 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
    63
	HANGAR_TILE_1 = 65,
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    64
	HANGAR_TILE_2 = 86,
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    65
	HANGAR_TILE_3 = 129, // added for west facing hangar
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    66
	HANGAR_TILE_4 = 130, // added for north facing hangar
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
    67
	HANGAR_TILE_5 = 131 // added for east facing hangar
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    68
} HangarTiles;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    69
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    70
typedef enum StationType {
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    71
	STATION_RAIL,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    72
	STATION_AIRPORT,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    73
	STATION_TRUCK,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    74
	STATION_BUS,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    75
	STATION_OILRIG,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    76
	STATION_DOCK,
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    77
	STATION_BUOY
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    78
} StationType;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    79
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    80
StationType GetStationType(TileIndex);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
    81
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 5726
diff changeset
    82
static inline RoadStop::Type 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
    83
{
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
    84
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 5726
diff changeset
    85
	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
    86
}
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
    87
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
    88
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
    89
{
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
    90
	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
    91
	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
    92
}
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
    93
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
    94
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
    95
{
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
    96
	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
    97
	_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
    98
}
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
    99
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   100
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
   101
{
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
   102
	return GetStationGfx(t) < GFX_RAILWAY_BASE + RAILWAY_SIZE;
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
3442
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   105
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
   106
{
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   107
	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
   108
}
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   109
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   110
static inline bool IsHangar(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   111
{
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
   112
	StationGfx gfx = GetStationGfx(t);
3337
07e476ea35b5 (svn r4119) There's one more possible hangar tile. Check for this in IsHangar(), too
tron
parents: 3334
diff changeset
   113
	return
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
   114
		gfx == HANGAR_TILE_0 ||
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
   115
		gfx == HANGAR_TILE_1 ||
4059
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
   116
		gfx == HANGAR_TILE_2 ||
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
   117
		gfx == HANGAR_TILE_3 ||
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
   118
		gfx == HANGAR_TILE_4 ||
f1442dfe1c8a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 4041
diff changeset
   119
		gfx == HANGAR_TILE_5;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   120
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   121
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   122
static inline bool IsAirport(TileIndex t)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   123
{
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
   124
	StationGfx gfx = GetStationGfx(t);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   125
	return
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
   126
		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE, GFX_AIRPORT_BASE + AIRPORT_SIZE)) ||
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
   127
		(IS_BYTE_INSIDE(gfx, GFX_AIRPORT_BASE_EXTENDED, GFX_AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   128
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   129
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   130
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
   131
{
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   132
	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE)) ||
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   133
		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   134
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   135
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   136
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
   137
{
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   138
	return (IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE)) ||
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   139
		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   140
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   141
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   142
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
   143
{
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   144
	return IsTruckStop(t) || IsBusStop(t);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   145
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   146
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
   147
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
   148
{
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   149
	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
   150
}
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   151
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   152
static inline bool IsStandardRoadStopTile(TileIndex t)
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   153
{
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   154
	return IsTileType(t, MP_STATION) &&
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   155
		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE, GFX_TRUCK_BASE + TRUCK_SIZE) ||
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   156
		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE, GFX_BUS_BASE + BUS_SIZE));
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   157
}
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   158
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   159
static inline bool IsDriveThroughStopTile(TileIndex t)
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   160
{
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   161
	return IsTileType(t, MP_STATION) &&
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   162
		(IS_BYTE_INSIDE(GetStationGfx(t), GFX_TRUCK_BASE_EXT, GFX_TRUCK_BASE_EXT + TRUCK_SIZE_EXT) ||
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   163
		IS_BYTE_INSIDE(GetStationGfx(t), GFX_BUS_BASE_EXT, GFX_BUS_BASE_EXT + BUS_SIZE_EXT));
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   164
}
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   165
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   166
static inline bool GetStopBuiltOnTownRoad(TileIndex t)
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   167
{
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   168
	assert(IsDriveThroughStopTile(t));
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   169
	return HASBIT(_m[t].m6, 3);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   170
}
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   171
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   172
static inline void SetStopBuiltOnTownRoad(TileIndex t)
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   173
{
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   174
	assert(IsDriveThroughStopTile(t));
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   175
	SETBIT(_m[t].m6, 3);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   176
}
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   177
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
   178
/**
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   179
 * 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
   180
 */
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
   181
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
   182
{
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   183
	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
   184
	assert(IsRoadStopTile(t));
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   185
	if (gfx < GFX_TRUCK_BASE_EXT) {
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   186
		return (DiagDirection)((gfx - GFX_TRUCK_BASE) & 3);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   187
	} else {
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   188
		return (DiagDirection)((gfx - GFX_TRUCK_BASE_EXT) & 1);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   189
	}
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
   190
}
3ac4f7fedfb5 (svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents: 3371
diff changeset
   191
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   192
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
   193
{
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
   194
	return GetStationGfx(t) == GFX_OILRIG_BASE;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   195
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   196
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   197
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
   198
{
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
   199
	return IS_BYTE_INSIDE(GetStationGfx(t), GFX_DOCK_BASE, GFX_DOCK_BASE + DOCK_SIZE_TOTAL);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   200
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   201
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   202
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
   203
{
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
   204
	return GetStationGfx(t) == GFX_BUOY_BASE;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   205
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   206
3442
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   207
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
   208
{
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   209
	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
   210
}
c494e7246d7b (svn r4272) -Codechange: Moved the map-accessing stuff from station.h into station_map.h
celestar
parents: 3404
diff changeset
   211
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   212
3338
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   213
static inline bool IsHangarTile(TileIndex t)
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   214
{
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   215
	return IsTileType(t, MP_STATION) && IsHangar(t);
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   216
}
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   217
2c60ed0dcce3 (svn r4120) Use the new station functions where appropriate
tron
parents: 3337
diff changeset
   218
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   219
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
   220
{
3541
5e680cec018c (svn r4404) Reverted part of r4403. GetRailStationAxis need assertion on IsRailwayStation. Thanks glx for spotting it
belugas
parents: 3540
diff changeset
   221
	assert(IsRailwayStation(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
   222
	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
   223
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   224
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   225
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   226
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
   227
{
4158
a8f7265a6fd0 (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4136
diff changeset
   228
	return AxisToTrack(GetRailStationAxis(t));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   229
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   230
3444
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   231
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
   232
{
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   233
	assert(IsRailwayStationTile(t2));
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   234
	return
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   235
		IsRailwayStationTile(t1) &&
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   236
		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
   237
		GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
f0077e6b6f99 (svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
peter1138
parents: 3742
diff changeset
   238
		!IsStationTileBlocked(t1);
3444
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   239
}
d7f55b5e44b9 (svn r4275) -Codechange: Use of map accessor functions inside station_map.h when possible
celestar
parents: 3443
diff changeset
   240
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   241
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   242
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
   243
{
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
   244
	StationGfx gfx = GetStationGfx(t);
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
   245
	assert(gfx < GFX_DOCK_BASE_WATER_PART);
3e66bf329257 (svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents: 3541
diff changeset
   246
	return (DiagDirection)(gfx - GFX_DOCK_BASE);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   247
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   248
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
   249
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
   250
{
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
   251
	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
   252
	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
   253
	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
   254
		{-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
   255
		{ 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
   256
		{ 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
   257
		{ 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
   258
	};
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
   259
	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
   260
6156
5adeec1679a4 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 6087
diff changeset
   261
	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
   262
	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
   263
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
   264
	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
   265
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
   266
	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
   267
}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   268
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
   269
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
   270
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   271
	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
   272
	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
   273
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   274
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
   275
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
   276
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   277
	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
   278
	_m[t].m4 = specindex;
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   279
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   280
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
   281
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
   282
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3360
diff changeset
   283
	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
   284
	return _m[t].m4;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   285
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   286
3742
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   287
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
   288
{
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   289
	assert(IsTileType(t, MP_STATION));
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   290
	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
   291
}
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   292
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   293
static inline byte GetStationTileRandomBits(TileIndex t)
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   294
{
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   295
	assert(IsTileType(t, MP_STATION));
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   296
	return GB(_m[t].m3, 4, 4);
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   297
}
8528d7737361 (svn r4724) - Newstations: Add per-tile random data for station tiles.
peter1138
parents: 3568
diff changeset
   298
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   299
static inline void MakeStation(TileIndex t, Owner o, StationID sid, byte m5)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   300
{
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   301
	SetTileType(t, MP_STATION);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   302
	SetTileOwner(t, o);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   303
	_m[t].m2 = sid;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   304
	_m[t].m3 = 0;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   305
	_m[t].m4 = 0;
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   306
	_m[t].m5 = m5;
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
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   309
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
   310
{
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   311
	MakeStation(t, o, sid, section + a);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   312
	SetRailType(t, rt);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   313
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   314
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   315
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, bool is_drive_through, DiagDirection d)
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   316
{
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   317
	if (is_drive_through) {
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   318
		MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + d);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   319
	} else {
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   320
		MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6204
diff changeset
   321
	}
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   322
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   323
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   324
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
   325
{
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   326
	MakeStation(t, o, sid, section);
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   327
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   328
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   329
static inline void MakeBuoy(TileIndex t, StationID sid)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   330
{
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
   331
	/* 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
   332
	 * 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
   333
	 * original state when the buoy gets removed. */
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
   334
	MakeStation(t, GetTileOwner(t), sid, GFX_BUOY_BASE);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   335
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   336
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   337
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d)
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   338
{
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
   339
	MakeStation(t, o, sid, GFX_DOCK_BASE + d);
4559
c853d2440065 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4158
diff changeset
   340
	MakeStation(t + TileOffsByDiagDir(d), o, sid, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d));
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   341
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   342
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   343
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
   344
{
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
   345
	MakeStation(t, OWNER_NONE, sid, GFX_OILRIG_BASE);
3334
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   346
}
b72ac8637a30 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents: 3315
diff changeset
   347
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
   348
#endif /* STATION_MAP_H */