src/bridge_map.h
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 6878 7d1ff2f621c7
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
     3 /** @file bridge_map.h Map accessor functions for bridges. */
     3 /** @file bridge_map.h Map accessor functions for bridges. */
     4 
     4 
     5 #ifndef BRIDGE_MAP_H
     5 #ifndef BRIDGE_MAP_H
     6 #define BRIDGE_MAP_H
     6 #define BRIDGE_MAP_H
     7 
     7 
     8 #include "direction.h"
     8 #include "direction_func.h"
     9 #include "macros.h"
     9 #include "rail_type.h"
    10 #include "map.h"
       
    11 #include "rail.h"
       
    12 #include "road_map.h"
    10 #include "road_map.h"
    13 #include "tile.h"
       
    14 
    11 
    15 
    12 
    16 /**
    13 /**
    17  * Checks if this is a bridge, instead of a tunnel
    14  * Checks if this is a bridge, instead of a tunnel
    18  * @param t The tile to analyze
    15  * @param t The tile to analyze
    62 {
    59 {
    63 	assert(MayHaveBridgeAbove(t));
    60 	assert(MayHaveBridgeAbove(t));
    64 	return GB(_m[t].m6, 6, 2) != 0;
    61 	return GB(_m[t].m6, 6, 2) != 0;
    65 }
    62 }
    66 
    63 
    67 
       
    68 /**
    64 /**
    69  * Determines the type of bridge on a tile
    65  * Determines the type of bridge on a tile
    70  * @param t The tile to analyze
    66  * @param t The tile to analyze
    71  * @pre IsBridgeTile(t)
    67  * @pre IsBridgeTile(t)
    72  * @return The bridge type
    68  * @return The bridge type
    75 {
    71 {
    76 	assert(IsBridgeTile(t));
    72 	assert(IsBridgeTile(t));
    77 	return GB(_m[t].m2, 4, 4);
    73 	return GB(_m[t].m2, 4, 4);
    78 }
    74 }
    79 
    75 
    80 
       
    81 /**
       
    82  * Get the direction pointing onto the bridge
       
    83  * @param t The tile to analyze
       
    84  * @pre IsBridgeTile(t)
       
    85  * @return the above mentionned direction
       
    86  */
       
    87 static inline DiagDirection GetBridgeRampDirection(TileIndex t)
       
    88 {
       
    89 	assert(IsBridgeTile(t));
       
    90 	return (DiagDirection)GB(_m[t].m5, 0, 2);
       
    91 }
       
    92 
       
    93 
       
    94 /**
    76 /**
    95  * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
    77  * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
    96  * @param t The tile to analyze
    78  * @param t The tile to analyze
    97  * @pre IsBridgeAbove(t)
    79  * @pre IsBridgeAbove(t)
    98  * @return the above mentioned axis
    80  * @return the above mentioned axis
    99  */
    81  */
   100 static inline Axis GetBridgeAxis(TileIndex t)
    82 static inline Axis GetBridgeAxis(TileIndex t)
   101 {
    83 {
   102 	assert(IsBridgeAbove(t));
    84 	assert(IsBridgeAbove(t));
   103 	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
    85 	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
   104 }
       
   105 
       
   106 
       
   107 /**
       
   108  * Get the transport type of the bridge's ramp.
       
   109  * @param t The ramp tile to analyze
       
   110  * @pre IsBridgeTile(t)
       
   111  * @return the transport type of the bridge
       
   112  */
       
   113 static inline TransportType GetBridgeTransportType(TileIndex t)
       
   114 {
       
   115 	assert(IsBridgeTile(t));
       
   116 	return (TransportType)GB(_m[t].m5, 2, 2);
       
   117 }
       
   118 
       
   119 
       
   120 /**
       
   121  * Does the bridge ramp lie in a snow or desert area?
       
   122  * @param t The ramp tile to analyze
       
   123  * @pre IsBridgeTile(t)
       
   124  * @return true if and only if in a snow or desert area
       
   125  */
       
   126 static inline bool HasBridgeSnowOrDesert(TileIndex t)
       
   127 {
       
   128 	assert(IsBridgeTile(t));
       
   129 	return HasBit(_m[t].m4, 7);
       
   130 }
       
   131 
       
   132 
       
   133 /**
       
   134  * Sets whether the bridge ramp lies in a snow or desert area.
       
   135  * @param t              The ramp tile to set (un)make a snow/desert area
       
   136  * @param snow_or_desert Make (true) or unmake the tile a snow/desert area
       
   137  * @pre IsBridgeTile(t)
       
   138  */
       
   139 static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
       
   140 {
       
   141 	assert(IsBridgeTile(t));
       
   142 	SB(_m[t].m4, 7, 1, snow_or_desert);
       
   143 }
    86 }
   144 
    87 
   145 /**
    88 /**
   146  * Finds the end of a bridge in the specified direction starting at a middle tile
    89  * Finds the end of a bridge in the specified direction starting at a middle tile
   147  * @param t the bridge tile to find the bridge ramp for
    90  * @param t the bridge tile to find the bridge ramp for
   184 static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
   127 static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
   185 {
   128 {
   186 	assert(MayHaveBridgeAbove(t));
   129 	assert(MayHaveBridgeAbove(t));
   187 	ClrBit(_m[t].m6, 6 + a);
   130 	ClrBit(_m[t].m6, 6 + a);
   188 }
   131 }
   189 
       
   190 
   132 
   191 /**
   133 /**
   192  * Removes bridges from the given, that is bridges along the X and Y axis.
   134  * Removes bridges from the given, that is bridges along the X and Y axis.
   193  * @param t the tile to remove the bridge from
   135  * @param t the tile to remove the bridge from
   194  * @pre MayHaveBridgeAbove(t)
   136  * @pre MayHaveBridgeAbove(t)