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"
|
|
13 |
|
|
14 |
|
|
15 |
/**
|
9732
|
16 |
* Get the direction pointing to the other end.
|
|
17 |
*
|
|
18 |
* Tunnel: Get the direction facing into the tunnel
|
9723
|
19 |
* Bridge: Get the direction pointing onto the bridge
|
|
20 |
* @param t The tile to analyze
|
|
21 |
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
22 |
* @return the above mentionned direction
|
|
23 |
*/
|
|
24 |
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
|
|
25 |
{
|
|
26 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
27 |
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
|
28 |
}
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Tunnel: Get the transport type of the tunnel (road or rail)
|
|
32 |
* Bridge: Get the transport type of the bridge's ramp
|
|
33 |
* @param t The tile to analyze
|
|
34 |
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
35 |
* @return the transport type in the tunnel/bridge
|
|
36 |
*/
|
|
37 |
static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
|
|
38 |
{
|
|
39 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
40 |
return (TransportType)GB(_m[t].m5, 2, 2);
|
|
41 |
}
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Tunnel: Is this tunnel entrance in a snowy or desert area?
|
|
45 |
* Bridge: Does the bridge ramp lie in a snow or desert area?
|
|
46 |
* @param t The tile to analyze
|
|
47 |
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
48 |
* @return true if and only if the tile is in a snowy/desert area
|
|
49 |
*/
|
|
50 |
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
|
|
51 |
{
|
|
52 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
53 |
return HasBit(_m[t].m4, 7);
|
|
54 |
}
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there.
|
|
58 |
* Bridge: Sets whether the bridge ramp lies in a snow or desert area.
|
|
59 |
* @param t the tunnel entrance / bridge ramp tile
|
|
60 |
* @param snow_or_desert is the entrance/ramp in snow or desert (true), when
|
|
61 |
* not in snow and not in desert false
|
|
62 |
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
63 |
*/
|
|
64 |
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
|
|
65 |
{
|
|
66 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
67 |
SB(_m[t].m4, 7, 1, snow_or_desert);
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Determines type of the wormhole and returns its other end
|
|
72 |
* @param t one end
|
|
73 |
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
74 |
* @return other end
|
|
75 |
*/
|
|
76 |
static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
|
|
77 |
{
|
|
78 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
79 |
return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
|
|
80 |
}
|
|
81 |
|
|
82 |
#endif /* TUNNELBRIDGE_MAP_H */
|