summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-02-06 08:15:30 +0000
committertron <tron@openttd.org>2006-02-06 08:15:30 +0000
commit34a9da4a3207f54bbda281d00b2df5e2cac95fe9 (patch)
tree9d9184763fc76f2586eea62adb5d38a7c2b7194e
parentfa529e1e3855f5a0689a95fa46737ff4223038e4 (diff)
downloadopenttd-34a9da4a3207f54bbda281d00b2df5e2cac95fe9.tar.xz
(svn r3561) Don't use FindLandscapeHeightByTile() when it's overkill. Also use a sprite enum instead of a magic number.
-rw-r--r--town_cmd.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 4811651b6..8d2f43de4 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -77,7 +77,7 @@ typedef struct DrawTownTileStruct {
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 @@ static Town *AllocateTown(void)
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 @@ int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Town *CreateRandomTown(uint attempts)
{
TileIndex tile;
- TileInfo ti;
Town *t;
uint32 townnameparts;
@@ -1073,9 +1071,7 @@ Town *CreateRandomTown(uint attempts)
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 void TownActionRoadRebuild(Town *t, int action)
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;