author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9718 | 4b7468076d31 |
permissions | -rw-r--r-- |
3111
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8966
diff
changeset
|
3 |
/** @file water_map.h Map accessors for water tiles. */ |
6432
226650eb2ef3
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6248
diff
changeset
|
4 |
|
3111
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
5 |
#ifndef WATER_MAP_H |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
6 |
#define WATER_MAP_H |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
7 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
8 |
enum WaterTileType { |
6181
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
9 |
WATER_TILE_CLEAR, |
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
10 |
WATER_TILE_COAST, |
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
11 |
WATER_TILE_LOCK, |
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
12 |
WATER_TILE_DEPOT, |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
13 |
}; |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
14 |
|
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
15 |
enum WaterClass { |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
16 |
WATER_CLASS_SEA, |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
17 |
WATER_CLASS_CANAL, |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
18 |
WATER_CLASS_RIVER, |
9718
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
19 |
WATER_CLASS_INVALID, ///< Used for industry tiles on land (also for oilrig if newgrf says so) |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
20 |
}; |
3402
812f9dc4baff
(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
|
21 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
22 |
enum DepotPart { |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
23 |
DEPOT_NORTH = 0x80, |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
24 |
DEPOT_SOUTH = 0x81, |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
25 |
DEPOT_END = 0x84, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
26 |
}; |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
27 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
28 |
enum LockPart { |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
29 |
LOCK_MIDDLE = 0x10, |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
30 |
LOCK_LOWER = 0x14, |
3402
812f9dc4baff
(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_UPPER = 0x18, |
812f9dc4baff
(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
|
32 |
LOCK_END = 0x1C |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6181
diff
changeset
|
33 |
}; |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
34 |
|
3402
812f9dc4baff
(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
|
35 |
static inline WaterTileType GetWaterTileType(TileIndex t) |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
36 |
{ |
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
37 |
assert(IsTileType(t, MP_WATER)); |
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
38 |
|
6181
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
39 |
if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
40 |
if (_m[t].m5 == 1) return WATER_TILE_COAST; |
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7928
diff
changeset
|
41 |
if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
3402
812f9dc4baff
(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
|
42 |
|
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7928
diff
changeset
|
43 |
assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
6181
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
44 |
return WATER_TILE_DEPOT; |
3402
812f9dc4baff
(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 |
} |
812f9dc4baff
(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
|
46 |
|
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
47 |
static inline WaterClass GetWaterClass(TileIndex t) |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
48 |
{ |
9718
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
49 |
assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY)); |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
50 |
return (WaterClass)(IsTileType(t, MP_INDUSTRY) ? GB(_m[t].m1, 5, 2) : GB(_m[t].m3, 0, 2)); |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
51 |
} |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
52 |
|
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
53 |
static inline void SetWaterClass(TileIndex t, WaterClass wc) |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
54 |
{ |
9718
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
55 |
assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY)); |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
56 |
if (IsTileType(t, MP_INDUSTRY)) { |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
57 |
SB(_m[t].m1, 5, 2, wc); |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
58 |
} else { |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
59 |
SB(_m[t].m3, 0, 2, wc); |
4b7468076d31
(svn r13838) -Codechange: Make industry tiles aware of WaterClasses.
frosch
parents:
9111
diff
changeset
|
60 |
} |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
61 |
} |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
62 |
|
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
63 |
/** IsWater return true if any type of clear water like ocean, river, canal */ |
3402
812f9dc4baff
(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
|
64 |
static inline bool IsWater(TileIndex t) |
812f9dc4baff
(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
|
65 |
{ |
6181
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
66 |
return GetWaterTileType(t) == WATER_TILE_CLEAR; |
3402
812f9dc4baff
(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
|
67 |
} |
812f9dc4baff
(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
|
68 |
|
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
69 |
static inline bool IsSea(TileIndex t) |
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
70 |
{ |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
71 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_SEA; |
3423
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
72 |
} |
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
73 |
|
6974
952d742f6dee
(svn r10230) -Fix [FS#594]: terraforming wipes out canals. Now you always have to remove the canal before terraforming, instead of "just" removing the canal.
rubidium
parents:
6432
diff
changeset
|
74 |
static inline bool IsCanal(TileIndex t) |
952d742f6dee
(svn r10230) -Fix [FS#594]: terraforming wipes out canals. Now you always have to remove the canal before terraforming, instead of "just" removing the canal.
rubidium
parents:
6432
diff
changeset
|
75 |
{ |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
76 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL; |
6974
952d742f6dee
(svn r10230) -Fix [FS#594]: terraforming wipes out canals. Now you always have to remove the canal before terraforming, instead of "just" removing the canal.
rubidium
parents:
6432
diff
changeset
|
77 |
} |
952d742f6dee
(svn r10230) -Fix [FS#594]: terraforming wipes out canals. Now you always have to remove the canal before terraforming, instead of "just" removing the canal.
rubidium
parents:
6432
diff
changeset
|
78 |
|
8360
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
79 |
static inline bool IsRiver(TileIndex t) |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
80 |
{ |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
81 |
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_RIVER; |
8360
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
82 |
} |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
83 |
|
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
84 |
static inline bool IsWaterTile(TileIndex t) |
3402
812f9dc4baff
(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
|
85 |
{ |
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
86 |
return IsTileType(t, MP_WATER) && IsWater(t); |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
87 |
} |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
88 |
|
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
89 |
static inline bool IsCoast(TileIndex t) |
8383
dec97c6d7e37
(svn r11952) -Fix (r11926): Prevent industries from being built on rivers, unless they require water.
peter1138
parents:
8368
diff
changeset
|
90 |
{ |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
91 |
return GetWaterTileType(t) == WATER_TILE_COAST; |
8383
dec97c6d7e37
(svn r11952) -Fix (r11926): Prevent industries from being built on rivers, unless they require water.
peter1138
parents:
8368
diff
changeset
|
92 |
} |
dec97c6d7e37
(svn r11952) -Fix (r11926): Prevent industries from being built on rivers, unless they require water.
peter1138
parents:
8368
diff
changeset
|
93 |
|
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
94 |
static inline TileIndex GetOtherShipDepotTile(TileIndex t) |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
95 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7739
diff
changeset
|
96 |
return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
97 |
} |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
98 |
|
8966
511e7f1bc564
(svn r12758) -Fix(r4712, r12745): Use a bool when it's about boolean evaluation. a TileIndex is hardly a bool, of course of course. Thanks for good old MSVC warnings.
belugas
parents:
8954
diff
changeset
|
99 |
static inline bool IsShipDepot(TileIndex t) |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
100 |
{ |
7954
57b51c69c072
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
7928
diff
changeset
|
101 |
return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END); |
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
102 |
} |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
103 |
|
8966
511e7f1bc564
(svn r12758) -Fix(r4712, r12745): Use a bool when it's about boolean evaluation. a TileIndex is hardly a bool, of course of course. Thanks for good old MSVC warnings.
belugas
parents:
8954
diff
changeset
|
104 |
static inline bool IsShipDepotTile(TileIndex t) |
8954
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8495
diff
changeset
|
105 |
{ |
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8495
diff
changeset
|
106 |
return IsTileType(t, MP_WATER) && IsShipDepot(t); |
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8495
diff
changeset
|
107 |
} |
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8495
diff
changeset
|
108 |
|
3423
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
109 |
static inline Axis GetShipDepotAxis(TileIndex t) |
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
110 |
{ |
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
111 |
return (Axis)GB(_m[t].m5, 1, 1); |
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
112 |
} |
dab85d82708b
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3402
diff
changeset
|
113 |
|
3953
e64bbd8598e2
(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
|
114 |
static inline DiagDirection GetShipDepotDirection(TileIndex t) |
e64bbd8598e2
(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
|
115 |
{ |
e64bbd8598e2
(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
|
116 |
return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); |
e64bbd8598e2
(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
|
117 |
} |
e64bbd8598e2
(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
|
118 |
|
8495
35c77bdca32a
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8471
diff
changeset
|
119 |
static inline bool IsLock(TileIndex t) |
8029
6cc607fe1d3d
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
7954
diff
changeset
|
120 |
{ |
8495
35c77bdca32a
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8471
diff
changeset
|
121 |
return IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END); |
8029
6cc607fe1d3d
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
7954
diff
changeset
|
122 |
} |
6cc607fe1d3d
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
7954
diff
changeset
|
123 |
|
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
124 |
static inline DiagDirection GetLockDirection(TileIndex t) |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
125 |
{ |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
126 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
127 |
} |
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
128 |
|
3425
5411e9c8b6c8
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
129 |
static inline byte GetSection(TileIndex t) |
5411e9c8b6c8
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
130 |
{ |
6181
2d0ac0598453
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
5475
diff
changeset
|
131 |
assert(GetWaterTileType(t) == WATER_TILE_LOCK || GetWaterTileType(t) == WATER_TILE_DEPOT); |
3425
5411e9c8b6c8
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
132 |
return GB(_m[t].m5, 0, 4); |
5411e9c8b6c8
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
133 |
} |
5411e9c8b6c8
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3424
diff
changeset
|
134 |
|
8368
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
135 |
static inline byte GetWaterTileRandomBits(TileIndex t) |
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
136 |
{ |
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
137 |
return _m[t].m4; |
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
138 |
} |
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
139 |
|
3373
2838aadd3a28
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
140 |
|
3111
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
141 |
static inline void MakeWater(TileIndex t) |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
142 |
{ |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
143 |
SetTileType(t, MP_WATER); |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
144 |
SetTileOwner(t, OWNER_WATER); |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
145 |
_m[t].m2 = 0; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
146 |
_m[t].m3 = WATER_CLASS_SEA; |
3111
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
147 |
_m[t].m4 = 0; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
148 |
_m[t].m5 = 0; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
149 |
} |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
150 |
|
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
151 |
static inline void MakeShore(TileIndex t) |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
152 |
{ |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
153 |
SetTileType(t, MP_WATER); |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
154 |
SetTileOwner(t, OWNER_WATER); |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
155 |
_m[t].m2 = 0; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
156 |
_m[t].m3 = 0; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
157 |
_m[t].m4 = 0; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
158 |
_m[t].m5 = 1; |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
159 |
} |
750f37699a13
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
160 |
|
8368
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
161 |
static inline void MakeRiver(TileIndex t, uint8 random_bits) |
8360
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
162 |
{ |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
163 |
SetTileType(t, MP_WATER); |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
164 |
SetTileOwner(t, OWNER_WATER); |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
165 |
_m[t].m2 = 0; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
166 |
_m[t].m3 = WATER_CLASS_RIVER; |
8368
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
167 |
_m[t].m4 = random_bits; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
168 |
_m[t].m5 = 0; |
8360
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
169 |
} |
3021c928de6c
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8029
diff
changeset
|
170 |
|
8368
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
171 |
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits) |
3940
8965b9bfaabc
(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
|
172 |
{ |
7739
0b6f3da5c083
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
6974
diff
changeset
|
173 |
assert(o != OWNER_WATER); |
3940
8965b9bfaabc
(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 |
SetTileType(t, MP_WATER); |
8965b9bfaabc
(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 |
SetTileOwner(t, o); |
8965b9bfaabc
(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 |
_m[t].m2 = 0; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
177 |
_m[t].m3 = WATER_CLASS_CANAL; |
8368
dcee6c9440b5
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8360
diff
changeset
|
178 |
_m[t].m4 = random_bits; |
3940
8965b9bfaabc
(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
|
179 |
_m[t].m5 = 0; |
8965b9bfaabc
(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
|
180 |
} |
8965b9bfaabc
(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
|
181 |
|
8495
35c77bdca32a
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8471
diff
changeset
|
182 |
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class) |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
183 |
{ |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
184 |
SetTileType(t, MP_WATER); |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
185 |
SetTileOwner(t, o); |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
186 |
_m[t].m2 = 0; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
187 |
_m[t].m3 = original_water_class; |
8495
35c77bdca32a
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8471
diff
changeset
|
188 |
_m[t].m4 = 0; |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
189 |
_m[t].m5 = base + a * 2; |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
190 |
} |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
191 |
|
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
192 |
static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass original_water_class) |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
193 |
{ |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
194 |
SetTileType(t, MP_WATER); |
3940
8965b9bfaabc
(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
|
195 |
SetTileOwner(t, o); |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
196 |
_m[t].m2 = 0; |
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
197 |
_m[t].m3 = original_water_class; |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
198 |
_m[t].m4 = 0; |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
199 |
_m[t].m5 = section; |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
200 |
} |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
201 |
|
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
202 |
static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper) |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
203 |
{ |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
3953
diff
changeset
|
204 |
TileIndexDiff delta = TileOffsByDiagDir(d); |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
205 |
|
8471
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
206 |
MakeLockTile(t, o, LOCK_MIDDLE + d, WATER_CLASS_CANAL); |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
207 |
MakeLockTile(t - delta, o, LOCK_LOWER + d, wc_lower); |
ba4c15fe147b
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8383
diff
changeset
|
208 |
MakeLockTile(t + delta, o, LOCK_UPPER + d, wc_upper); |
3372
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
209 |
} |
f6afa98d5219
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
210 |
|
4666
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4559
diff
changeset
|
211 |
#endif /* WATER_MAP_H */ |