diff options
author | tron <tron@openttd.org> | 2006-03-10 12:57:42 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-10 12:57:42 +0000 |
commit | 293bf531beeb3a385f872da55e019c091f1efa8f (patch) | |
tree | 4844d3a6ad0359e64aa4edc683f5605d63a82881 | |
parent | abca252ff5925469d7394959493fb0c98416e8d5 (diff) | |
download | openttd-293bf531beeb3a385f872da55e019c091f1efa8f.tar.xz |
(svn r3813) Simplify strange control flow
-rw-r--r-- | water_cmd.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/water_cmd.c b/water_cmd.c index 1d81863d3..cd7087e3b 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -210,7 +210,7 @@ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2) */ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2) { - int32 ret, cost; + int32 cost; int size_x, size_y; int sx, sy; @@ -234,7 +234,6 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2) cost = 0; BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { - ret = 0; if (GetTileSlope(tile, NULL) != 0) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); // can't make water of water! @@ -246,28 +245,29 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (_m[tile].m5 & 0x20) // transport route under bridge return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); - if (_m[tile].m5 & 0x18) // already water under bridge + if (_m[tile].m5 & 0x18) { // already water under bridge return_cmd_error(STR_1007_ALREADY_BUILT); - /* no bridge? then try to clear it. */ - } else - ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); - - if (CmdFailed(ret)) return CMD_ERROR; - cost += ret; + } - /* execute modifications */ - if (flags & DC_EXEC) { - if (IsTileType(tile, MP_TUNNELBRIDGE)) { + if (flags & DC_EXEC) { // change owner to OWNER_WATER and set land under bridge bit to water ModifyTile(tile, MP_MAP5 | MP_MAPOWNER, OWNER_WATER, _m[tile].m5 | 0x08); - } else { + } + } else { + /* no bridge, try to clear it. */ + int32 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + + if (CmdFailed(ret)) return CMD_ERROR; + cost += ret; + + if (flags & DC_EXEC) { MakeWater(tile); MarkTileDirtyByTile(tile); } - // mark the tiles around dirty too - MarkTilesAroundDirty(tile); } + if (flags & DC_EXEC) MarkTilesAroundDirty(tile); + cost += _price.clear_water; } } END_TILE_LOOP(tile, size_x, size_y, 0); |