From a2362674e33e66bf1d27df208db5b2250a01012e Mon Sep 17 00:00:00 2001 From: tron Date: Sat, 10 Jun 2006 08:37:41 +0000 Subject: (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc. --- clear_cmd.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'clear_cmd.c') diff --git a/clear_cmd.c b/clear_cmd.c index 259146965..2bd0dd732 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -142,8 +142,7 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height for (;;) { if (count == 0) { - if (ts->modheight_count >= 576) - return false; + if (ts->modheight_count >= 576) return false; ts->modheight_count++; break; } @@ -190,6 +189,7 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { TerraformerState ts; + TileIndex t; int direction; TerraformerHeightMod modheight_data[576]; @@ -210,27 +210,31 @@ int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR; if (p1 & 1) { - if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 0), - TileHeight(tile + TileDiffXY(1, 0)) + direction)) - return CMD_ERROR; + t = tile + TileDiffXY(1, 0); + if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { + return CMD_ERROR; + } } if (p1 & 2) { - if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 1), - TileHeight(tile + TileDiffXY(1, 1)) + direction)) - return CMD_ERROR; + t = tile + TileDiffXY(1, 1); + if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { + return CMD_ERROR; + } } if (p1 & 4) { - if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 1), - TileHeight(tile + TileDiffXY(0, 1)) + direction)) - return CMD_ERROR; + t = tile + TileDiffXY(0, 1); + if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { + return CMD_ERROR; + } } if (p1 & 8) { - if (!TerraformTileHeight(&ts, tile + TileDiffXY(0, 0), - TileHeight(tile + TileDiffXY(0, 0)) + direction)) - return CMD_ERROR; + t = tile + TileDiffXY(0, 0); + if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) { + return CMD_ERROR; + } } { /* Check if tunnel or track would take damage */ @@ -430,8 +434,7 @@ int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) if (!EnsureNoVehicle(tile)) return CMD_ERROR; - if (flags & DC_EXEC) - DoClearSquare(tile); + if (flags & DC_EXEC) DoClearSquare(tile); return - _price.purchase_land * 2; } -- cgit v1.2.3-54-g00ecf