author | rubidium |
Fri, 29 Dec 2006 09:10:44 +0000 | |
changeset 5661 | 6c6145677e7c |
parent 4666 | 850b5b6e4bac |
permissions | -rw-r--r-- |
3154 | 1 |
/* $Id$ */ |
2 |
||
3 |
#ifndef TUNNEL_MAP_H |
|
4 |
#define TUNNEL_MAP_H |
|
5 |
||
6 |
#include "direction.h" |
|
7 |
#include "macros.h" |
|
8 |
#include "map.h" |
|
9 |
#include "rail.h" |
|
10 |
||
11 |
||
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
|
12 |
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
|
13 |
{ |
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
14 |
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
|
15 |
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
|
16 |
} |
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
|
17 |
|
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
|
18 |
|
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
|
19 |
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
|
20 |
{ |
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 |
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
|
22 |
} |
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 |
|
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 |
|
3154 | 25 |
static inline DiagDirection GetTunnelDirection(TileIndex t) |
26 |
{ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
27 |
assert(IsTunnelTile(t)); |
3154 | 28 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
29 |
} |
|
30 |
||
31 |
||
32 |
static inline TransportType GetTunnelTransportType(TileIndex t) |
|
33 |
{ |
|
3369
00c2ca209a89
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
34 |
assert(IsTunnelTile(t)); |
3154 | 35 |
return (TransportType)GB(_m[t].m5, 2, 2); |
36 |
} |
|
37 |
||
5661
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
38 |
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
|
39 |
{ |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
40 |
assert(IsTunnelTile(t)); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
41 |
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
|
42 |
} |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
43 |
|
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
44 |
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
|
45 |
{ |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
46 |
assert(IsTunnelTile(t)); |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
47 |
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
|
48 |
} |
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
49 |
|
3154 | 50 |
|
51 |
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
|
52 |
bool IsTunnelInWay(TileIndex, uint z); |
3154 | 53 |
|
54 |
||
55 |
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d) |
|
56 |
{ |
|
57 |
SetTileType(t, MP_TUNNELBRIDGE); |
|
58 |
SetTileOwner(t, o); |
|
59 |
_m[t].m2 = 0; |
|
60 |
_m[t].m3 = 0; |
|
61 |
_m[t].m4 = 0; |
|
62 |
_m[t].m5 = TRANSPORT_ROAD << 2 | d; |
|
63 |
} |
|
64 |
||
65 |
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r) |
|
66 |
{ |
|
67 |
SetTileType(t, MP_TUNNELBRIDGE); |
|
68 |
SetTileOwner(t, o); |
|
69 |
_m[t].m2 = 0; |
|
70 |
_m[t].m3 = r; |
|
71 |
_m[t].m4 = 0; |
|
72 |
_m[t].m5 = TRANSPORT_RAIL << 2 | d; |
|
73 |
} |
|
74 |
||
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
|
75 |
#endif /* TUNNEL_MAP_H */ |