From 47137cefb72d3b3d3bc6fdefc7a4b103429f6d46 Mon Sep 17 00:00:00 2001 From: tron Date: Sun, 23 Oct 2005 13:04:44 +0000 Subject: (svn r3078) Some more stuff, which piled up: - const, whitespace, indentation, bracing, GB/SB, pointless casts - use the trinary operator where appropriate - data types (uint[] -> AcceptedCargo, ...) - if cascade -> switch - if (ptr) -> if (ptr != NULL) - DeMorgan's Law - Fix some comments - 0 -> '\0', change magic numbers to symbolic constants --- road_cmd.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'road_cmd.c') diff --git a/road_cmd.c b/road_cmd.c index 5275d461b..663864705 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -460,7 +460,7 @@ do_clear:; if (cost && (!_patches.build_on_slopes || _is_old_ai_player)) return CMD_ERROR; - if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) { + if (ti.type != MP_STREET || (ti.map5 & 0xF0) != 0) { cost += DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); } else { // Don't put the pieces that already exist @@ -483,7 +483,7 @@ do_clear:; SetTileOwner(tile, _current_player); } - _m[tile].m5 |= (byte)pieces; + _m[tile].m5 |= pieces; MarkTileDirtyByTile(tile); } @@ -554,8 +554,9 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD); if (CmdFailed(ret)) { if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; - } else + } else { cost += ret; + } if (tile == end_tile) break; @@ -642,24 +643,21 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) tile = ti.tile; - if (!EnsureNoVehicle(tile)) - return CMD_ERROR; + if (!EnsureNoVehicle(tile)) return CMD_ERROR; - if ((ti.tileh != 0) && ( - !_patches.build_on_slopes || - IsSteepTileh(ti.tileh) || - !CanBuildDepotByTileh(p1, ti.tileh) - ) - ) { - return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); + if (ti.tileh != 0 && ( + !_patches.build_on_slopes || + IsSteepTileh(ti.tileh) || + !CanBuildDepotByTileh(p1, ti.tileh) + )) { + return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); } cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(cost)) return CMD_ERROR; dep = AllocateDepot(); - if (dep == NULL) - return CMD_ERROR; + if (dep == NULL) return CMD_ERROR; if (flags & DC_EXEC) { if (IsLocalPlayer()) _last_built_road_depot_tile = tile; -- cgit v1.2.3-54-g00ecf