From 892a4c587dfd1427fcebf3081520524a2c822ae6 Mon Sep 17 00:00:00 2001 From: tron Date: Sun, 2 Apr 2006 12:49:18 +0000 Subject: [PATCH] (svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo --- clear_cmd.c | 4 ++-- dummy_land.c | 2 +- industry_cmd.c | 2 +- landscape.c | 13 +++++-------- openttd.h | 2 +- rail_cmd.c | 10 +++++----- road_cmd.c | 10 +++++----- station_cmd.c | 2 +- town_cmd.c | 2 +- tree_cmd.c | 4 ++-- tunnelbridge_cmd.c | 2 +- unmovable_cmd.c | 4 ++-- water_cmd.c | 4 ++-- 13 files changed, 29 insertions(+), 32 deletions(-) diff --git a/clear_cmd.c b/clear_cmd.c index aea1441278..d859a9823b 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -518,9 +518,9 @@ static uint GetSlopeZ_Clear(const TileInfo* ti) return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; } -static uint GetSlopeTileh_Clear(const TileInfo *ti) +static uint GetSlopeTileh_Clear(TileIndex tile, uint tileh) { - return ti->tileh; + return tileh; } static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac) diff --git a/dummy_land.c b/dummy_land.c index 9cc7ec590d..b852ddcdf5 100644 --- a/dummy_land.c +++ b/dummy_land.c @@ -19,7 +19,7 @@ static uint GetSlopeZ_Dummy(const TileInfo* ti) return 0; } -static uint GetSlopeTileh_Dummy(const TileInfo* ti) +static uint GetSlopeTileh_Dummy(TileIndex tile, uint tileh) { return 0; } diff --git a/industry_cmd.c b/industry_cmd.c index 66b6f23349..407fcb0cb0 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -404,7 +404,7 @@ static uint GetSlopeZ_Industry(const TileInfo* ti) return ti->z + (ti->tileh == 0 ? 0 : 8); } -static uint GetSlopeTileh_Industry(const TileInfo* ti) +static uint GetSlopeTileh_Industry(TileIndex tile, uint tileh) { return 0; } diff --git a/landscape.c b/landscape.c index 033ef3205c..ad684160a0 100644 --- a/landscape.c +++ b/landscape.c @@ -183,11 +183,11 @@ uint GetSlopeZ(int x, int y) // direction=true: check for foundation in east and south corner // direction=false: check for foundation in west and south corner -static bool hasFoundation(const TileInfo* ti, bool direction) +static bool HasFoundation(TileIndex tile, bool direction) { bool south, other; // southern corner and east/west corner - uint slope = _tile_type_procs[ti->type]->get_slope_tileh_proc(ti); - uint tileh = ti->tileh; + uint tileh = GetTileSlope(tile, NULL); + uint slope = _tile_type_procs[GetTileType(tile)]->get_slope_tileh_proc(tile, tileh); if (slope == 0 && slope != tileh) tileh = 15; south = (tileh & 2) != (slope & 2); @@ -204,11 +204,8 @@ void DrawFoundation(TileInfo *ti, uint f) { uint32 sprite_base = SPR_SLOPES_BASE-14; - TileInfo ti2; - FindLandscapeHeight(&ti2, ti->x, ti->y - 1); - if (hasFoundation(&ti2, true)) sprite_base += 22; // foundation in NW direction - FindLandscapeHeight(&ti2, ti->x - 1, ti->y); - if (hasFoundation(&ti2, false)) sprite_base += 22 * 2; // foundation in NE direction + if (HasFoundation(TILE_ADDXY(ti->tile, 0, -1), true)) sprite_base += 22; // foundation in NW direction + if (HasFoundation(TILE_ADDXY(ti->tile, -1, 0), false)) sprite_base += 44; // foundation in NE direction if (f < 15) { // leveled foundation diff --git a/openttd.h b/openttd.h index 2ca959c4d4..d0db98e816 100644 --- a/openttd.h +++ b/openttd.h @@ -333,7 +333,7 @@ typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID n * other bits that can be set? */ typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y); typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y); -typedef uint GetSlopeTilehProc(const TileInfo *ti); +typedef uint GetSlopeTilehProc(TileIndex, uint tileh); typedef struct { DrawTileProc *draw_tile_proc; diff --git a/rail_cmd.c b/rail_cmd.c index 1f61b7e6f7..092ed6f77c 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1770,15 +1770,15 @@ static uint GetSlopeZ_Track(const TileInfo* ti) } } -static uint GetSlopeTileh_Track(const TileInfo *ti) +static uint GetSlopeTileh_Track(TileIndex tile, uint tileh) { - if (ti->tileh == 0) return ti->tileh; - if (GetRailTileType(ti->tile) == RAIL_TYPE_DEPOT_WAYPOINT) { + if (tileh == 0) return 0; + if (GetRailTileType(tile) == RAIL_TYPE_DEPOT_WAYPOINT) { return 0; } else { - uint f = GetRailFoundation(ti->tileh, GetTrackBits(ti->tile)); + uint f = GetRailFoundation(tileh, GetTrackBits(tile)); - if (f == 0) return ti->tileh; + if (f == 0) return tileh; if (f < 15) return 0; // leveled foundation return _inclined_tileh[f - 15]; // inclined foundation } diff --git a/road_cmd.c b/road_cmd.c index 5e961254a2..7edc503f7e 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -863,13 +863,13 @@ static uint GetSlopeZ_Road(const TileInfo* ti) } } -static uint GetSlopeTileh_Road(const TileInfo *ti) +static uint GetSlopeTileh_Road(TileIndex tile, uint tileh) { - if (ti->tileh == 0) return ti->tileh; - if (GetRoadType(ti->tile) == ROAD_NORMAL) { - uint f = GetRoadFoundation(ti->tileh, GetRoadBits(ti->tile)); + if (tileh == 0) return 0; + if (GetRoadType(tile) == ROAD_NORMAL) { + uint f = GetRoadFoundation(tileh, GetRoadBits(tile)); - if (f == 0) return ti->tileh; + if (f == 0) return tileh; if (f < 15) return 0; // leveled foundation return _inclined_tileh[f - 15]; // inclined foundation } else { diff --git a/station_cmd.c b/station_cmd.c index d5b5afea0a..06772f9e40 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1999,7 +1999,7 @@ static uint GetSlopeZ_Station(const TileInfo* ti) return ti->z + (ti->tileh == 0 ? 0 : 8); } -static uint GetSlopeTileh_Station(const TileInfo *ti) +static uint GetSlopeTileh_Station(TileIndex tile, uint tileh) { return 0; } diff --git a/town_cmd.c b/town_cmd.c index 94ba74938b..afd0d690c1 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -150,7 +150,7 @@ static uint GetSlopeZ_Town(const TileInfo* ti) return ti->z + (ti->tileh == 0 ? 0 : 8); } -static uint GetSlopeTileh_Town(const TileInfo *ti) +static uint GetSlopeTileh_Town(TileIndex tile, uint tileh) { return 0; } diff --git a/tree_cmd.c b/tree_cmd.c index 28290c7fec..eb87d77669 100644 --- a/tree_cmd.c +++ b/tree_cmd.c @@ -326,9 +326,9 @@ static uint GetSlopeZ_Trees(const TileInfo* ti) return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; } -static uint GetSlopeTileh_Trees(const TileInfo* ti) +static uint GetSlopeTileh_Trees(TileIndex tile, uint tileh) { - return ti->tileh; + return tileh; } static int32 ClearTile_Trees(TileIndex tile, byte flags) diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 68cc8246ac..612a248211 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1143,7 +1143,7 @@ static uint GetSlopeZ_TunnelBridge(const TileInfo* ti) return GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh) + ti->z; } -static uint GetSlopeTileh_TunnelBridge(const TileInfo* ti) +static uint GetSlopeTileh_TunnelBridge(TileIndex tile, uint tileh) { // not accurate, but good enough for slope graphics drawing return 0; diff --git a/unmovable_cmd.c b/unmovable_cmd.c index da6b8cf2c5..78c958462d 100644 --- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -212,9 +212,9 @@ static uint GetSlopeZ_Unmovable(const TileInfo* ti) } } -static uint GetSlopeTileh_Unmovable(const TileInfo *ti) +static uint GetSlopeTileh_Unmovable(TileIndex tile, uint tileh) { - return IsOwnedLand(ti->tile) ? ti->tileh : 0; + return IsOwnedLand(tile) ? tileh : 0; } static int32 ClearTile_Unmovable(TileIndex tile, byte flags) diff --git a/water_cmd.c b/water_cmd.c index c3e7aa7abc..5d9ca0ac2b 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -446,9 +446,9 @@ static uint GetSlopeZ_Water(const TileInfo* ti) return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; } -static uint GetSlopeTileh_Water(const TileInfo *ti) +static uint GetSlopeTileh_Water(TileIndex tile, uint tileh) { - return ti->tileh; + return tileh; } static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac)