author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5475 | 2e6990a8c7c4 |
child 6172 | e6d7a5b3d63f |
permissions | -rw-r--r-- |
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
2 |
|
3145
e833d7a78887
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
3 |
#ifndef ROAD_MAP_H |
e833d7a78887
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
4 |
#define ROAD_MAP_H |
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
5 |
|
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
6 |
#include "macros.h" |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
7 |
#include "rail.h" |
3518
c1e19f08fc25
(svn r4374) Never directly commit something you prepared the evening before, mysteriously it will break in the morning, fix r4373
tron
parents:
3497
diff
changeset
|
8 |
#include "road.h" |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
9 |
#include "tile.h" |
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
10 |
|
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
11 |
|
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
12 |
typedef enum RoadTileType { |
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
13 |
ROAD_TILE_NORMAL, |
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
14 |
ROAD_TILE_CROSSING, |
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
15 |
ROAD_TILE_DEPOT |
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
16 |
} RoadTileType; |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
17 |
|
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
18 |
static inline RoadTileType GetRoadTileType(TileIndex t) |
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
19 |
{ |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
20 |
assert(IsTileType(t, MP_STREET)); |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3900
diff
changeset
|
21 |
return (RoadTileType)GB(_m[t].m5, 4, 4); |
3150
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
22 |
} |
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
23 |
|
3497
154080838ed1
(svn r4348) Move IsLevelCrossing() from rail.h to road_map.h
tron
parents:
3430
diff
changeset
|
24 |
static inline bool IsLevelCrossing(TileIndex t) |
154080838ed1
(svn r4348) Move IsLevelCrossing() from rail.h to road_map.h
tron
parents:
3430
diff
changeset
|
25 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
26 |
return GetRoadTileType(t) == ROAD_TILE_CROSSING; |
3497
154080838ed1
(svn r4348) Move IsLevelCrossing() from rail.h to road_map.h
tron
parents:
3430
diff
changeset
|
27 |
} |
154080838ed1
(svn r4348) Move IsLevelCrossing() from rail.h to road_map.h
tron
parents:
3430
diff
changeset
|
28 |
|
3560
b2fcf1898eec
(svn r4435) - Fix: an assertion triggered when trying to remove a bridge with the remove-tool (r4348 surfaced this). In CmdRemoveRoad tiletype was not checked for ownership. Intorudce IsLevelCrossingTile() which checks if a tile is a crossing without knowing the type. Suggested by peter1138 and Tron.
Darkvater
parents:
3518
diff
changeset
|
29 |
static inline bool IsLevelCrossingTile(TileIndex t) |
b2fcf1898eec
(svn r4435) - Fix: an assertion triggered when trying to remove a bridge with the remove-tool (r4348 surfaced this). In CmdRemoveRoad tiletype was not checked for ownership. Intorudce IsLevelCrossingTile() which checks if a tile is a crossing without knowing the type. Suggested by peter1138 and Tron.
Darkvater
parents:
3518
diff
changeset
|
30 |
{ |
b2fcf1898eec
(svn r4435) - Fix: an assertion triggered when trying to remove a bridge with the remove-tool (r4348 surfaced this). In CmdRemoveRoad tiletype was not checked for ownership. Intorudce IsLevelCrossingTile() which checks if a tile is a crossing without knowing the type. Suggested by peter1138 and Tron.
Darkvater
parents:
3518
diff
changeset
|
31 |
return IsTileType(t, MP_STREET) && IsLevelCrossing(t); |
b2fcf1898eec
(svn r4435) - Fix: an assertion triggered when trying to remove a bridge with the remove-tool (r4348 surfaced this). In CmdRemoveRoad tiletype was not checked for ownership. Intorudce IsLevelCrossingTile() which checks if a tile is a crossing without knowing the type. Suggested by peter1138 and Tron.
Darkvater
parents:
3518
diff
changeset
|
32 |
} |
3150
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
33 |
|
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
34 |
static inline RoadBits GetRoadBits(TileIndex t) |
3272
b3e2d8e19937
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3196
diff
changeset
|
35 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
36 |
assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3900
diff
changeset
|
37 |
return (RoadBits)GB(_m[t].m5, 0, 4); |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
38 |
} |
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
39 |
|
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
40 |
static inline void SetRoadBits(TileIndex t, RoadBits r) |
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
41 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
42 |
assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); // XXX incomplete |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
43 |
SB(_m[t].m5, 0, 4, r); |
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
44 |
} |
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
45 |
|
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
46 |
|
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
47 |
static inline Axis GetCrossingRoadAxis(TileIndex t) |
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
48 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
49 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
50 |
return (Axis)GB(_m[t].m5, 3, 1); |
3272
b3e2d8e19937
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3196
diff
changeset
|
51 |
} |
b3e2d8e19937
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3196
diff
changeset
|
52 |
|
3070
980529af506f
(svn r3659) Add function to get the road bits of a level crossing
tron
parents:
3069
diff
changeset
|
53 |
static inline RoadBits GetCrossingRoadBits(TileIndex tile) |
980529af506f
(svn r3659) Add function to get the road bits of a level crossing
tron
parents:
3069
diff
changeset
|
54 |
{ |
3272
b3e2d8e19937
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3196
diff
changeset
|
55 |
return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y; |
3070
980529af506f
(svn r3659) Add function to get the road bits of a level crossing
tron
parents:
3069
diff
changeset
|
56 |
} |
980529af506f
(svn r3659) Add function to get the road bits of a level crossing
tron
parents:
3069
diff
changeset
|
57 |
|
3103
c0681c720481
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
58 |
static inline TrackBits GetCrossingRailBits(TileIndex tile) |
c0681c720481
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
59 |
{ |
4158 | 60 |
return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile))); |
3103
c0681c720481
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
61 |
} |
c0681c720481
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
62 |
|
c0681c720481
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
63 |
|
3274 | 64 |
// TODO swap owner of road and rail |
65 |
static inline Owner GetCrossingRoadOwner(TileIndex t) |
|
66 |
{ |
|
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
67 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3274 | 68 |
return (Owner)_m[t].m3; |
69 |
} |
|
70 |
||
71 |
static inline void SetCrossingRoadOwner(TileIndex t, Owner o) |
|
72 |
{ |
|
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
73 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3274 | 74 |
_m[t].m3 = o; |
75 |
} |
|
76 |
||
3322
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
77 |
static inline void UnbarCrossing(TileIndex t) |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
78 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
79 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3322
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
80 |
CLRBIT(_m[t].m5, 2); |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
81 |
} |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
82 |
|
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
83 |
static inline void BarCrossing(TileIndex t) |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
84 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
85 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3322
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
86 |
SETBIT(_m[t].m5, 2); |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
87 |
} |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
88 |
|
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
89 |
static inline bool IsCrossingBarred(TileIndex t) |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
90 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
91 |
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); |
3322
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
92 |
return HASBIT(_m[t].m5, 2); |
41b4d25b126d
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3274
diff
changeset
|
93 |
} |
3274 | 94 |
|
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
95 |
#define IsOnDesert IsOnSnow |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
96 |
static inline bool IsOnSnow(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
97 |
{ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
98 |
return HASBIT(_m[t].m4, 7); |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
99 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
100 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
101 |
#define ToggleDesert ToggleSnow |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
102 |
static inline void ToggleSnow(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
103 |
{ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
104 |
TOGGLEBIT(_m[t].m4, 7); |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
105 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
106 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
107 |
|
4048 | 108 |
typedef enum Roadside { |
109 |
ROADSIDE_BARREN = 0, |
|
110 |
ROADSIDE_GRASS = 1, |
|
111 |
ROADSIDE_PAVED = 2, |
|
112 |
ROADSIDE_STREET_LIGHTS = 3, |
|
113 |
ROADSIDE_TREES = 5, |
|
114 |
ROADSIDE_GRASS_ROAD_WORKS = 6, |
|
115 |
ROADSIDE_PAVED_ROAD_WORKS = 7 |
|
116 |
} Roadside; |
|
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
117 |
|
4048 | 118 |
static inline Roadside GetRoadside(TileIndex tile) |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
119 |
{ |
4048 | 120 |
return (Roadside)GB(_m[tile].m4, 4, 3); |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
121 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
122 |
|
4048 | 123 |
static inline void SetRoadside(TileIndex tile, Roadside s) |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
124 |
{ |
4048 | 125 |
SB(_m[tile].m4, 4, 3, s); |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
126 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
127 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
128 |
static inline bool HasRoadWorks(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
129 |
{ |
4048 | 130 |
return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS; |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
131 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
132 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
133 |
static inline bool IncreaseRoadWorksCounter(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
134 |
{ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
135 |
AB(_m[t].m4, 0, 4, 1); |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
136 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
137 |
return GB(_m[t].m4, 0, 4) == 15; |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
138 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
139 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
140 |
static inline void StartRoadWorks(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
141 |
{ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
142 |
assert(!HasRoadWorks(t)); |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
143 |
/* Remove any trees or lamps in case or roadwork */ |
4048 | 144 |
switch (GetRoadside(t)) { |
145 |
case ROADSIDE_BARREN: |
|
146 |
case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break; |
|
147 |
default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break; |
|
4045
9eda219bc134
(svn r5314) -Regression: When road works started on a road tile with barren roadside the road side turned into trees (caused by r4258)
tron
parents:
4000
diff
changeset
|
148 |
} |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
149 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
150 |
|
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
151 |
static inline void TerminateRoadWorks(TileIndex t) |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
152 |
{ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
153 |
assert(HasRoadWorks(t)); |
4048 | 154 |
SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS)); |
3430
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
155 |
/* Stop the counter */ |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
156 |
SB(_m[t].m4, 0, 4, 0); |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
157 |
} |
fcc344e41319
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3369
diff
changeset
|
158 |
|
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
159 |
|
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
160 |
static inline DiagDirection GetRoadDepotDirection(TileIndex t) |
3069
9a1fd047b595
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
161 |
{ |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
162 |
assert(GetRoadTileType(t) == ROAD_TILE_DEPOT); |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3322
diff
changeset
|
163 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
3167
8323c2ccd029
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3150
diff
changeset
|
164 |
} |
8323c2ccd029
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3150
diff
changeset
|
165 |
|
8323c2ccd029
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3150
diff
changeset
|
166 |
|
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
167 |
/** |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
168 |
* Returns the RoadBits on an arbitrary tile |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
169 |
* Special behavior: |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
170 |
* - road depots: entrance is treated as road piece |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
171 |
* - road tunnels: entrance is treated as road piece |
3196 | 172 |
* - bridge ramps: start of the ramp is treated as road piece |
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
173 |
* - bridge middle parts: bridge itself is ignored |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
174 |
*/ |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
175 |
RoadBits GetAnyRoadBits(TileIndex); |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
176 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
177 |
|
3150
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
178 |
TrackBits GetAnyRoadTrackBits(TileIndex tile); |
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
179 |
|
729951cb5448
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
180 |
|
4849
1c6f21eb97f2
(svn r6775) -Codechange: Use some more proper types, especially Owner and PlayerID as
Darkvater
parents:
4666
diff
changeset
|
181 |
static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, TownID town) |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
182 |
{ |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
183 |
SetTileType(t, MP_STREET); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
184 |
SetTileOwner(t, owner); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
185 |
_m[t].m2 = town; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
186 |
_m[t].m3 = 0; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
187 |
_m[t].m4 = 0 << 7 | 0 << 4 | 0; |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
188 |
_m[t].m5 = ROAD_TILE_NORMAL << 4 | bits; |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
189 |
} |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
190 |
|
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
191 |
|
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
192 |
static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner rail, Axis roaddir, RailType rt, uint town) |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
193 |
{ |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
194 |
SetTileType(t, MP_STREET); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
195 |
SetTileOwner(t, rail); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
196 |
_m[t].m2 = town; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
197 |
_m[t].m3 = road; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
198 |
_m[t].m4 = 0 << 7 | 0 << 4 | rt; |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
199 |
_m[t].m5 = ROAD_TILE_CROSSING << 4 | roaddir << 3 | 0 << 2; |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
200 |
} |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
201 |
|
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
202 |
|
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
203 |
static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir) |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
204 |
{ |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
205 |
SetTileType(t, MP_STREET); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
206 |
SetTileOwner(t, owner); |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
207 |
_m[t].m2 = 0; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
208 |
_m[t].m3 = 0; |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
209 |
_m[t].m4 = 0; |
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3560
diff
changeset
|
210 |
_m[t].m5 = ROAD_TILE_DEPOT << 4 | dir; |
3099
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
211 |
} |
571719b2cee3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3070
diff
changeset
|
212 |
|
4666
172a0cdf28a6
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4158
diff
changeset
|
213 |
#endif /* ROAD_MAP_H */ |