src/bridge_map.h
author belugas
Wed, 04 Apr 2007 01:35:16 +0000
changeset 6420 456c275f3313
parent 6418 e04693bbe82a
child 6661 1716fce5ad29
permissions -rw-r--r--
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     1
/* $Id$ */
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     2
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
     3
/** @file bridge_map.h Map accessor functions for bridges. */
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5596
diff changeset
     4
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     5
#ifndef BRIDGE_MAP_H
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     6
#define BRIDGE_MAP_H
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     7
3196
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
     8
#include "direction.h"
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     9
#include "macros.h"
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    10
#include "map.h"
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    11
#include "rail.h"
3234
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    12
#include "road_map.h"
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    13
#include "tile.h"
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    14
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    15
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    16
/**
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    17
 * Checks if this is a bridge, instead of a tunnel
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    18
 * @param t The tile to analyze
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    19
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    20
 * @return true if the structure is a bridge one
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    21
 */
3234
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    22
static inline bool IsBridge(TileIndex t)
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    23
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    24
	assert(IsTileType(t, MP_TUNNELBRIDGE));
3234
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    25
	return HASBIT(_m[t].m5, 7);
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    26
}
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    27
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    28
/**
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    29
 * checks if there is a bridge on this tile
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    30
 * @param t The tile to analyze
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    31
 * @return true if a bridge is present
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    32
 */
3234
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    33
static inline bool IsBridgeTile(TileIndex t)
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    34
{
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    35
	return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    36
}
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
    37
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    38
/**
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    39
 * checks for the possibility that a bridge may be on this tile
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    40
 * These are in fact all the tile types on which a bridge can be found
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    41
 * @param t The tile to analyze
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    42
 * @return true if a bridge migh be present
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    43
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    44
static inline bool MayHaveBridgeAbove(TileIndex t)
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
    45
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    46
	return
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    47
		IsTileType(t, MP_CLEAR) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    48
		IsTileType(t, MP_RAILWAY) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    49
		IsTileType(t, MP_STREET) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    50
		IsTileType(t, MP_WATER) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    51
		IsTileType(t, MP_TUNNELBRIDGE) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    52
		IsTileType(t, MP_UNMOVABLE);
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    53
}
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    54
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    55
/**
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    56
 * checks if a bridge is set above the ground of this tile
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    57
 * @param t The tile to analyze
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    58
 * @pre MayHaveBridgeAbove(t)
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    59
 * @return true if a bridge is detected above
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    60
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    61
static inline bool IsBridgeAbove(TileIndex t)
3933
231ae3c419f4 (svn r5070) Merged the bridge branch
celestar
parents: 3466
diff changeset
    62
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    63
	assert(MayHaveBridgeAbove(t));
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5475
diff changeset
    64
	return GB(_m[t].m6, 6, 2) != 0;
3231
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    65
}
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    66
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    67
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    68
/**
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    69
 * Determines the type of bridge on a tile
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    70
 * @param t The tile to analyze
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    71
 * @pre IsBridgeTile(t)
3231
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    72
 * @return The bridge type
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    73
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    74
static inline uint GetBridgeType(TileIndex t)
3231
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    75
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    76
	assert(IsBridgeTile(t));
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    77
	return GB(_m[t].m2, 4, 4);
3231
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    78
}
b85d451b6bf8 (svn r3904) Move GetBridgePiece() and GetBridgeType() to bridge_map.h and make the only place which still extracted that info diretly use the wrapper
tron
parents: 3226
diff changeset
    79
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
    80
3196
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    81
/**
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    82
 * Get the direction pointing onto the bridge
6416
dc8d134b8c48 (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6160
diff changeset
    83
 * @param t The tile to analyze
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    84
 * @pre IsBridgeTile(t)
6123
04eb770ec17e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5596
diff changeset
    85
 * @return the above mentionned direction
3196
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    86
 */
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    87
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    88
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    89
	assert(IsBridgeTile(t));
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    90
	return (DiagDirection)GB(_m[t].m5, 0, 2);
