src/tunnel_map.h
author rubidium
Wed, 07 May 2008 21:09:51 +0000
branchnoai
changeset 10455 22c441f5adf9
parent 9723 eee46cb39750
permissions -rw-r--r--
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     1
/* $Id$ */
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     2
10455
22c441f5adf9 (svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents: 9723
diff changeset
     3
/** @file tunnel_map.h Map accessors for tunnels. */
9574
698395509d12 (svn r9575) [NoAI] -Sync with trunk r9504:9574
glx
parents: 5726
diff changeset
     4
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     5
#ifndef TUNNEL_MAP_H
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     6
#define TUNNEL_MAP_H
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     7
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
     8
#include "direction_func.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
     9
#include "rail_type.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    10
#include "road_type.h"
10455
22c441f5adf9 (svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents: 9723
diff changeset
    11
#include "transport_type.h"
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    12
#include "tile_map.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    13
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    14
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    15
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    16
 * Is this a tunnel (entrance)?
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    17
 * @param t the tile that might be a tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    18
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    19
 * @return true if and only if this tile is a tunnel (entrance)
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    20
 */
3184
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    21
static inline bool IsTunnel(TileIndex t)
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    22
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3184
diff changeset
    23
	assert(IsTileType(t, MP_TUNNELBRIDGE));
9722
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 9629
diff changeset
    24
	return !HasBit(_m[t].m5, 7);
3184
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    25
}
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    26
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    27
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    28
 * Is this a tunnel (entrance)?
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    29
 * @param t the tile that might be a tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    30
 * @return true if and only if this tile is a tunnel (entrance)
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    31
 */
3184
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    32
static inline bool IsTunnelTile(TileIndex t)
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    33
{
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    34
	return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    35
}
7405329343ce (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    36
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    37
TileIndex GetOtherTunnelEnd(TileIndex);
3156
028b6756b279 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    38
bool IsTunnelInWay(TileIndex, uint z);
9629
66dde6412125 (svn r10350) [NoAI] -Sync with trunk r10194:10349
glx
parents: 9624
diff changeset
    39
bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    40
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    41
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    42
 * Makes a road tunnel entrance
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    43
 * @param t the entrance of the tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    44
 * @param o the owner of the entrance
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    45
 * @param d the direction facing out of the tunnel
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    46
 * @param r the road type used in the tunnel
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    47
 */
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    48
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    49
{
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    50
	SetTileType(t, MP_TUNNELBRIDGE);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    51
	SetTileOwner(t, o);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    52
	_m[t].m2 = 0;
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    53
	_m[t].m3 = r;
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    54
	_m[t].m4 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    55
	_m[t].m5 = TRANSPORT_ROAD << 2 | d;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    56
}
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    57
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    58
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    59
 * Makes a rail tunnel entrance
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    60
 * @param t the entrance of the tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    61
 * @param o the owner of the entrance
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    62
 * @param d the direction facing out of the tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    63
 * @param r the rail type used in the tunnel
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    64
 */
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    65
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    66
{
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    67
	SetTileType(t, MP_TUNNELBRIDGE);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    68
	SetTileOwner(t, o);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    69
	_m[t].m2 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    70
	_m[t].m3 = r;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    71
	_m[t].m4 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    72
	_m[t].m5 = TRANSPORT_RAIL << 2 | d;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    73
}
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    74
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3369
diff changeset
    75
#endif /* TUNNEL_MAP_H */