src/tunnel_map.h
author rubidium
Sun, 06 Apr 2008 12:26:40 +0000
branchnoai
changeset 9867 b7d9ffe24f81
parent 9723 eee46cb39750
child 10455 22c441f5adf9
permissions -rw-r--r--
(svn r12589) [NoAI] -Add: GetLastError support for AIBridge.
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
9574
698395509d12 (svn r9575) [NoAI] -Sync with trunk r9504:9574
glx
parents: 5726
diff changeset
     3
/** @file tunnel_map.h */
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"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    11
#include "tile_map.h"
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    12
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    13
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    14
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    15
 * 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
    16
 * @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
    17
 * @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
    18
 * @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
    19
 */
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
    20
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
    21
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3184
diff changeset
    22
	assert(IsTileType(t, MP_TUNNELBRIDGE));
9722
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 9629
diff changeset
    23
	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
    24
}
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
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    26
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    27
 * 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
    28
 * @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
    29
 * @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
    30
 */
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
    31
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
    32
{
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
	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
    34
}
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
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    36
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
    37
bool IsTunnelInWay(TileIndex, uint z);
9629
66dde6412125 (svn r10350) [NoAI] -Sync with trunk r10194:10349
glx
parents: 9624
diff changeset
    38
bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    39
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    40
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    41
 * 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
    42
 * @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
    43
 * @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
    44
 * @param d the direction facing out of the tunnel
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    45
 * @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
    46
 */
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    47
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
    48
{
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    49
	SetTileType(t, MP_TUNNELBRIDGE);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    50
	SetTileOwner(t, o);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    51
	_m[t].m2 = 0;
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9620
diff changeset
    52
	_m[t].m3 = r;
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    53
	_m[t].m4 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    54
	_m[t].m5 = TRANSPORT_ROAD << 2 | d;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    55
}
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    56
9620
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    57
/**
31e38d28a0af (svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents: 9574
diff changeset
    58
 * 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
    59
 * @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
    60
 * @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
    61
 * @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
    62
 * @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
    63
 */
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    64
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
    65
{
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    66
	SetTileType(t, MP_TUNNELBRIDGE);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    67
	SetTileOwner(t, o);
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    68
	_m[t].m2 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    69
	_m[t].m3 = r;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    70
	_m[t].m4 = 0;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    71
	_m[t].m5 = TRANSPORT_RAIL << 2 | d;
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    72
}
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    73
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
    74
#endif /* TUNNEL_MAP_H */