author | frosch |
Mon, 04 Feb 2008 15:26:35 +0000 | |
changeset 8481 | b12960a2e770 |
parent 8197 | 3af783256580 |
child 9126 | 5648d696456b |
permissions | -rw-r--r-- |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
1 |
/* $Id$ */ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
2 |
|
ad22eade501f
(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 */ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
4 |
|
ad22eade501f
(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 |
ad22eade501f
(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 |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
7 |
|
8100
6bc08f98ec16
(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:
8083
diff
changeset
|
8 |
#include "direction_func.h" |
8139
4e91c448c409
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8108
diff
changeset
|
9 |
#include "core/bitmath_func.hpp" |
4e91c448c409
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8108
diff
changeset
|
10 |
#include "tile_map.h" |
8197
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
11 |
#include "bridge_map.h" |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
12 |
#include "tunnel_map.h" |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
13 |
|
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
14 |
|
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
15 |
/** |
8481
b12960a2e770
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8197
diff
changeset
|
16 |
* Get the direction pointing to the other end. |
b12960a2e770
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8197
diff
changeset
|
17 |
* |
b12960a2e770
(svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents:
8197
diff
changeset
|
18 |
* Tunnel: Get the direction facing into the tunnel |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
19 |
* Bridge: Get the direction pointing onto the bridge |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
20 |
* @param t The tile to analyze |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
21 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
22 |
* @return the above mentionned direction |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
23 |
*/ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
24 |
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
25 |
{ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
26 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
27 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
28 |
} |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
29 |
|
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
30 |
/** |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
31 |
* Tunnel: Get the transport type of the tunnel (road or rail) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
32 |
* Bridge: Get the transport type of the bridge's ramp |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
33 |
* @param t The tile to analyze |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
34 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
35 |
* @return the transport type in the tunnel/bridge |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
36 |
*/ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
37 |
static inline TransportType GetTunnelBridgeTransportType(TileIndex t) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
38 |
{ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
39 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
40 |
return (TransportType)GB(_m[t].m5, 2, 2); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
41 |
} |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
42 |
|
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
43 |
/** |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
44 |
* Tunnel: Is this tunnel entrance in a snowy or desert area? |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
45 |
* Bridge: Does the bridge ramp lie in a snow or desert area? |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
46 |
* @param t The tile to analyze |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
47 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
48 |
* @return true if and only if the tile is in a snowy/desert area |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
49 |
*/ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
50 |
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
51 |
{ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
52 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
53 |
return HasBit(_m[t].m4, 7); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
54 |
} |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
55 |
|
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
56 |
/** |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
57 |
* Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there. |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
58 |
* Bridge: Sets whether the bridge ramp lies in a snow or desert area. |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
59 |
* @param t the tunnel entrance / bridge ramp tile |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
60 |
* @param snow_or_desert is the entrance/ramp in snow or desert (true), when |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
61 |
* not in snow and not in desert false |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
62 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
63 |
*/ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
64 |
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert) |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
65 |
{ |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
66 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
67 |
SB(_m[t].m4, 7, 1, snow_or_desert); |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
68 |
} |
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
69 |
|
8197
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
70 |
/** |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
71 |
* Determines type of the wormhole and returns its other end |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
72 |
* @param t one end |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
73 |
* @pre IsTileType(t, MP_TUNNELBRIDGE) |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
74 |
* @return other end |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
75 |
*/ |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
76 |
static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t) |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
77 |
{ |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
78 |
assert(IsTileType(t, MP_TUNNELBRIDGE)); |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
79 |
return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t); |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
80 |
} |
3af783256580
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz
parents:
8142
diff
changeset
|
81 |
|
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff
changeset
|
82 |
#endif /* TUNNELBRIDGE_MAP_H */ |