author | richk |
Tue, 17 Jun 2008 13:41:57 +0000 | |
branch | NewGRF_ports |
changeset 10995 | 311b38c7f9a7 |
parent 10724 | 68a692eacf22 |
permissions | -rw-r--r-- |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
2 |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
3 |
/** @file water_map.h Map accessors for water tiles. */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6574
diff
changeset
|
4 |
|
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
5 |
#ifndef WATER_MAP_H |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
6 |
#define WATER_MAP_H |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
7 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
8 |
enum WaterTileType { |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
9 |
WATER_TILE_CLEAR, |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
10 |
WATER_TILE_COAST, |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
11 |
WATER_TILE_LOCK, |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
12 |
WATER_TILE_DEPOT, |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
13 |
}; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
14 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
15 |
enum WaterClass { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
16 |
WATER_CLASS_SEA, |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
17 |
WATER_CLASS_CANAL, |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
18 |
WATER_CLASS_RIVER, |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
19 |
}; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
20 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
21 |
enum DepotPart { |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
22 |
DEPOT_NORTH = 0x80, |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
23 |
DEPOT_SOUTH = 0x81, |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
24 |
DEPOT_END = 0x84, |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
25 |
}; |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
26 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
27 |
enum LockPart { |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
28 |
LOCK_MIDDLE = 0x10, |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
29 |
LOCK_LOWER = 0x14, |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
30 |
LOCK_UPPER = 0x18, |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
31 |
LOCK_END = 0x1C |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
32 |
}; |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
33 |
|
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
34 |
static inline WaterTileType GetWaterTileType(TileIndex t) |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
35 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
36 |
assert(IsTileType(t, MP_WATER)); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
37 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
38 |
if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
39 |
if (_m[t].m5 == 1) return WATER_TILE_COAST; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
40 |
if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
41 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
42 |
assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
43 |
return WATER_TILE_DEPOT; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
44 |
} |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
45 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
46 |
static inline WaterClass GetWaterClass(TileIndex t) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
47 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
48 |
assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
49 |
return (WaterClass)GB(_m[t].m3, 0, 2); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
50 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
51 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
52 |
static inline void SetWaterClass(TileIndex t, WaterClass wc) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
53 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
54 |
assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
55 |
SB(_m[t].m3, 0, 2, wc); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
56 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
57 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
58 |
/** IsWater return true if any type of clear water like ocean, river, canal */ |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
59 |
static inline bool IsWater(TileIndex t) |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
60 |
{ |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
61 |
return GetWaterTileType(t) == WATER_TILE_CLEAR; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
62 |
} |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
63 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
64 |
static inline bool IsSea(TileIndex t) |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
65 |
{ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
66 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_SEA; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
67 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
68 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
69 |
static inline bool IsCanal(TileIndex t) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
70 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
71 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
72 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
73 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
74 |
static inline bool IsRiver(TileIndex t) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
75 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
76 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_RIVER; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
77 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
78 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
79 |
static inline bool IsWaterTile(TileIndex t) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
80 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
81 |
return IsTileType(t, MP_WATER) && IsWater(t); |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
82 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
83 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
84 |
static inline bool IsCoast(TileIndex t) |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
85 |
{ |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
86 |
return GetWaterTileType(t) == WATER_TILE_COAST; |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
87 |
} |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
88 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
89 |
static inline TileIndex GetOtherShipDepotTile(TileIndex t) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
90 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
91 |
return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
92 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
93 |
|
10242
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
94 |
static inline bool IsShipDepot(TileIndex t) |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
95 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
96 |
return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END); |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
97 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
98 |
|
10242
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
99 |
static inline bool IsShipDepotTile(TileIndex t) |
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
100 |
{ |
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
101 |
return IsTileType(t, MP_WATER) && IsShipDepot(t); |
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
102 |
} |
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
6878
diff
changeset
|
103 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
104 |
static inline Axis GetShipDepotAxis(TileIndex t) |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
105 |
{ |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
106 |
return (Axis)GB(_m[t].m5, 1, 1); |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
107 |
} |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
108 |
|
3953
db302c2d1a2a
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents:
3940
diff
changeset
|
109 |
static inline DiagDirection GetShipDepotDirection(TileIndex t) |
db302c2d1a2a
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents:
3940
diff
changeset
|
110 |
{ |
db302c2d1a2a
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents:
3940
diff
changeset
|
111 |
return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); |
db302c2d1a2a
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents:
3940
diff
changeset
|
112 |
} |
db302c2d1a2a
(svn r5101) Add a function to convert an axis and a flag for north/south into a DiagDirection. Use it for bridge ramps and ship depots
tron
parents:
3940
diff
changeset
|
113 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
114 |
static inline bool IsLock(TileIndex t) |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
115 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
116 |
return IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
117 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
118 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
119 |
static inline DiagDirection GetLockDirection(TileIndex t) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
120 |
{ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
121 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
122 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
123 |
|
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
124 |
static inline byte GetSection(TileIndex t) |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
125 |
{ |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5726
diff
changeset
|
126 |
assert(GetWaterTileType(t) == WATER_TILE_LOCK || GetWaterTileType(t) == WATER_TILE_DEPOT); |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
127 |
return GB(_m[t].m5, 0, 4); |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
128 |
} |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
129 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
130 |
static inline byte GetWaterTileRandomBits(TileIndex t) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
131 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
132 |
return _m[t].m4; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
133 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
134 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
135 |
|
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
136 |
static inline void MakeWater(TileIndex t) |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
137 |
{ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
138 |
SetTileType(t, MP_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
139 |
SetTileOwner(t, OWNER_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
140 |
_m[t].m2 = 0; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
141 |
_m[t].m3 = WATER_CLASS_SEA; |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
142 |
_m[t].m4 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
143 |
_m[t].m5 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
144 |
} |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
145 |
|
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
146 |
static inline void MakeShore(TileIndex t) |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
147 |
{ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
148 |
SetTileType(t, MP_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
149 |
SetTileOwner(t, OWNER_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
150 |
_m[t].m2 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
151 |
_m[t].m3 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
152 |
_m[t].m4 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
153 |
_m[t].m5 = 1; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
154 |
} |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
155 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
156 |
static inline void MakeRiver(TileIndex t, uint8 random_bits) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
157 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
158 |
SetTileType(t, MP_WATER); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
159 |
SetTileOwner(t, OWNER_WATER); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
160 |
_m[t].m2 = 0; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
161 |
_m[t].m3 = WATER_CLASS_RIVER; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
162 |
_m[t].m4 = random_bits; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
163 |
_m[t].m5 = 0; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
164 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
165 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
166 |
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits) |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
167 |
{ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6720
diff
changeset
|
168 |
assert(o != OWNER_WATER); |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
169 |
SetTileType(t, MP_WATER); |
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
170 |
SetTileOwner(t, o); |
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
171 |
_m[t].m2 = 0; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
172 |
_m[t].m3 = WATER_CLASS_CANAL; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
173 |
_m[t].m4 = random_bits; |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
174 |
_m[t].m5 = 0; |
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
175 |
} |
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
176 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
177 |
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class) |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
178 |
{ |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
179 |
SetTileType(t, MP_WATER); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
180 |
SetTileOwner(t, o); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
181 |
_m[t].m2 = 0; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
182 |
_m[t].m3 = original_water_class; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
183 |
_m[t].m4 = 0; |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
184 |
_m[t].m5 = base + a * 2; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
185 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
186 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
187 |
static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass original_water_class) |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
188 |
{ |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
189 |
SetTileType(t, MP_WATER); |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3636
diff
changeset
|
190 |
SetTileOwner(t, o); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
191 |
_m[t].m2 = 0; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
192 |
_m[t].m3 = original_water_class; |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
193 |
_m[t].m4 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
194 |
_m[t].m5 = section; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
195 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
196 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
197 |
static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper) |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
198 |
{ |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
3953
diff
changeset
|
199 |
TileIndexDiff delta = TileOffsByDiagDir(d); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
200 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
201 |
MakeLockTile(t, o, LOCK_MIDDLE + d, WATER_CLASS_CANAL); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
202 |
MakeLockTile(t - delta, o, LOCK_LOWER + d, wc_lower); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6872
diff
changeset
|
203 |
MakeLockTile(t + delta, o, LOCK_UPPER + d, wc_upper); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
204 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
205 |
|
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
|
206 |
#endif /* WATER_MAP_H */ |