10032
|
1 |
/* $Id$ */
|
|
2 |
|
|
3 |
#ifndef BRIDGE_MAP_H
|
|
4 |
#define BRIDGE_MAP_H
|
|
5 |
|
|
6 |
#include "direction.h"
|
|
7 |
#include "macros.h"
|
|
8 |
#include "map.h"
|
|
9 |
#include "rail.h"
|
|
10 |
#include "tile.h"
|
|
11 |
|
|
12 |
|
|
13 |
static inline bool IsBridge(TileIndex t)
|
|
14 |
{
|
|
15 |
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
|
16 |
return HASBIT(_m[t].m5, 7);
|
|
17 |
}
|
|
18 |
|
|
19 |
static inline bool IsBridgeTile(TileIndex t)
|
|
20 |
{
|
|
21 |
return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
|
|
22 |
}
|
|
23 |
|
|
24 |
|
|
25 |
static inline bool IsBridgeRamp(TileIndex t)
|
|
26 |
{
|
|
27 |
assert(IsBridgeTile(t));
|
|
28 |
return !HASBIT(_m[t].m5, 6);
|
|
29 |
}
|
|
30 |
|
|
31 |
static inline bool IsBridgeMiddle(TileIndex t)
|
|
32 |
{
|
|
33 |
assert(IsBridgeTile(t));
|
|
34 |
return HASBIT(_m[t].m5, 6);
|
|
35 |
}
|
|
36 |
|
|
37 |
|
|
38 |
/**
|
|
39 |
* Get the direction pointing onto the bridge
|
|
40 |
*/
|
|
41 |
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
|
|
42 |
{
|
|
43 |
assert(IsBridgeRamp(t));
|
|
44 |
/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
|
|
45 |
* bridges to a DiagDirection
|
|
46 |
*/
|
|
47 |
return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
static inline Axis GetBridgeAxis(TileIndex t)
|
|
52 |
{
|
|
53 |
assert(IsBridgeMiddle(t));
|
|
54 |
return (Axis)GB(_m[t].m5, 0, 1);
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
static inline bool IsTransportUnderBridge(TileIndex t)
|
|
59 |
{
|
|
60 |
assert(IsBridgeMiddle(t));
|
|
61 |
return HASBIT(_m[t].m5, 5);
|
|
62 |
}
|
|
63 |
|
|
64 |
#endif
|