src/tunnelbridge_map.h
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 8977 e6ebfc5024cb
child 10444 3876060cdef7
permissions -rw-r--r--
update tags
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"
8579
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    13
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
/**
8977
e6ebfc5024cb (svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents: 8693
diff changeset
    16
 * 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
    17
 *
e6ebfc5024cb (svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch
parents: 8693
diff changeset
    18
 * 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
    19
 * 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
    20
 * @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
    21
 * @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
    22
 * @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
    23
 */
3efbb430092e (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)
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    25
{
3efbb430092e (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));
3efbb430092e (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);
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    28
}
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
 * 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
    32
 * 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
    33
 * @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
    34
 * @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
    35
 * @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
    36
 */
3efbb430092e (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)
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    38
{
3efbb430092e (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));
3efbb430092e (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);
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    41
}
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
 * 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
    45
 * 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
    46
 * @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
    47
 * @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
    48
 * @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
    49
 */
3efbb430092e (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)
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    51
{
3efbb430092e (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));
3efbb430092e (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);
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    54
}
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
 * 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
    58
 * 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
    59
 * @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
    60
 * @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
    61
 *                       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
    62
 * @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
    63
 */
3efbb430092e (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)
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    65
{
3efbb430092e (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));
3efbb430092e (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);
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    68
}
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
diff changeset
    69
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
    70
/**
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
 * 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
    72
 * @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
    73
 * @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
    74
 * @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
    75
 */
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
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
    77
{
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
	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
    79
	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
    80
}
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
8579
3efbb430092e (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 */