From d624f66c794109a22787685a3aa53d6cf35a02ba Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 26 Jul 2007 16:51:10 +0000 Subject: (svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch. --- src/industry_cmd.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/industry_cmd.cpp') diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index fdbda407f..bbdab2415 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -255,7 +255,6 @@ static void DrawTile_Industry(TileInfo *ti) Industry *ind = GetIndustryByTile(ti->tile); const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); const DrawBuildingsTileStruct *dits; - byte z; SpriteID image; SpriteID pal; @@ -287,12 +286,8 @@ static void DrawTile_Industry(TileInfo *ti) pal = dits->ground.pal; } - z = ti->z; - /* Add bricks below the industry? */ - if (ti->tileh != SLOPE_FLAT) { - DrawFoundation(ti, ti->tileh); - z += TILE_HEIGHT; - } + /* DrawFoundation() modifes ti->z and ti->tileh */ + if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); DrawGroundSprite(image, pal); @@ -306,7 +301,7 @@ static void DrawTile_Industry(TileInfo *ti) dits->width + 1, dits->height + 1, dits->dz, - z, + ti->z, HASBIT(_transparent_opt, TO_INDUSTRIES)); if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return; @@ -323,9 +318,9 @@ static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y) return GetTileMaxZ(tile); } -static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh) +static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh) { - return SLOPE_FLAT; + return FlatteningFoundation(tileh); } static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) @@ -1995,7 +1990,7 @@ extern const TileTypeProcs _tile_type_industry_procs = { ChangeTileOwner_Industry, /* change_tile_owner_proc */ GetProducedCargo_Industry, /* get_produced_cargo_proc */ NULL, /* vehicle_enter_tile_proc */ - GetSlopeTileh_Industry, /* get_slope_tileh_proc */ + GetFoundation_Industry, /* get_foundation_proc */ }; static const SaveLoad _industry_desc[] = { -- cgit v1.2.3-54-g00ecf