author | celestar |
Wed, 13 Jun 2007 11:45:14 +0000 | |
branch | gamebalance |
changeset 9911 | 0b8b245a2391 |
parent 9908 | 0fa543611bbe |
permissions | -rw-r--r-- |
3154 | 1 |
/* $Id$ */ |
2 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
5726
diff
changeset
|
3 |
/** @file tunnel_map.h */ |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
5726
diff
changeset
|
4 |
|
3154 | 5 |
#ifndef TUNNEL_MAP_H |
6 |
#define TUNNEL_MAP_H |
|
7 |
||
8 |
#include "direction.h" |
|
9 |
#include "macros.h" |
|
10 |
#include "map.h" |
|
11 |
#include "rail.h" |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
12 |
#include "road.h" |
3154 | 13 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
14 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
15 |
* Is this a tunnel (entrance)? |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
16 |
* @param t the tile that might be a tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
17 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
18 |
* @return true if and only if this tile is a tunnel (entrance) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
19 |
*/ |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
20 |
static inline bool IsTunnel(TileIndex t) |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
21 |
{ |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
22 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
23 |
return !HASBIT(_m[t].m5, 7); |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
24 |
} |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
25 |
|
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
26 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
27 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
28 |
* Is this a tunnel (entrance)? |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
29 |
* @param t the tile that might be a tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
30 |
* @return true if and only if this tile is a tunnel (entrance) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
31 |
*/ |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
32 |
static inline bool IsTunnelTile(TileIndex t) |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
33 |
{ |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
34 |
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t); |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
35 |
} |
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3156
diff
changeset
|
36 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
37 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
38 |
* Gets the direction facing out of the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
39 |
* @param t the tile to get the tunnel facing direction of |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
40 |
* @pre IsTunnelTile(t) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
41 |
* @return the direction the tunnel is facing |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
42 |
*/ |
3154 | 43 |
static inline DiagDirection GetTunnelDirection(TileIndex t) |
44 |
{ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
45 |
assert(IsTunnelTile(t)); |
3154 | 46 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
47 |
} |
|
48 |
||
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
49 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
50 |
* Gets the transport type of the tunnel (road or rail) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
51 |
* @param t the tunnel entrance tile to get the type of |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
52 |
* @pre IsTunnelTile(t) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
53 |
* @return the transport type in the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
54 |
*/ |
3154 | 55 |
static inline TransportType GetTunnelTransportType(TileIndex t) |
56 |
{ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
57 |
assert(IsTunnelTile(t)); |
3154 | 58 |
return (TransportType)GB(_m[t].m5, 2, 2); |
59 |
} |
|
60 |
||
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
61 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
62 |
* Is this tunnel entrance in a snowy or desert area? |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
63 |
* @param t the tunnel entrance tile |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
64 |
* @pre IsTunnelTile(t) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
65 |
* @return true if and only if the tunnel entrance is in a snowy/desert area |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
66 |
*/ |
5661
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
67 |
static inline bool HasTunnelSnowOrDesert(TileIndex t) |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
68 |
{ |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
69 |
assert(IsTunnelTile(t)); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
70 |
return HASBIT(_m[t].m4, 7); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
71 |
} |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
72 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
73 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
74 |
* Places this tunnel entrance in a snowy or desert area, |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
75 |
* or takes it out of there. |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
76 |
* @param t the tunnel entrance tile |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
77 |
* @param snow_or_desert is the entrance in snow or desert (true), when |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
78 |
* not in snow and not in desert false |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
79 |
* @pre IsTunnelTile(t) |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
80 |
*/ |
5661
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
81 |
static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert) |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
82 |
{ |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
83 |
assert(IsTunnelTile(t)); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
84 |
SB(_m[t].m4, 7, 1, snow_or_desert); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
85 |
} |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
86 |
|
3154 | 87 |
|
88 |
TileIndex GetOtherTunnelEnd(TileIndex); |
|
3156
028b6756b279
(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents:
3154
diff
changeset
|
89 |
bool IsTunnelInWay(TileIndex, uint z); |
3154 | 90 |
|
91 |
||
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
92 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
93 |
* Makes a road tunnel entrance |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
94 |
* @param t the entrance of the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
95 |
* @param o the owner of the entrance |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
96 |
* @param d the direction facing out of the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
97 |
* @param r the road type used in the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
98 |
*/ |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
99 |
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r) |
3154 | 100 |
{ |
101 |
SetTileType(t, MP_TUNNELBRIDGE); |
|
102 |
SetTileOwner(t, o); |
|
103 |
_m[t].m2 = 0; |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
104 |
_m[t].m3 = r; |
3154 | 105 |
_m[t].m4 = 0; |
106 |
_m[t].m5 = TRANSPORT_ROAD << 2 | d; |
|
107 |
} |
|
108 |
||
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
109 |
/** |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
110 |
* Makes a rail tunnel entrance |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
111 |
* @param t the entrance of the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
112 |
* @param o the owner of the entrance |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
113 |
* @param d the direction facing out of the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
114 |
* @param r the rail type used in the tunnel |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9908
diff
changeset
|
115 |
*/ |
3154 | 116 |
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r) |
117 |
{ |
|
118 |
SetTileType(t, MP_TUNNELBRIDGE); |
|
119 |
SetTileOwner(t, o); |
|
120 |
_m[t].m2 = 0; |
|
121 |
_m[t].m3 = r; |
|
122 |
_m[t].m4 = 0; |
|
123 |
_m[t].m5 = TRANSPORT_RAIL << 2 | d; |
|
124 |
} |
|
125 |
||
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
3369
diff
changeset
|
126 |
#endif /* TUNNEL_MAP_H */ |