3196
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    91
}
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    92
5cec26c5ab75 (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
    93
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    94
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    95
 * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    96
 * @param t The tile to analyze
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    97
 * @pre IsBridgeAbove(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    98
 * @return the above mentioned axis
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
    99
 */
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   100
static inline Axis GetBridgeAxis(TileIndex t)
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   101
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   102
	assert(IsBridgeAbove(t));
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5475
diff changeset
   103
	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   104
}
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   105
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   106
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   107
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   108
 * Get the transport type of the bridge's ramp.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   109
 * @param t The ramp tile to analyze
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   110
 * @pre IsBridgeTile(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   111
 * @return the transport type of the bridge
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   112
 */
3234
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
   113
static inline TransportType GetBridgeTransportType(TileIndex t)
a2791a480b71 (svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents: 3231
diff changeset
   114
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
   115
	assert(IsBridgeTile(t));
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   116
	return (TransportType)GB(_m[t].m5, 2, 2);
3977
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   117
}
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   118
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   119
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   120
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   121
 * Does the bridge ramp lie in a snow or desert area?
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   122
 * @param t The ramp tile to analyze
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   123
 * @pre IsBridgeTile(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   124
 * @return true if and only if in a snow or desert area
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   125
 */
5410
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   126
static inline bool HasBridgeSnowOrDesert(TileIndex t)
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   127
{
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   128
	assert(IsBridgeTile(t));
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   129
	return HASBIT(_m[t].m4, 7);
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   130
}
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   131
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   132
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   133
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   134
 * Sets whether the bridge ramp lies in a snow or desert area.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   135
 * @param t              The ramp tile to set (un)make a snow/desert area
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   136
 * @param snow_or_desert Make (true) or unmake the tile a snow/desert area
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   137
 * @pre IsBridgeTile(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   138
 */
5410
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   139
static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   140
{
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   141
	assert(IsBridgeTile(t));
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   142
	SB(_m[t].m4, 7, 1, snow_or_desert);
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   143
}
2dae82c6ea63 (svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents: 5385
diff changeset
   144
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   145
/**
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   146
 * Finds the end of a bridge in the specified direction starting at a middle tile
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   147
 * @param t the bridge tile to find the bridge ramp for
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   148
 * @param d the direction to search in
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   149
 */
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   150
TileIndex GetBridgeEnd(TileIndex t, DiagDirection d);
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   151
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   152
/**
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   153
 * Finds the northern end of a bridge starting at a middle tile
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   154
 * @param t the bridge tile to find the bridge ramp for
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   155
 */
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   156
TileIndex GetNorthernBridgeEnd(TileIndex t);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   157
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   158
/**
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   159
 * Finds the southern end of a bridge starting at a middle tile
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   160
 * @param t the bridge tile to find the bridge ramp for
3225
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   161
 */
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   162
TileIndex GetSouthernBridgeEnd(TileIndex t);
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   163
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   164
3a3e35bd39a6 (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   165
/**
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   166
 * Starting at one bridge end finds the other bridge end
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   167
 * @param t the bridge ramp tile to find the other bridge ramp for
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   168
 */
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   169
TileIndex GetOtherBridgeEnd(TileIndex t);
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   170
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   171
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   172
 * Get the height ('z') of a bridge in pixels.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   173
 * @param tile the bridge ramp tile to get the bridge height from
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   174
 * @return the height of the bridge in pixels
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   175
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   176
uint GetBridgeHeight(TileIndex tile);
3214
dd744119dfac (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   177
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   178
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   179
 * Remove the bridge over the given axis.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   180
 * @param t the tile to remove the bridge from
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   181
 * @param a the axis of the bridge to remove
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   182
 * @pre MayHaveBridgeAbove(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   183
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   184
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   185
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   186
	assert(MayHaveBridgeAbove(t));
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5475
diff changeset
   187
	CLRBIT(_m[t].m6, 6 + a);
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   188
}
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   189
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   190
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   191
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   192
 * Removes bridges from the given, that is bridges along the X and Y axis.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   193
 * @param t the tile to remove the bridge from
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   194
 * @pre MayHaveBridgeAbove(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   195
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   196
static inline void ClearBridgeMiddle(TileIndex t)
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   197
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   198
	ClearSingleBridgeMiddle(t, AXIS_X);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   199
	ClearSingleBridgeMiddle(t, AXIS_Y);
3977
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   200
}
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   201
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   202
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   203
 * Set that there is a bridge over the given axis.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   204
 * @param t the tile to add the bridge to
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   205
 * @param a the axis of the bridge to add
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   206
 * @pre MayHaveBridgeAbove(t)
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   207
 */
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   208
static inline void SetBridgeMiddle(TileIndex t, Axis a)
3977
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   209
{
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   210
	assert(MayHaveBridgeAbove(t));
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5475
diff changeset
   211
	SETBIT(_m[t].m6, 6 + a);
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   212
}
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   213
3209
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   214
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   215
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   216
 * Generic part to make a bridge ramp for both roads and rails.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   217
 * @param t          the tile to make a bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   218
 * @param o          the new owner of the bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   219
 * @param bridgetype the type of bridge this bridge ramp belongs to
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   220
 * @param d          the direction this ramp must be facing
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   221
 * @param tt         the transport type of the bridge
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   222
 * @note this function should not be called directly.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   223
 */
3209
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   224
static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, TransportType tt)
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   225
{
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   226
	SetTileType(t, MP_TUNNELBRIDGE);
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   227
	SetTileOwner(t, o);
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   228
	_m[t].m2 = bridgetype << 4;
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   229
	_m[t].m4 = 0;
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   230
	_m[t].m5 = 1 << 7 | tt << 2 | d;
3209
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   231
}
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   232
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   233
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   234
 * Make a bridge ramp for roads.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   235
 * @param t          the tile to make a bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   236
 * @param o          the new owner of the bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   237
 * @param bridgetype the type of bridge this bridge ramp belongs to
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   238
 * @param d          the direction this ramp must be facing
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   239
 */
3209
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   240
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d)
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   241
{
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   242
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD);
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   243
	_m[t].m3 = 0;
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   244
}
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   245
6418
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   246
/**
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   247
 * Make a bridge ramp for rails.
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   248
 * @param t          the tile to make a bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   249
 * @param o          the new owner of the bridge ramp
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   250
 * @param bridgetype the type of bridge this bridge ramp belongs to
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   251
 * @param d          the direction this ramp must be facing
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   252
 * @param r          the rail type of the bridge
e04693bbe82a (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6416
diff changeset
   253
 */
3209
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   254
static inline void MakeRailBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RailType r)
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   255
{
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   256
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL);
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   257
	_m[t].m3 = r;
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   258
}
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   259
98153d2f1ba7 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   260
4666
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4158
diff changeset
   261
#endif /* BRIDGE_MAP_H */