bridge_map.h
author Darkvater
Mon, 31 Jul 2006 15:49:12 +0000
branch0.4
changeset 10070 308b88d1851f
parent 10032 fcf09abbde96
permissions -rw-r--r--
(svn r5678) - Prepare 0.4 branch for release. Update readme's, bugs, installers, changelog, etc. to 0.4.8-RC2
10032
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     1
/* $Id$ */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     2
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     3
#ifndef BRIDGE_MAP_H
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     4
#define BRIDGE_MAP_H
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     5
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     6
#include "direction.h"
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     7
#include "macros.h"
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     8
#include "map.h"
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     9
#include "rail.h"
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    10
#include "tile.h"
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    11
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    12
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    13
static inline bool IsBridge(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    14
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    15
	assert(IsTileType(t, MP_TUNNELBRIDGE));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    16
	return HASBIT(_m[t].m5, 7);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    17
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    18
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    19
static inline bool IsBridgeTile(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    20
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    21
	return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    22
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    23
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    24
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    25
static inline bool IsBridgeRamp(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    26
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    27
	assert(IsBridgeTile(t));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    28
	return !HASBIT(_m[t].m5, 6);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    29
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    30
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    31
static inline bool IsBridgeMiddle(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    32
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    33
	assert(IsBridgeTile(t));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    34
	return HASBIT(_m[t].m5, 6);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    35
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    36
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    37
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    38
/**
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    39
 * Get the direction pointing onto the bridge
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    40
 */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    41
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    42
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    43
	assert(IsBridgeRamp(t));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    44
	/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    45
	 * bridges to a DiagDirection
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    46
	 */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    47
	return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    48
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    49
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    50
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    51
static inline Axis GetBridgeAxis(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    52
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    53
	assert(IsBridgeMiddle(t));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    54
	return (Axis)GB(_m[t].m5, 0, 1);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    55
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    56
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    57
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    58
static inline bool IsTransportUnderBridge(TileIndex t)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    59
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    60
	assert(IsBridgeMiddle(t));
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    61
	return HASBIT(_m[t].m5, 5);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    62
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    63
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    64
#endif