# HG changeset patch # User tron # Date 1154881969 0 # Node ID 2823b364386291717ef4ef37f74cd97d615d6e94 # Parent f4e93251e2f6907e97e7e4aa17c6bed5e403ceee (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo diff -r f4e93251e2f6 -r 2823b3643862 clear_cmd.c --- a/clear_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/clear_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -534,9 +534,12 @@ DrawClearLandFence(ti); } -static uint GetSlopeZ_Clear(const TileInfo* ti) +static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y) { - return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; + uint z; + uint tileh = GetTileSlope(tile, &z); + + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } static Slope GetSlopeTileh_Clear(TileIndex tile, Slope tileh) diff -r f4e93251e2f6 -r 2823b3643862 dummy_land.c --- a/dummy_land.c Sun Aug 06 08:23:19 2006 +0000 +++ b/dummy_land.c Sun Aug 06 16:32:49 2006 +0000 @@ -14,7 +14,7 @@ } -static uint GetSlopeZ_Dummy(const TileInfo* ti) +static uint GetSlopeZ_Dummy(TileIndex tile, uint x, uint y) { return 0; } diff -r f4e93251e2f6 -r 2823b3643862 industry_cmd.c --- a/industry_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/industry_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -267,9 +267,9 @@ } } -static uint GetSlopeZ_Industry(const TileInfo *ti) +static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y) { - return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT); + return GetTileMaxZ(tile); } static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh) diff -r f4e93251e2f6 -r 2823b3643862 landscape.c --- a/landscape.c Sun Aug 06 08:23:19 2006 +0000 +++ b/landscape.c Sun Aug 06 16:32:49 2006 +0000 @@ -174,11 +174,9 @@ uint GetSlopeZ(int x, int y) { - TileInfo ti; + TileIndex tile = TileVirtXY(x, y); - FindLandscapeHeight(&ti, x, y); - - return _tile_type_procs[ti.type]->get_slope_z_proc(&ti); + return _tile_type_procs[GetTileType(tile)]->get_slope_z_proc(tile, x, y); } diff -r f4e93251e2f6 -r 2823b3643862 openttd.h --- a/openttd.h Sun Aug 06 08:23:19 2006 +0000 +++ b/openttd.h Sun Aug 06 16:32:49 2006 +0000 @@ -298,7 +298,7 @@ typedef void DrawTileProc(TileInfo *ti); -typedef uint GetSlopeZProc(const TileInfo* ti); +typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y); typedef int32 ClearTileProc(TileIndex tile, byte flags); typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); typedef void GetTileDescProc(TileIndex tile, TileDesc *td); diff -r f4e93251e2f6 -r 2823b3643862 rail_cmd.c --- a/rail_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/rail_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -1692,20 +1692,20 @@ UpdateSignalsOnSegment(tile, _search_dir_2[track]); } -static uint GetSlopeZ_Track(const TileInfo* ti) +static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y) { - Slope tileh = ti->tileh; - uint z = ti->z; + uint z; + Slope tileh = GetTileSlope(tile, &z); if (tileh == SLOPE_FLAT) return z; - if (IsPlainRailTile(ti->tile)) { - uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); + if (IsPlainRailTile(tile)) { + uint f = GetRailFoundation(tileh, GetTrackBits(tile)); if (f != 0) { if (f < 15) return z + TILE_HEIGHT; // leveled foundation tileh = _inclined_tileh[f - 15]; // inclined foundation } - return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh); + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } else { return z + TILE_HEIGHT; } diff -r f4e93251e2f6 -r 2823b3643862 road_cmd.c --- a/road_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/road_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -833,20 +833,20 @@ } } -static uint GetSlopeZ_Road(const TileInfo* ti) +static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y) { - Slope tileh = ti->tileh; - uint z = ti->z; + uint z; + Slope tileh = GetTileSlope(tile, &z); if (tileh == SLOPE_FLAT) return z; - if (GetRoadTileType(ti->tile) == ROAD_TILE_NORMAL) { - uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile)); + if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + uint f = GetRoadFoundation(tileh, GetRoadBits(tile)); if (f != 0) { if (f < 15) return z + TILE_HEIGHT; // leveled foundation tileh = _inclined_tileh[f - 15]; // inclined foundation } - return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh); + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } else { return z + TILE_HEIGHT; } diff -r f4e93251e2f6 -r 2823b3643862 station_cmd.c --- a/station_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/station_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -2152,9 +2152,9 @@ } } -static uint GetSlopeZ_Station(const TileInfo* ti) +static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y) { - return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT); + return GetTileMaxZ(tile); } static Slope GetSlopeTileh_Station(TileIndex tile, Slope tileh) diff -r f4e93251e2f6 -r 2823b3643862 town_cmd.c --- a/town_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/town_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -110,9 +110,9 @@ } } -static uint GetSlopeZ_Town(const TileInfo* ti) +static uint GetSlopeZ_Town(TileIndex tile, uint x, uint y) { - return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT); + return GetTileMaxZ(tile); } static Slope GetSlopeTileh_Town(TileIndex tile, Slope tileh) diff -r f4e93251e2f6 -r 2823b3643862 tree_cmd.c --- a/tree_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/tree_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -323,9 +323,12 @@ } -static uint GetSlopeZ_Trees(const TileInfo* ti) +static uint GetSlopeZ_Trees(TileIndex tile, uint x, uint y) { - return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; + uint z; + uint tileh = GetTileSlope(tile, &z); + + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } static Slope GetSlopeTileh_Trees(TileIndex tile, Slope tileh) diff -r f4e93251e2f6 -r 2823b3643862 tunnelbridge_cmd.c --- a/tunnelbridge_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/tunnelbridge_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -1089,13 +1089,13 @@ } } -static uint GetSlopeZ_TunnelBridge(const TileInfo* ti) +static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) { - TileIndex tile = ti->tile; - uint z = ti->z; - uint x = ti->x & 0xF; - uint y = ti->y & 0xF; - Slope tileh = ti->tileh; + uint z; + Slope tileh = GetTileSlope(tile, &z); + + x &= 0xF; + y &= 0xF; if (IsTunnel(tile)) { uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x); diff -r f4e93251e2f6 -r 2823b3643862 unmovable_cmd.c --- a/unmovable_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/unmovable_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -176,12 +176,15 @@ } } -static uint GetSlopeZ_Unmovable(const TileInfo* ti) +static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y) { - if (IsOwnedLand(ti->tile)) { - return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh); + if (IsOwnedLand(tile)) { + uint z; + uint tileh = GetTileSlope(tile, &z); + + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } else { - return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT); + return GetTileMaxZ(tile); } } diff -r f4e93251e2f6 -r 2823b3643862 viewport.c --- a/viewport.c Sun Aug 06 08:23:19 2006 +0000 +++ b/viewport.c Sun Aug 06 16:32:49 2006 +0000 @@ -294,7 +294,6 @@ static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y) { - int z; Point pt; int a,b; @@ -314,16 +313,19 @@ a = x+y; b = x-y; #endif - z = GetSlopeZ(a, b) >> 1; - z = GetSlopeZ(a+z, b+z) >> 1; - z = GetSlopeZ(a+z, b+z) >> 1; - z = GetSlopeZ(a+z, b+z) >> 1; - z = GetSlopeZ(a+z, b+z) >> 1; - pt.x = a+z; - pt.y = b+z; + if ((uint)a < MapMaxX() * TILE_SIZE && (uint)b < MapMaxY() * TILE_SIZE) { + uint z; - if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) { + z = GetSlopeZ(a, b ) / 2; + z = GetSlopeZ(a + z, b + z) / 2; + z = GetSlopeZ(a + z, b + z) / 2; + z = GetSlopeZ(a + z, b + z) / 2; + z = GetSlopeZ(a + z, b + z) / 2; + + pt.x = a + z; + pt.y = b + z; + } else { pt.x = pt.y = -1; } diff -r f4e93251e2f6 -r 2823b3643862 water_cmd.c --- a/water_cmd.c Sun Aug 06 08:23:19 2006 +0000 +++ b/water_cmd.c Sun Aug 06 16:32:49 2006 +0000 @@ -479,9 +479,12 @@ } -static uint GetSlopeZ_Water(const TileInfo *ti) +static uint GetSlopeZ_Water(TileIndex tile, uint x, uint y) { - return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; + uint z; + uint tileh = GetTileSlope(tile, &z); + + return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh)