src/road_map.h
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 6878 7d1ff2f621c7
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
     3 /** @file road_map.h */
     3 /** @file road_map.h */
     4 
     4 
     5 #ifndef ROAD_MAP_H
     5 #ifndef ROAD_MAP_H
     6 #define ROAD_MAP_H
     6 #define ROAD_MAP_H
     7 
     7 
     8 #include "macros.h"
     8 #include "track_func.h"
     9 #include "rail.h"
     9 #include "rail_type.h"
    10 #include "road.h"
    10 #include "town_type.h"
    11 #include "tile.h"
    11 #include "road_func.h"
       
    12 #include "tile_map.h"
    12 
    13 
    13 
    14 
    14 enum RoadTileType {
    15 enum RoadTileType {
    15 	ROAD_TILE_NORMAL,
    16 	ROAD_TILE_NORMAL,
    16 	ROAD_TILE_CROSSING,
    17 	ROAD_TILE_CROSSING,
   188 static inline TrackBits GetCrossingRailBits(TileIndex tile)
   189 static inline TrackBits GetCrossingRailBits(TileIndex tile)
   189 {
   190 {
   190 	return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile)));
   191 	return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile)));
   191 }
   192 }
   192 
   193 
   193 
       
   194 static inline void UnbarCrossing(TileIndex t)
       
   195 {
       
   196 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
       
   197 	ClrBit(_m[t].m4, 5);
       
   198 }
       
   199 
       
   200 static inline void BarCrossing(TileIndex t)
       
   201 {
       
   202 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
       
   203 	SetBit(_m[t].m4, 5);
       
   204 }
       
   205 
       
   206 static inline bool IsCrossingBarred(TileIndex t)
   194 static inline bool IsCrossingBarred(TileIndex t)
   207 {
   195 {
   208 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
   196 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
   209 	return HasBit(_m[t].m4, 5);
   197 	return HasBit(_m[t].m4, 5);
       
   198 }
       
   199 
       
   200 static inline void SetCrossingBarred(TileIndex t, bool barred)
       
   201 {
       
   202 	assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
       
   203 	SB(_m[t].m4, 5, 1, barred);
       
   204 }
       
   205 
       
   206 static inline void UnbarCrossing(TileIndex t)
       
   207 {
       
   208 	SetCrossingBarred(t, false);
       
   209 }
       
   210 
       
   211 static inline void BarCrossing(TileIndex t)
       
   212 {
       
   213 	SetCrossingBarred(t, true);
   210 }
   214 }
   211 
   215 
   212 #define IsOnDesert IsOnSnow
   216 #define IsOnDesert IsOnSnow
   213 static inline bool IsOnSnow(TileIndex t)
   217 static inline bool IsOnSnow(TileIndex t)
   214 {
   218 {
   302  * @param tile the tile to get the track bits for
   306  * @param tile the tile to get the track bits for
   303  * @return the track bits for the given tile
   307  * @return the track bits for the given tile
   304  */
   308  */
   305 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt);
   309 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt);
   306 
   310 
       
   311 /**
       
   312  * Return if the tile is a valid tile for a crossing.
       
   313  *
       
   314  * @note function is overloaded
       
   315  * @param tile the curent tile
       
   316  * @param ax the axis of the road over the rail
       
   317  * @return true if it is a valid tile
       
   318  */
       
   319 bool IsPossibleCrossing(const TileIndex tile, Axis ax);
       
   320 
   307 
   321 
   308 static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, Owner hway)
   322 static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, Owner hway)
   309 {
   323 {
   310 	SetTileType(t, MP_ROAD);
   324 	SetTileType(t, MP_ROAD);
   311 	SetTileOwner(t, road);
   325 	SetTileOwner(t, road);