author | truebrain |
Fri, 18 Jul 2008 10:15:16 +0000 | |
branch | noai |
changeset 11168 | 3842648184cd |
parent 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */ |
|
4 |
||
5 |
#ifndef TUNNELBRIDGE_MAP_H |
|
6 |
#define TUNNELBRIDGE_MAP_H |
|
7 |
||
8 |
#include "direction_func.h" |
|
9 |
#include "core/bitmath_func.hpp" |
|
10 |
#include "tile_map.h" |
|
11 |
#include "bridge_map.h" |
|
12 |
#include "tunnel_map.h" |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9732
diff
changeset
|
13 |
#include "transport_type.h" |
9723 | 14 |
|
15 |
||
16 |
/** |
|
9732 | 17 |
* Get the direction pointing to the other end. |
18 |
* |
|
19 |
* Tunnel: Get the direction facing into the tunnel |
|
9723 | 20 |
* Bridge: Get the direction pointing onto the bridge |
21 |
* @param t The tile to analyze |
|
22 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
23 |
* @return the above mentionned direction |
|
24 |
*/ |
|
25 |
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t) |
|
26 |
{ |
|
27 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
28 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
|
29 |
} |
|
30 |
||
31 |
/** |
|
32 |
* Tunnel: Get the transport type of the tunnel (road or rail) |
|
33 |
* Bridge: Get the transport type of the bridge's ramp |
|
34 |
* @param t The tile to analyze |
|
35 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
36 |
* @return the transport type in the tunnel/bridge |
|
37 |
*/ |
|
38 |
static inline TransportType GetTunnelBridgeTransportType(TileIndex t) |
|
39 |
{ |
|
40 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
41 |
return (TransportType)GB(_m[t].m5, 2, 2); |
|
42 |
} |
|
43 |
||
44 |
/** |
|
45 |
* Tunnel: Is this tunnel entrance in a snowy or desert area? |
|
46 |
* Bridge: Does the bridge ramp lie in a snow or desert area? |
|
47 |
* @param t The tile to analyze |
|
48 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
49 |
* @return true if and only if the tile is in a snowy/desert area |
|
50 |
*/ |
|
51 |
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t) |
|
52 |
{ |
|
53 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
54 |
return HasBit(_m[t].m4, 7); |
|
55 |
} |
|
56 |
||
57 |
/** |
|
58 |
* Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there. |
|
59 |
* Bridge: Sets whether the bridge ramp lies in a snow or desert area. |
|
60 |
* @param t the tunnel entrance / bridge ramp tile |
|
61 |
* @param snow_or_desert is the entrance/ramp in snow or desert (true), when |
|
62 |
* not in snow and not in desert false |
|
63 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
64 |
*/ |
|
65 |
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert) |
|
66 |
{ |
|
67 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
68 |
SB(_m[t].m4, 7, 1, snow_or_desert); |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* Determines type of the wormhole and returns its other end |
|
73 |
* @param t one end |
|
74 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
|
75 |
* @return other end |
|
76 |
*/ |
|
77 |
static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) |
|
78 |
{ |
|
79 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
|
80 |
return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); |
|
81 |
} |
|
82 |
||
83 |
#endif /* TUNNELBRIDGE_MAP_H */ |