author | celestar |
Mon, 19 Mar 2007 12:38:16 +0000 | |
branch | gamebalance |
changeset 9895 | 7bd07f43b0e3 |
parent 6442 | 10b44714b85d |
child 6307 | f40e88cff863 |
child 6719 | 4cc327ad39d5 |
permissions | -rw-r--r-- |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
2 |
|
3518
53847cf852c6
(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
|
3 |
#ifndef ROAD_H |
53847cf852c6
(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
|
4 |
#define ROAD_H |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
5 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
6 |
#include "helpers.hpp" |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
7 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6442
diff
changeset
|
8 |
enum RoadBits { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
9 |
ROAD_NONE = 0U, |
3795
52398950b042
(svn r4791) - Codechange: Mark road bits as unsigned. Fixes warning with older gcc versions.
peter1138
parents:
3518
diff
changeset
|
10 |
ROAD_NW = 1U, |
52398950b042
(svn r4791) - Codechange: Mark road bits as unsigned. Fixes warning with older gcc versions.
peter1138
parents:
3518
diff
changeset
|
11 |
ROAD_SW = 2U, |
52398950b042
(svn r4791) - Codechange: Mark road bits as unsigned. Fixes warning with older gcc versions.
peter1138
parents:
3518
diff
changeset
|
12 |
ROAD_SE = 4U, |
52398950b042
(svn r4791) - Codechange: Mark road bits as unsigned. Fixes warning with older gcc versions.
peter1138
parents:
3518
diff
changeset
|
13 |
ROAD_NE = 8U, |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
14 |
ROAD_X = ROAD_SW | ROAD_NE, |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
15 |
ROAD_Y = ROAD_NW | ROAD_SE, |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
16 |
ROAD_ALL = ROAD_X | ROAD_Y |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6442
diff
changeset
|
17 |
}; |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
diff
changeset
|
18 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
19 |
DECLARE_ENUM_AS_BIT_SET(RoadBits); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
20 |
|
3103
fb7f22d3bc9b
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
21 |
static inline RoadBits ComplementRoadBits(RoadBits r) |
fb7f22d3bc9b
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
22 |
{ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3795
diff
changeset
|
23 |
return (RoadBits)(ROAD_ALL ^ r); |
3103
fb7f22d3bc9b
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
24 |
} |
fb7f22d3bc9b
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3099
diff
changeset
|
25 |
|
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
26 |
static inline RoadBits DiagDirToRoadBits(DiagDirection d) |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
27 |
{ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3795
diff
changeset
|
28 |
return (RoadBits)(1U << (3 ^ d)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
29 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
3145
diff
changeset
|
30 |
|
6335
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
31 |
/** Checks whether the trackdir means that we are reversing */ |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
32 |
static inline bool IsReversingRoadTrackdir(Trackdir dir) |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
33 |
{ |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
34 |
return (dir & 0x07) >= 6; |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
35 |
} |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
36 |
|
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
37 |
/** Checks whether the given trackdir is a straight road */ |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
38 |
static inline bool IsStraightRoadTrackdir(Trackdir dir) |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
39 |
{ |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
40 |
return (dir & 0x06) == 0; |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
41 |
} |
0c3dc188f099
(svn r8730) -Codechange: more replacements of magic numbers by enums and removal of some (by now) redundant comments.
rubidium
parents:
5838
diff
changeset
|
42 |
|
6442
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
43 |
/** |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
44 |
* Is it allowed to remove the given road bits from the given tile? |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
45 |
* @param tile the tile to remove the road from |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
46 |
* @param remove the roadbits that are going to be removed |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
47 |
* @param owner the actual owner of the roadbits of the tile |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
48 |
* @param edge_road are the removed bits from a town? |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
49 |
* @return true when it is allowed to remove the road bits |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
50 |
*/ |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
51 |
bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road); |
10b44714b85d
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium
parents:
6335
diff
changeset
|
52 |
|
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
3900
diff
changeset
|
53 |
#endif /* ROAD_H */ |