src/road.h
branchnoai
changeset 9704 197cb8c6ae17
parent 9703 d2a6acdbd665
child 8424 4a488a90ccab
equal deleted inserted replaced
9703:d2a6acdbd665 9704:197cb8c6ae17
   114 {
   114 {
   115 	return (RoadBits)(ROAD_ALL ^ r);
   115 	return (RoadBits)(ROAD_ALL ^ r);
   116 }
   116 }
   117 
   117 
   118 /**
   118 /**
       
   119  * Calculate the mirrored RoadBits
       
   120  *
       
   121  * Simply move the bits to their new position.
       
   122  *
       
   123  * @param r The given RoadBits value
       
   124  * @return the mirrored
       
   125  */
       
   126 static inline RoadBits MirrorRoadBits(RoadBits r)
       
   127 {
       
   128 	return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
       
   129 }
       
   130 
       
   131 /**
       
   132  * Calculate rotated RoadBits
       
   133  *
       
   134  * Move the Roadbits clockwise til they are in their final position.
       
   135  *
       
   136  * @param r The given RoadBits value
       
   137  * @param rot The given Rotation angle
       
   138  * @return the rotated
       
   139  */
       
   140 static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
       
   141 {
       
   142 	for (; rot > (DiagDirDiff)0; rot--){
       
   143 		r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
       
   144 	}
       
   145 	return r;
       
   146 }
       
   147 
       
   148 /**
   119  * Create the road-part which belongs to the given DiagDirection
   149  * Create the road-part which belongs to the given DiagDirection
   120  *
   150  *
   121  * This function returns a RoadBits value which belongs to
   151  * This function returns a RoadBits value which belongs to
   122  * the given DiagDirection.
   152  * the given DiagDirection.
   123  *
   153  *
   126  */
   156  */
   127 static inline RoadBits DiagDirToRoadBits(DiagDirection d)
   157 static inline RoadBits DiagDirToRoadBits(DiagDirection d)
   128 {
   158 {
   129 	return (RoadBits)(ROAD_NW << (3 ^ d));
   159 	return (RoadBits)(ROAD_NW << (3 ^ d));
   130 }
   160 }
       
   161 
       
   162 /**
       
   163  * Return if the tile is a valid tile for a crossing.
       
   164  *
       
   165  * @note function is overloaded
       
   166  * @param tile the curent tile
       
   167  * @param ax the axis of the road over the rail
       
   168  * @return true if it is a valid tile
       
   169  */
       
   170 bool IsPossibleCrossing(const TileIndex tile, Axis ax);
   131 
   171 
   132 /**
   172 /**
   133  * Checks whether the trackdir means that we are reversing.
   173  * Checks whether the trackdir means that we are reversing.
   134  * @param dir the trackdir to check
   174  * @param dir the trackdir to check
   135  * @return true if it is a reversing road trackdir
   175  * @return true if it is a reversing road trackdir
   146  */
   186  */
   147 static inline bool IsStraightRoadTrackdir(Trackdir dir)
   187 static inline bool IsStraightRoadTrackdir(Trackdir dir)
   148 {
   188 {
   149 	return (dir & 0x06) == 0;
   189 	return (dir & 0x06) == 0;
   150 }
   190 }
       
   191 
       
   192 /**
       
   193  * Clean up unneccesary RoadBits of a planed tile.
       
   194  * @param tile current tile
       
   195  * @param org_rb planed RoadBits
       
   196  * @return optimised RoadBits
       
   197  */
       
   198 RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb);
   151 
   199 
   152 /**
   200 /**
   153  * Is it allowed to remove the given road bits from the given tile?
   201  * Is it allowed to remove the given road bits from the given tile?
   154  * @param tile      the tile to remove the road from
   202  * @param tile      the tile to remove the road from
   155  * @param remove    the roadbits that are going to be removed
   203  * @param remove    the roadbits that are going to be removed