mirror of https://github.com/OpenTTD/OpenTTD.git
(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.
This commit is contained in:
parent
6eec07257a
commit
63653bd6af
|
@ -2049,13 +2049,13 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
|
||||||
|
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
if ((_map5[tile] & 0xC0) == 0xC0) { // is bridge middle part?
|
if ((_map5[tile] & 0xC0) == 0xC0) { // is bridge middle part?
|
||||||
TileInfo ti;
|
uint height;
|
||||||
FindLandscapeHeightByTile(&ti, tile);
|
uint tileh = GetTileSlope(tile, &height);
|
||||||
|
|
||||||
// correct Z position of a train going under a bridge on slopes
|
// correct Z position of a train going under a bridge on slopes
|
||||||
if (CORRECT_Z(ti.tileh)) ti.z += 8;
|
if (CORRECT_Z(tileh)) height += 8;
|
||||||
|
|
||||||
if (v->z_pos != ti.z) return true; // train is going over bridge
|
if (v->z_pos != height) return true; // train is going over bridge
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -905,9 +905,7 @@ int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
|
||||||
static uint GetBridgeHeight(const TileInfo *ti)
|
static uint GetBridgeHeight(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
uint delta;
|
uint delta;
|
||||||
TileInfo ti_end;
|
TileIndex tile = ti->tile;
|
||||||
uint tile = ti->tile;
|
|
||||||
uint z_correction = 0;
|
|
||||||
|
|
||||||
// find the end tile of the bridge.
|
// find the end tile of the bridge.
|
||||||
delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0);
|
delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0);
|
||||||
|
@ -916,14 +914,10 @@ static uint GetBridgeHeight(const TileInfo *ti)
|
||||||
tile += delta;
|
tile += delta;
|
||||||
} while (_map5[tile] & 0x40); // while bridge middle parts
|
} 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
|
/* Return the height there (the height of the NORTH CORNER)
|
||||||
// correct it.
|
* If the end of the bridge is on a tileh 7 (all raised, except north corner),
|
||||||
FindLandscapeHeightByTile(&ti_end, tile);
|
* the z coordinate is 1 height level too low. Compensate for that */
|
||||||
if (HASBIT(1 << 7, ti_end.tileh))
|
return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == 7 ? 8 : 0);
|
||||||
z_correction += 8;
|
|
||||||
|
|
||||||
// return the height there (the height of the NORTH CORNER)
|
|
||||||
return TilePixelHeight(tile) + z_correction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte _bridge_foundations[2][16] = {
|
static const byte _bridge_foundations[2][16] = {
|
||||||
|
|
|
@ -82,10 +82,7 @@ static inline uint Correct_Z(uint tileh)
|
||||||
|
|
||||||
uint GetCorrectTileHeight(TileIndex tile)
|
uint GetCorrectTileHeight(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileInfo ti;
|
return Correct_Z(GetTileSlope(tile, NULL));
|
||||||
|
|
||||||
FindLandscapeHeightByTile(&ti, tile);
|
|
||||||
return Correct_Z(ti.tileh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnsureNoVehicleZ(TileIndex tile, byte z)
|
bool EnsureNoVehicleZ(TileIndex tile, byte z)
|
||||||
|
|
Loading…
Reference in New Issue