src/bridge_map.h
author smatz
Sun, 16 Dec 2007 15:38:51 +0000
changeset 8579 3efbb430092e
parent 8427 143b0be22af1
child 8596 27646407e0bc
permissions -rw-r--r--
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     1
/* $Id$ */
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     2
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
     3
/** @file bridge_map.h Map accessor functions for bridges. */
6449
e520244dc71e (svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5847
diff changeset
     4
3189
1af302c5abd0 (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
1af302c5abd0 (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
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     7
3196
29717e930f9a (svn r3857) Add and use GetBridgeRampDirection()
tron
parents: 3189
diff changeset
     8
#include "direction.h"
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
     9
#include "macros.h"
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    10
#include "map.h"
1af302c5abd0 (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
986c30171e92 (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
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    13
#include "tile.h"
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    14
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
    15
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    16
/**
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    17
 * Checks if this is a bridge, instead of a tunnel
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    18
 * @param t The tile to analyze
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    19
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    20
 * @return true if the structure is a bridge one
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    21
 */
3234
986c30171e92 (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)
986c30171e92 (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
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    24
	assert(IsTileType(t, MP_TUNNELBRIDGE));
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7866
diff changeset
    25
	return HasBit(_m[t].m5, 7);
3234
986c30171e92 (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
}
986c30171e92 (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
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    28
/**
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    29
 * checks if there is a bridge on this tile
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    30
 * @param t The tile to analyze
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    31
 * @return true if a bridge is present
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    32
 */
3234
986c30171e92 (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)
986c30171e92 (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
{
986c30171e92 (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);
986c30171e92 (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
}
986c30171e92 (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
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    38
/**
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    39
 * checks for the possibility that a bridge may be on this tile
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    40
 * These are in fact all the tile types on which a bridge can be found
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    41
 * @param t The tile to analyze
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    42
 * @return true if a bridge migh be present
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    43
 */
5573
afa6f92a71fd (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
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
    45
{
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    46
	return
afa6f92a71fd (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) ||
afa6f92a71fd (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) ||
7866
e19fda04e8d3 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents: 7157
diff changeset
    49
		IsTileType(t, MP_ROAD) ||
5573
afa6f92a71fd (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) ||
afa6f92a71fd (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) ||
afa6f92a71fd (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
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    53
}
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    54
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    55
/**
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    56
 * checks if a bridge is set above the ground of this tile
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    57
 * @param t The tile to analyze
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    58
 * @pre MayHaveBridgeAbove(t)
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    59
 * @return true if a bridge is detected above
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    60
 */
5573
afa6f92a71fd (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
a5f08e17f4a0 (svn r5070) Merged the bridge branch
celestar
parents: 3466
diff changeset
    62
{
5573
afa6f92a71fd (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));
5847
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5726
diff changeset
    64
	return GB(_m[t].m6, 6, 2) != 0;
3231
eb74c2e361f9 (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
}
eb74c2e361f9 (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
eb74c2e361f9 (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
/**
eb74c2e361f9 (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
 * Determines the type of bridge on a tile
6912
f1dafa4911fb (svn r9552) -Documentation: Some more doxygen work, adding comments too
belugas
parents: 6486
diff changeset
    69
 * @param t The tile to analyze
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    70
 * @pre IsBridgeTile(t)
3231
eb74c2e361f9 (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
    71
 * @return The bridge type
eb74c2e361f9 (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
 */
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    73
static inline uint GetBridgeType(TileIndex t)
3231
eb74c2e361f9 (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
    74
{
3369
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    75
	assert(IsBridgeTile(t));
00c2ca209a89 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3355
diff changeset
    76
	return GB(_m[t].m2, 4, 4);
3231
eb74c2e361f9 (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
    77
}
eb74c2e361f9 (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
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    79
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    80
 * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    81
 * @param t The tile to analyze
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    82
 * @pre IsBridgeAbove(t)
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    83
 * @return the above mentioned axis
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    84
 */
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    85
static inline Axis GetBridgeAxis(TileIndex t)
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    86
{
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    87
	assert(IsBridgeAbove(t));
5847
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5726
diff changeset
    88
	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    89
}
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    90
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
    91
/**
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    92
 * Finds the end of a bridge in the specified direction starting at a middle tile
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    93
 * @param t the bridge tile to find the bridge ramp for
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    94
 * @param d the direction to search in
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    95
 */
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
    96
TileIndex GetBridgeEnd(TileIndex t, DiagDirection d);
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    97
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
    98
/**
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
    99
 * Finds the northern end of a bridge starting at a middle tile
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   100
 * @param t the bridge tile to find the bridge ramp for
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   101
 */
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   102
TileIndex GetNorthernBridgeEnd(TileIndex t);
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   103
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   104
/**
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   105
 * Finds the southern end of a bridge starting at a middle tile
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   106
 * @param t the bridge tile to find the bridge ramp for
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   107
 */
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   108
TileIndex GetSouthernBridgeEnd(TileIndex t);
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   109
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   110
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3216
diff changeset
   111
/**
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   112
 * Starting at one bridge end finds the other bridge end
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   113
 * @param t the bridge ramp tile to find the other bridge ramp for
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   114
 */
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   115
TileIndex GetOtherBridgeEnd(TileIndex t);
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   116
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   117
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   118
 * Get the height ('z') of a bridge in pixels.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   119
 * @param tile the bridge ramp tile to get the bridge height from
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   120
 * @return the height of the bridge in pixels
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   121
 */
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   122
uint GetBridgeHeight(TileIndex tile);
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents: 3209
diff changeset
   123
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   124
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   125
 * Remove the bridge over the given axis.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   126
 * @param t the tile to remove the bridge from
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   127
 * @param a the axis of the bridge to remove
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   128
 * @pre MayHaveBridgeAbove(t)
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   129
 */
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   130
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   131
{
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   132
	assert(MayHaveBridgeAbove(t));
8425
72a71d480c5f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
   133
	ClrBit(_m[t].m6, 6 + a);
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   134
}
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   135
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   136
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   137
 * Removes bridges from the given, that is bridges along the X and Y axis.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   138
 * @param t the tile to remove the bridge from
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   139
 * @pre MayHaveBridgeAbove(t)
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   140
 */
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   141
static inline void ClearBridgeMiddle(TileIndex t)
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   142
{
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   143
	ClearSingleBridgeMiddle(t, AXIS_X);
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   144
	ClearSingleBridgeMiddle(t, AXIS_Y);
3977
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   145
}
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   146
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   147
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   148
 * Set that there is a bridge over the given axis.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   149
 * @param t the tile to add the bridge to
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   150
 * @param a the axis of the bridge to add
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   151
 * @pre MayHaveBridgeAbove(t)
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   152
 */
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   153
static inline void SetBridgeMiddle(TileIndex t, Axis a)
3977
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3953
diff changeset
   154
{
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   155
	assert(MayHaveBridgeAbove(t));
8427
143b0be22af1 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 8425
diff changeset
   156
	SetBit(_m[t].m6, 6 + a);
3189
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   157
}
1af302c5abd0 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
diff changeset
   158
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   159
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   160
 * Generic part to make a bridge ramp for both roads and rails.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   161
 * @param t          the tile to make a bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   162
 * @param o          the new owner of the bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   163
 * @param bridgetype the type of bridge this bridge ramp belongs to
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   164
 * @param d          the direction this ramp must be facing
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   165
 * @param tt         the transport type of the bridge
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   166
 * @param rt         the road or rail type
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   167
 * @note this function should not be called directly.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   168
 */
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   169
static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, TransportType tt, uint rt)
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   170
{
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   171
	SetTileType(t, MP_TUNNELBRIDGE);
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   172
	SetTileOwner(t, o);
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   173
	_m[t].m2 = bridgetype << 4;
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   174
	_m[t].m3 = rt;
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   175
	_m[t].m4 = 0;
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4666
diff changeset
   176
	_m[t].m5 = 1 << 7 | tt << 2 | d;
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   177
}
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   178
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   179
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   180
 * Make a bridge ramp for roads.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   181
 * @param t          the tile to make a bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   182
 * @param o          the new owner of the bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   183
 * @param bridgetype the type of bridge this bridge ramp belongs to
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   184
 * @param d          the direction this ramp must be facing
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   185
 * @param r          the road type of the bridge
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   186
 */
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   187
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RoadTypes r)
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   188
{
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   189
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, r);
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   190
}
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   191
6914
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   192
/**
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   193
 * Make a bridge ramp for rails.
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   194
 * @param t          the tile to make a bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   195
 * @param o          the new owner of the bridge ramp
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   196
 * @param bridgetype the type of bridge this bridge ramp belongs to
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   197
 * @param d          the direction this ramp must be facing
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   198
 * @param r          the rail type of the bridge
3ba37b6fa39b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents: 6912
diff changeset
   199
 */
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   200
static inline void MakeRailBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, RailType r)
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   201
{
7157
270bc5b64e08 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents: 6914
diff changeset
   202
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r);
3209
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   203
}
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   204
e0b7d48351a3 (svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents: 3196
diff changeset
   205
4666
850b5b6e4bac (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4158
diff changeset
   206
#endif /* BRIDGE_MAP_H */