changeset 2986:3d3ce13752b0 draft

(svn r3561) Don't use FindLandscapeHeightByTile() when it's overkill. Also use a sprite enum instead of a magic number.
author tron <tron@openttd.org>
date Mon, 06 Feb 2006 08:15:30 +0000
parents 448dc4355596
children f1bbf7b7003b
files town_cmd.c
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -77,7 +77,7 @@
 
 static void TownDrawHouseLift(const TileInfo *ti)
 {
-	AddChildSpriteScreen(0x5A3, 0xE, 0x3C - GB(_m[ti->tile].m1, 0, 7));
+	AddChildSpriteScreen(SPR_LIFT, 14, 60 - GB(_m[ti->tile].m1, 0, 7));
 }
 
 typedef void TownDrawTileProc(const TileInfo *ti);
@@ -1021,7 +1021,6 @@
 int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 {
 	TileIndex tile = TileVirtXY(x, y);
-	TileInfo ti;
 	Town *t;
 	uint32 townnameparts;
 
@@ -1035,9 +1034,9 @@
 		return_cmd_error(STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP);
 
 	// Can only build on clear flat areas.
-	FindLandscapeHeightByTile(&ti, tile);
-	if (ti.type != MP_CLEAR || ti.tileh != 0)
+	if (!IsTileType(tile, MP_CLEAR) || GetTileSlope(tile, NULL) != 0) {
 		return_cmd_error(STR_0239_SITE_UNSUITABLE);
+	}
 
 	// Check distance to all other towns.
 	if (IsCloseToTown(tile, 20))
@@ -1063,7 +1062,6 @@
 Town *CreateRandomTown(uint attempts)
 {
 	TileIndex tile;
-	TileInfo ti;
 	Town *t;
 	uint32 townnameparts;
 
@@ -1073,9 +1071,7 @@
 		if (DistanceFromEdge(tile) < 20) continue;
 
 		// Make sure the tile is plain
-		FindLandscapeHeightByTile(&ti, tile);
-		if (ti.type != MP_CLEAR || ti.tileh != 0)
-			continue;
+		if (!IsTileType(tile, MP_CLEAR) || GetTileSlope(tile, NULL) != 0) continue;
 
 		// Check not too close to a town
 		if (IsCloseToTown(tile, 20)) continue;
@@ -1562,16 +1558,16 @@
 
 static bool DoBuildStatueOfCompany(TileIndex tile)
 {
-	TileInfo ti;
 	PlayerID old;
 	int32 r;
 
-	FindLandscapeHeightByTile(&ti, tile);
-	if (ti.tileh != 0) return false;
+	if (GetTileSlope(tile, NULL) != 0) return false;
 
-	if (ti.type != MP_HOUSE && ti.type != MP_CLEAR && ti.type != MP_TREES)
+	if (!IsTileType(tile, MP_HOUSE) &&
+			!IsTileType(tile, MP_CLEAR) &&
+			!IsTileType(tile, MP_TREES)) {
 		return false;
-
+	}
 
 	old = _current_player;
 	_current_player = OWNER_NONE;