author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5475 | 2e6990a8c7c4 |
child 6422 | 6679df1c05ba |
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
118a520164e4
(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) |
118a520164e4
(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
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3184
diff
changeset
|
14 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3184
118a520164e4
(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); |
118a520164e4
(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 |
} |
118a520164e4
(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 |
|
118a520164e4
(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 |
|
118a520164e4
(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) |
118a520164e4
(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 |
{ |
118a520164e4
(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); |
118a520164e4
(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 |
} |
118a520164e4
(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 |
|
118a520164e4
(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
cab209754317
(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
cab209754317
(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 |
||
5410
2dae82c6ea63
(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) |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
39 |
{ |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
40 |
assert(IsTunnelTile(t)); |
2dae82c6ea63
(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); |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
42 |
} |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
43 |
|
2dae82c6ea63
(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) |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
45 |
{ |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
46 |
assert(IsTunnelTile(t)); |
2dae82c6ea63
(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); |
2dae82c6ea63
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
4666
diff
changeset
|
48 |
} |
2dae82c6ea63
(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
f4caf4197189
(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
172a0cdf28a6
(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 */ |