(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
This commit is contained in:
		
							
								
								
									
										34
									
								
								rail_cmd.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								rail_cmd.c
									
									
									
									
									
								
							| @@ -1753,49 +1753,35 @@ void SetSignalsOnBothDir(TileIndex tile, byte track) | |||||||
|  |  | ||||||
| static uint GetSlopeZ_Track(const TileInfo* ti) | static uint GetSlopeZ_Track(const TileInfo* ti) | ||||||
| { | { | ||||||
|  | 	uint tileh = ti->tileh; | ||||||
| 	uint z = ti->z; | 	uint z = ti->z; | ||||||
| 	int th = ti->tileh; |  | ||||||
|  |  | ||||||
| 	// check if it's a foundation | 	if (tileh == 0) return z; | ||||||
| 	if (ti->tileh != 0) { |  | ||||||
| 	if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) { | 	if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) { | ||||||
| 		return z + 8; | 		return z + 8; | ||||||
| 	} else { | 	} else { | ||||||
| 		uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); | 		uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); | ||||||
|  |  | ||||||
| 		if (f != 0) { | 		if (f != 0) { | ||||||
| 				if (f < 15) { | 			if (f < 15) return z + 8; // leveled foundation | ||||||
| 					// leveled foundation | 			tileh = _inclined_tileh[f - 15]; // inclined foundation | ||||||
| 					return z + 8; |  | ||||||
| 		} | 		} | ||||||
| 				// inclined foundation | 		return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh); | ||||||
| 				th = _inclined_tileh[f - 15]; |  | ||||||
| 	} | 	} | ||||||
| 		} |  | ||||||
| 		return GetPartialZ(ti->x & 0xF, ti->y & 0xF, th) + z; |  | ||||||
| 	} |  | ||||||
| 	return z; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static uint GetSlopeTileh_Track(const TileInfo *ti) | static uint GetSlopeTileh_Track(const TileInfo *ti) | ||||||
| { | { | ||||||
| 	// check if it's a foundation | 	if (ti->tileh == 0) return ti->tileh; | ||||||
| 	if (ti->tileh != 0) { |  | ||||||
| 	if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) { | 	if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) { | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} else { | 	} else { | ||||||
| 		uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); | 		uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); | ||||||
| 			if (f != 0) { |  | ||||||
| 				if (f < 15) { | 		if (f == 0) return ti->tileh; | ||||||
| 					// leveled foundation | 		if (f < 15) return 0; // leveled foundation | ||||||
| 					return 0; | 		return _inclined_tileh[f - 15]; // inclined foundation | ||||||
| 	} | 	} | ||||||
| 				// inclined foundation |  | ||||||
| 				return _inclined_tileh[f - 15]; |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return ti->tileh; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) | static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) | ||||||
|   | |||||||
							
								
								
									
										61
									
								
								road_cmd.c
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								road_cmd.c
									
									
									
									
									
								
							| @@ -846,66 +846,35 @@ void DrawRoadDepotSprite(int x, int y, int image) | |||||||
|  |  | ||||||
| static uint GetSlopeZ_Road(const TileInfo* ti) | static uint GetSlopeZ_Road(const TileInfo* ti) | ||||||
| { | { | ||||||
|  | 	uint tileh = ti->tileh; | ||||||
| 	uint z = ti->z; | 	uint z = ti->z; | ||||||
| 	int th = ti->tileh; |  | ||||||
|  |  | ||||||
| 	// check if it's a foundation | 	if (tileh == 0) return z; | ||||||
| 	if (ti->tileh != 0) { | 	if (GetRoadType(ti->tile) == ROAD_NORMAL) { | ||||||
| 		switch (GetRoadType(ti->tile)) { | 		uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile)); | ||||||
| 			case ROAD_NORMAL: { |  | ||||||
| 				uint f = GetRoadFoundation(ti->tileh, GetRoadBits(ti->tile)); |  | ||||||
|  |  | ||||||
| 		if (f != 0) { | 		if (f != 0) { | ||||||
| 					if (f < 15) { | 			if (f < 15) return z + 8; // leveled foundation | ||||||
| 						// leveled foundation | 			tileh = _inclined_tileh[f - 15]; // inclined foundation | ||||||
|  | 		} | ||||||
|  | 		return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh); | ||||||
|  | 	} else { | ||||||
| 		return z + 8; | 		return z + 8; | ||||||
| 	} | 	} | ||||||
| 					// inclined foundation |  | ||||||
| 					th = _inclined_tileh[f - 15]; |  | ||||||
| 				} |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			// if these are on a slope then there's a level foundation |  | ||||||
| 			case ROAD_DEPOT: |  | ||||||
| 			case ROAD_CROSSING: |  | ||||||
| 				return z + 8; |  | ||||||
|  |  | ||||||
| 			default: break; |  | ||||||
| 		} |  | ||||||
| 		return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z; |  | ||||||
| 	} |  | ||||||
| 	return z; // normal Z if no slope |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static uint GetSlopeTileh_Road(const TileInfo *ti) | static uint GetSlopeTileh_Road(const TileInfo *ti) | ||||||
| { | { | ||||||
| 	// check if it's a foundation | 	if (ti->tileh == 0) return ti->tileh; | ||||||
| 	if (ti->tileh != 0) { | 	if (GetRoadType(ti->tile) == ROAD_NORMAL) { | ||||||
| 		switch (GetRoadType(ti->tile)) { |  | ||||||
| 			case ROAD_NORMAL: { |  | ||||||
| 		uint f = GetRoadFoundation(ti->tileh, GetRoadBits(ti->tile)); | 		uint f = GetRoadFoundation(ti->tileh, GetRoadBits(ti->tile)); | ||||||
|  |  | ||||||
| 				if (f != 0) { | 		if (f == 0) return ti->tileh; | ||||||
| 					if (f < 15) { | 		if (f < 15) return 0; // leveled foundation | ||||||
| 						// leveled foundation | 		return _inclined_tileh[f - 15]; // inclined foundation | ||||||
|  | 	} else { | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
| 					// inclined foundation |  | ||||||
| 					return _inclined_tileh[f - 15]; |  | ||||||
| 				} |  | ||||||
| 				break; |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			// if these are on a slope then there's a level foundation |  | ||||||
| 			case ROAD_CROSSING: |  | ||||||
| 			case ROAD_DEPOT: |  | ||||||
| 				return 0; |  | ||||||
|  |  | ||||||
| 			default: break; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return ti->tileh; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) | static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 tron
					tron