From b3cda6ee62b367824dcb3a3aabe641bfe6bf4720 Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 7 Aug 2006 17:32:29 +0000 Subject: [PATCH] (svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo --- functions.h | 4 ---- landscape.c | 25 ------------------------- openttd.h | 1 - viewport.c | 21 +++++++++++++++++++-- 4 files changed, 19 insertions(+), 32 deletions(-) diff --git a/functions.h b/functions.h index 08e91badd8..bc1c6601d5 100644 --- a/functions.h +++ b/functions.h @@ -3,9 +3,6 @@ #ifndef FUNCTIONS_H #define FUNCTIONS_H -/* landscape.c */ -void FindLandscapeHeight(TileInfo *ti, uint x, uint y); - void DoClearSquare(TileIndex tile); void RunTileLoop(void); @@ -17,7 +14,6 @@ void ChangeTileOwner(TileIndex tile, byte old_player, byte new_player); void AnimateTile(TileIndex tile); void ClickTile(TileIndex tile); void GetTileDesc(TileIndex tile, TileDesc *td); -void DrawTile(TileInfo *ti); void UpdateTownMaxPass(Town *t); bool IsValidTile(TileIndex tile); diff --git a/landscape.c b/landscape.c index e6608fa5e1..0b083ebc3b 100644 --- a/landscape.c +++ b/landscape.c @@ -55,26 +55,6 @@ const byte _inclined_tileh[] = { }; -/* find the landscape height for the coordinates x y */ -void FindLandscapeHeight(TileInfo *ti, uint x, uint y) -{ - ti->x = x; - ti->y = y; - - if (x >= MapMaxX() * TILE_SIZE - 1 || y >= MapMaxY() * TILE_SIZE - 1) { - ti->tileh = SLOPE_FLAT; - ti->type = MP_VOID; - ti->tile = 0; - ti->z = 0; - } else { - TileIndex tile = TileVirtXY(x, y); - - ti->tile = tile; - ti->type = GetTileType(tile); - ti->tileh = GetTileSlope(tile, &ti->z); - } -} - uint GetPartialZ(int x, int y, Slope corners) { int z = 0; @@ -280,11 +260,6 @@ void ClickTile(TileIndex tile) _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile); } -void DrawTile(TileInfo *ti) -{ - _tile_type_procs[ti->type]->draw_tile_proc(ti); -} - void GetTileDesc(TileIndex tile, TileDesc *td) { _tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td); diff --git a/openttd.h b/openttd.h index c72cbc0a4a..18fa5b4492 100644 --- a/openttd.h +++ b/openttd.h @@ -130,7 +130,6 @@ typedef struct TileInfo { uint x; uint y; Slope tileh; - uint type; TileIndex tile; uint z; } TileInfo; diff --git a/viewport.c b/viewport.c index 200098188b..ed22304ce0 100644 --- a/viewport.c +++ b/viewport.c @@ -707,7 +707,24 @@ static void ViewportAddLandscape(void) int y_cur = y; do { - FindLandscapeHeight(&ti, x_cur, y_cur); + TileType tt; + + ti.x = x_cur; + ti.y = y_cur; + if (0 <= x_cur && x_cur < (int)MapMaxX() * TILE_SIZE && + 0 <= y_cur && y_cur < (int)MapMaxY() * TILE_SIZE) { + TileIndex tile = TileVirtXY(x_cur, y_cur); + + ti.tile = tile; + ti.tileh = GetTileSlope(tile, &ti.z); + tt = GetTileType(tile); + } else { + ti.tileh = SLOPE_FLAT; + ti.tile = 0; + ti.z = 0; + tt = MP_VOID; + } + #if !defined(NEW_ROTATION) y_cur += 0x10; x_cur -= 0x10; @@ -718,7 +735,7 @@ static void ViewportAddLandscape(void) _added_tile_sprite = false; _offset_ground_sprites = false; - DrawTile(&ti); + _tile_type_procs[tt]->draw_tile_proc(&ti); DrawTileSelection(&ti); } while (--width_cur);