# HG changeset patch # User tron # Date 1106830340 0 # Node ID cd9b8a18a18365adeefbd62577913d049184fb32 # Parent b680ace4455e1366c209ce542a8df42d779625b4 (svn r1696) Use GetTileSlope() instead of FindLandscapeHeightByTile() where it is sufficient. FindLandscapeHeightByTile() uses GetTileSlope() internally and adds some more info, which is discarded in these cases. While touching the code make a bit more clear how GetBridgeHeight() works. diff -r b680ace4455e -r cd9b8a18a183 train_cmd.c --- a/train_cmd.c Thu Jan 27 11:33:14 2005 +0000 +++ b/train_cmd.c Thu Jan 27 12:52:20 2005 +0000 @@ -2049,13 +2049,13 @@ case MP_TUNNELBRIDGE: if ((_map5[tile] & 0xC0) == 0xC0) { // is bridge middle part? - TileInfo ti; - FindLandscapeHeightByTile(&ti, tile); + uint height; + uint tileh = GetTileSlope(tile, &height); // correct Z position of a train going under a bridge on slopes - if (CORRECT_Z(ti.tileh)) ti.z += 8; - - if (v->z_pos != ti.z) return true; // train is going over bridge + if (CORRECT_Z(tileh)) height += 8; + + if (v->z_pos != height) return true; // train is going over bridge } break; diff -r b680ace4455e -r cd9b8a18a183 tunnelbridge_cmd.c --- a/tunnelbridge_cmd.c Thu Jan 27 11:33:14 2005 +0000 +++ b/tunnelbridge_cmd.c Thu Jan 27 12:52:20 2005 +0000 @@ -905,9 +905,7 @@ static uint GetBridgeHeight(const TileInfo *ti) { uint delta; - TileInfo ti_end; - uint tile = ti->tile; - uint z_correction = 0; + TileIndex tile = ti->tile; // find the end tile of the bridge. delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0); @@ -916,14 +914,10 @@ tile += delta; } while (_map5[tile] & 0x40); // while bridge middle parts - // if the end of the bridge is on a tileh 7, the z coordinate is 1 tile too low - // correct it. - FindLandscapeHeightByTile(&ti_end, tile); - if (HASBIT(1 << 7, ti_end.tileh)) - z_correction += 8; - - // return the height there (the height of the NORTH CORNER) - return TilePixelHeight(tile) + z_correction; + /* Return the height there (the height of the NORTH CORNER) + * If the end of the bridge is on a tileh 7 (all raised, except north corner), + * the z coordinate is 1 height level too low. Compensate for that */ + return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == 7 ? 8 : 0); } static const byte _bridge_foundations[2][16] = { diff -r b680ace4455e -r cd9b8a18a183 vehicle.c --- a/vehicle.c Thu Jan 27 11:33:14 2005 +0000 +++ b/vehicle.c Thu Jan 27 12:52:20 2005 +0000 @@ -82,10 +82,7 @@ uint GetCorrectTileHeight(TileIndex tile) { - TileInfo ti; - - FindLandscapeHeightByTile(&ti, tile); - return Correct_Z(ti.tileh); + return Correct_Z(GetTileSlope(tile, NULL)); } bool EnsureNoVehicleZ(TileIndex tile, byte z)