author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10444 | 3876060cdef7 |
permissions | -rw-r--r-- |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
1 |
/* $Id$ */ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
2 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
3 |
/** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
4 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
5 |
#ifndef TUNNELBRIDGE_MAP_H |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
6 |
#define TUNNELBRIDGE_MAP_H |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
7 |
|
8596
27646407e0bc
(svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents:
8579
diff
changeset
|
8 |
#include "direction_func.h" |
8635
3bbb6f87fced
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8604
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
3bbb6f87fced
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8604
diff
changeset
|
10 |
#include "tile_map.h" |
8693
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
11 |
#include "bridge_map.h" |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
12 |
#include "tunnel_map.h" |
10444
3876060cdef7
(svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents:
8977
diff
changeset
|
13 |
#include "transport_type.h" |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
14 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
15 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
16 |
/** |
8977
e6ebfc5024cb
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8693
diff
changeset
|
17 |
* Get the direction pointing to the other end. |
e6ebfc5024cb
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8693
diff
changeset
|
18 |
* |
e6ebfc5024cb
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8693
diff
changeset
|
19 |
* Tunnel: Get the direction facing into the tunnel |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
20 |
* Bridge: Get the direction pointing onto the bridge |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
21 |
* @param t The tile to analyze |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
22 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
23 |
* @return the above mentionned direction |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
24 |
*/ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
25 |
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
26 |
{ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
27 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
28 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
29 |
} |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
30 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
31 |
/** |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
32 |
* Tunnel: Get the transport type of the tunnel (road or rail) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
33 |
* Bridge: Get the transport type of the bridge's ramp |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
34 |
* @param t The tile to analyze |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
35 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
36 |
* @return the transport type in the tunnel/bridge |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
37 |
*/ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
38 |
static inline TransportType GetTunnelBridgeTransportType(TileIndex t) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
39 |
{ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
40 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
41 |
return (TransportType)GB(_m[t].m5, 2, 2); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
42 |
} |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
43 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
44 |
/** |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
45 |
* Tunnel: Is this tunnel entrance in a snowy or desert area? |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
46 |
* Bridge: Does the bridge ramp lie in a snow or desert area? |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
47 |
* @param t The tile to analyze |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
48 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
49 |
* @return true if and only if the tile is in a snowy/desert area |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
50 |
*/ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
51 |
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
52 |
{ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
53 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
54 |
return HasBit(_m[t].m4, 7); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
55 |
} |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
56 |
|
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
57 |
/** |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
58 |
* Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there. |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
59 |
* Bridge: Sets whether the bridge ramp lies in a snow or desert area. |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
60 |
* @param t the tunnel entrance / bridge ramp tile |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
61 |
* @param snow_or_desert is the entrance/ramp in snow or desert (true), when |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
62 |
* not in snow and not in desert false |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
63 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
64 |
*/ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
65 |
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert) |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
66 |
{ |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
67 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
68 |
SB(_m[t].m4, 7, 1, snow_or_desert); |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
69 |
} |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
70 |
|
8693
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
71 |
/** |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
72 |
* Determines type of the wormhole and returns its other end |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
73 |
* @param t one end |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
74 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
75 |
* @return other end |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
76 |
*/ |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
77 |
static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
78 |
{ |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
79 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
80 |
return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
81 |
} |
3d721429cc4f
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8638
diff
changeset
|
82 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
83 |
#endif /* TUNNELBRIDGE_MAP_H */ |