src/tunnel_map.h
author rubidium
Fri, 04 Jul 2008 19:00:11 +0000
changeset 11118 f66e0a4ce878
parent 10444 3876060cdef7
permissions -rw-r--r--
(svn r13676) -Fix [FS#2126]: inactive companies from old (TTD) saves could be marked active in some cases, which then loads garbage in their statistics and such.
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
10429
1b99254f9607 (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: 8635
diff changeset
     3
/** @file tunnel_map.h Map accessors for tunnels. */
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
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
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"
8598
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8596
diff changeset
     9
#include "rail_type.h"
14ae80fe4c8f (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8596
diff changeset
    10
#include "road_type.h"
10444
3876060cdef7 (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents: 10429
diff changeset
    11
#include "transport_type.h"
8604
8afdd9877afd (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8598
diff changeset
    12
#include "tile_map.h"
3154
a8fffb204d0e (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    13
8579
3efbb430092e (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents: 8424
diff changeset
    14
7036
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    15
/**
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    16
 * Is this a tunnel (entrance)?
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    17
 * @param t the tile that might be a tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    18
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    19
 * @return true if and only if this tile is a tunnel (entrance)
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
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));
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7498
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
7036
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    27
/**
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    28
 * Is this a tunnel (entrance)?
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    29
 * @param t the tile that might be a tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    30
 * @return true if and only if this tile is a tunnel (entrance)
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
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);
7498
ce6588257e8d (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: 7157
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
7036
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    41
/**
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    42
 * Makes a road tunnel entrance
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    43
 * @param t the entrance of the tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    44
 * @param o the owner of the entrance
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    45
 * @param d the direction facing out of the tunnel
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 7036
diff changeset
    46
 * @param r the road type used in the tunnel
7036
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    47
 */
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 7036
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;
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 7036
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
7036
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    58
/**
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    59
 * Makes a rail tunnel entrance
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    60
 * @param t the entrance of the tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    61
 * @param o the owner of the entrance
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    62
 * @param d the direction facing out of the tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
diff changeset
    63
 * @param r the rail type used in the tunnel
9f23930e7ded (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6918
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 */