src/tunnel_map.h
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 9126 5648d696456b
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     1
/* $Id$ */
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8139
diff changeset
     3
/** @file tunnel_map.h Map accessors for tunnels. */
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 5475
diff changeset
     4
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     5
#ifndef TUNNEL_MAP_H
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     6
#define TUNNEL_MAP_H
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
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"
8102
906a3d3b6df1 (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8100
diff changeset
     9
#include "rail_type.h"
906a3d3b6df1 (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8100
diff changeset
    10
#include "road_type.h"
9126
5648d696456b (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents: 9111
diff changeset
    11
#include "transport_type.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8102
diff changeset
    12
#include "tile_map.h"
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    13
8083
ad22eade501f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents: 7928
diff changeset
    14
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    15
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    16
 * Is this a tunnel (entrance)?
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    17
 * @param t the tile that might be a tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    18
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    19
 * @return true if and only if this tile is a tunnel (entrance)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    20
 */
3184
118a520164e4 (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)
118a520164e4 (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
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3184
diff changeset
    23
	assert(IsTileType(t, MP_TUNNELBRIDGE));
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7002
diff changeset
    24
	return !HasBit(_m[t].m5, 7);
3184
118a520164e4 (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
}
118a520164e4 (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
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    27
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    28
 * Is this a tunnel (entrance)?
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    29
 * @param t the tile that might be a tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    30
 * @return true if and only if this tile is a tunnel (entrance)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    31
 */
3184
118a520164e4 (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)
118a520164e4 (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
{
118a520164e4 (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);
118a520164e4 (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
}
118a520164e4 (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
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    37
TileIndex GetOtherTunnelEnd(TileIndex);
3156
f4caf4197189 (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);
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6661
diff changeset
    39
bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    40
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    41
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    42
 * Makes a road tunnel entrance
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    43
 * @param t the entrance of the tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    44
 * @param o the owner of the entrance
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    45
 * @param d the direction facing out of the tunnel
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6540
diff changeset
    46
 * @param r the road type used in the tunnel
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    47
 */
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6540
diff changeset
    48
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    49
{
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    50
	SetTileType(t, MP_TUNNELBRIDGE);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    51
	SetTileOwner(t, o);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    52
	_m[t].m2 = 0;
6661
1716fce5ad29 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6540
diff changeset
    53
	_m[t].m3 = r;
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    54
	_m[t].m4 = 0;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    55
	_m[t].m5 = TRANSPORT_ROAD << 2 | d;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    56
}
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    57
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    58
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    59
 * Makes a rail tunnel entrance
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    60
 * @param t the entrance of the tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    61
 * @param o the owner of the entrance
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    62
 * @param d the direction facing out of the tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    63
 * @param r the rail type used in the tunnel
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6422
diff changeset
    64
 */
3154
6ab0cb6b7ab3 (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)
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    66
{
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    67
	SetTileType(t, MP_TUNNELBRIDGE);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    68
	SetTileOwner(t, o);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    69
	_m[t].m2 = 0;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    70
	_m[t].m3 = r;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    71
	_m[t].m4 = 0;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    72
	_m[t].m5 = TRANSPORT_RAIL << 2 | d;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    73
}
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    74
4666
172a0cdf28a6 (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 */