summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-18 16:42:40 +0000
committerrubidium <rubidium@openttd.org>2007-06-18 16:42:40 +0000
commitb09431478d416ceb58f9676d67c1cc3b4af397bc (patch)
treea267e10793edc2f19da1d23e3a7f536644234f0f
parentfad2a36b8f9ce57610532226b2f14cbadc40fae9 (diff)
downloadopenttd-b09431478d416ceb58f9676d67c1cc3b4af397bc.tar.xz
(svn r10200) -Codechange: add "shortcut" for !CmdFailed (CmdSucceeded).
-rw-r--r--src/ai/default/default.cpp42
-rw-r--r--src/ai/trolly/build.cpp2
-rw-r--r--src/ai/trolly/pathfinder.cpp6
-rw-r--r--src/ai/trolly/trolly.cpp12
-rw-r--r--src/command.h2
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/town_cmd.cpp8
-rw-r--r--src/vehicle.cpp10
-rw-r--r--src/vehicle_gui.cpp2
-rw-r--r--src/water_cmd.cpp4
13 files changed, 49 insertions, 47 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 83ae1e004..d5d3922c8 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -152,7 +152,7 @@ static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag,
}
ret = DoCommand(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
- if (!CmdFailed(ret) && ret <= money && rvi->ai_rank >= best_veh_score) {
+ if (CmdSucceeded(ret) && ret <= money && rvi->ai_rank >= best_veh_score) {
best_veh_score = rvi->ai_rank;
best_veh_index = i;
}
@@ -216,7 +216,7 @@ static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
if ((AircraftVehInfo(i)->subtype & AIR_CTOL) != flag) continue;
ret = DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT);
- if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
+ if (CmdSucceeded(ret) && ret <= money && ret >= best_veh_cost) {
best_veh_cost = ret;
best_veh_index = i;
}
@@ -331,8 +331,8 @@ static void AiHandleReplaceTrain(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommand(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
- !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE))) {
+ if (CmdSucceeded(DoCommand(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
+ CmdSucceeded(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE))) {
VehicleID veh = _new_vehicle_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
@@ -360,8 +360,8 @@ static void AiHandleReplaceRoadVeh(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
- !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) {
+ if (CmdSucceeded(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
+ CmdSucceeded(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) {
VehicleID veh = _new_vehicle_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
@@ -389,8 +389,8 @@ static void AiHandleReplaceAircraft(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
- !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) {
+ if (CmdSucceeded(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
+ CmdSucceeded(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) {
VehicleID veh = _new_vehicle_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
@@ -1743,7 +1743,7 @@ static int AiBuildDefaultRailTrack(TileIndex tile, byte p0, byte p1, byte p2, by
if (p->p0 == p0 && p->p1 == p1 && p->p2 == p2 && p->p3 == p3 &&
(p->dir == 0xFF || p->dir == dir || ((p->dir - 1) & 3) == dir)) {
*cost = AiDoBuildDefaultRailTrack(tile, p->data, railtype, DC_NO_TOWN_RATING);
- if (!CmdFailed(*cost) && AiCheckTrackResources(tile, p->data, cargo))
+ if (CmdSucceeded(*cost) && AiCheckTrackResources(tile, p->data, cargo))
return i;
}
}
@@ -2069,7 +2069,7 @@ static inline void AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile,
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
CommandCost cost = DoCommand(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
- if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
+ if (CmdSucceeded(cost) && cost <= (arf->player->player_money >> 4)) {
AiBuildRailRecursive(arf, _build_tunnel_endtile, p[0] & 3);
if (arf->depth == 1) AiCheckRailPathBetter(arf, p);
}
@@ -2123,7 +2123,7 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
do {
// Make sure the tile is not in the list of banned tiles and that a rail can be built here.
if (!AiIsTileBanned(arf->player, tile, p[0]) &&
- !CmdFailed(DoCommand(tile, arf->player->ai.railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
+ CmdSucceeded(DoCommand(tile, arf->player->ai.railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
AiBuildRailRecursive(arf, tile, p[1]);
}
@@ -2211,7 +2211,7 @@ static void AiBuildRailConstruct(Player *p)
for (i = MAX_BRIDGES - 1; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
int32 cost = DoCommand(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE);
- if (!CmdFailed(cost) && cost < (p->player_money >> 5)) break;
+ if (CmdSucceeded(cost) && cost < (p->player_money >> 5)) break;
}
}
@@ -2500,7 +2500,7 @@ handle_nocash:
if (++p->ai.state_counter == 1000) {
for (i = 0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
cost = DoCommand(tile, p->ai.wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
- assert(!CmdFailed(cost));
+ assert(CmdSucceeded(cost));
}
p->ai.state = AIS_0;
}
@@ -2509,7 +2509,7 @@ handle_nocash:
// Try to build the locomotive
cost = DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
- assert(!CmdFailed(cost));
+ assert(CmdSucceeded(cost));
loco_id = _new_vehicle_id;
// Sell a vehicle if the train is double headed.
@@ -2618,7 +2618,7 @@ static int AiFindBestDefaultRoadBlock(TileIndex tile, byte direction, byte cargo
for (i = 0; (p = _road_default_block_data[i]) != NULL; i++) {
if (p->dir == direction) {
*cost = AiDoBuildDefaultRoadBlock(tile, p->data, 0);
- if (!CmdFailed(*cost) && AiCheckRoadResources(tile, p->data, cargo))
+ if (CmdSucceeded(*cost) && AiCheckRoadResources(tile, p->data, cargo))
return i;
}
}
@@ -2768,7 +2768,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
_road_default_block_data[rule]->data,
DC_EXEC | DC_NO_TOWN_RATING
);
- assert(!CmdFailed(r));
+ assert(CmdSucceeded(r));
}
} while (++aib, --j);
}
@@ -2916,7 +2916,7 @@ static bool AiBuildRoadHelper(TileIndex tile, int flags, int type)
ROAD_NW | ROAD_SW,
ROAD_SE | ROAD_NE
};
- return !CmdFailed(DoCommand(tile, _road_bits[type], 0, flags, CMD_BUILD_ROAD));
+ return CmdSucceeded(DoCommand(tile, _road_bits[type], 0, flags, CMD_BUILD_ROAD));
}
static inline void AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile, const byte *p)
@@ -2969,7 +2969,7 @@ static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile,
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
CommandCost cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
- if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
+ if (CmdSucceeded(cost) && cost <= (arf->player->player_money >> 4)) {
AiBuildRoadRecursive(arf, _build_tunnel_endtile, p[0] & 3);
if (arf->depth == 1) AiCheckRoadPathBetter(arf, p);
}
@@ -3102,7 +3102,7 @@ do_some_terraform:
for (i = 10; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
CommandCost cost = DoCommand(tile, p->ai.cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE);
- if (!CmdFailed(cost) && cost < (p->player_money >> 5)) break;
+ if (CmdSucceeded(cost) && cost < (p->player_money >> 5)) break;
}
}
@@ -3435,7 +3435,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli,
if (heli && !(GetAirport(p->attr)->flags & AirportFTAClass::HELICOPTERS)) continue;
*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
- if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo))
+ if (CmdSucceeded(*cost) && AiCheckAirportResources(tile, p, cargo))
return i;
}
return -1;
@@ -3494,7 +3494,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
_airport_default_block_data[rule],
DC_EXEC | DC_NO_TOWN_RATING
);
- assert(!CmdFailed(r));
+ assert(CmdSucceeded(r));
}
} while (++aib, --j);
} while (--i);
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp
index 60518d0fa..25b7ebd8d 100644
--- a/src/ai/trolly/build.cpp
+++ b/src/ai/trolly/build.cpp
@@ -206,7 +206,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
return 0;
}
- if (!CmdFailed(res)) cost += res;
+ if (CmdSucceeded(res)) cost += res;
}
// Go to the next tile
part++;
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index 4fca513df..4cc160748 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -28,13 +28,13 @@ static bool TestCanBuildStationHere(TileIndex tile, byte dir)
// should be fixed!!!
for (dir = 0; dir < 4; dir++) {
ret = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
- if (!CmdFailed(ret)) return true;
+ if (CmdSucceeded(ret)) return true;
}
return false;
}
// return true if command succeeded, so the inverse of CmdFailed()
- return !CmdFailed(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
+ return CmdSucceeded(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
}
@@ -352,7 +352,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
// Now simply check if a tunnel can be build
ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road?0:0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
tileh = GetTileSlope(_build_tunnel_endtile, NULL);
- if (!CmdFailed(ret) && (tileh == SLOPE_SW || tileh == SLOPE_SE || tileh == SLOPE_NW || tileh == SLOPE_NE)) {
+ if (CmdSucceeded(ret) && (tileh == SLOPE_SW || tileh == SLOPE_SE || tileh == SLOPE_NW || tileh == SLOPE_NE)) {
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_TUNNEL + (dir << 8);
aystar->neighbours[aystar->num_neighbours++].direction = 0;
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index dd274e2ed..f0e3e2500 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -1057,11 +1057,11 @@ static void AiNew_State_BuildPath(Player *p)
}
ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir((DiagDirection)dir1)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
dir1 = TileOffsByDiagDir(dir1);
if (IsTileType(tile + dir1, MP_CLEAR) || IsTileType(tile + dir1, MP_TREES)) {
ret = AI_DoCommand(tile+dir1, AiNew_GetRoadDirection(tile, tile+dir1, tile+dir1+dir1), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
if (IsTileType(tile + dir1 + dir1, MP_CLEAR) || IsTileType(tile + dir1 + dir1, MP_TREES))
AI_DoCommand(tile+dir1+dir1, AiNew_GetRoadDirection(tile+dir1, tile+dir1+dir1, tile+dir1+dir1+dir1), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
}
@@ -1069,11 +1069,11 @@ static void AiNew_State_BuildPath(Player *p)
}
ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir((DiagDirection)dir2)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
dir2 = TileOffsByDiagDir(dir2);
if (IsTileType(tile + dir2, MP_CLEAR) || IsTileType(tile + dir2, MP_TREES)) {
ret = AI_DoCommand(tile+dir2, AiNew_GetRoadDirection(tile, tile+dir2, tile+dir2+dir2), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
if (IsTileType(tile + dir2 + dir2, MP_CLEAR) || IsTileType(tile + dir2 + dir2, MP_TREES))
AI_DoCommand(tile+dir2+dir2, AiNew_GetRoadDirection(tile+dir2, tile+dir2+dir2, tile+dir2+dir2+dir2), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
}
@@ -1081,11 +1081,11 @@ static void AiNew_State_BuildPath(Player *p)
}
ret = AI_DoCommand(tile, DiagDirToRoadBits((DiagDirection)dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
dir3 = TileOffsByDiagDir(dir3);
if (IsTileType(tile + dir3, MP_CLEAR) || IsTileType(tile + dir3, MP_TREES)) {
ret = AI_DoCommand(tile+dir3, AiNew_GetRoadDirection(tile, tile+dir3, tile+dir3+dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
if (IsTileType(tile + dir3 + dir3, MP_CLEAR) || IsTileType(tile + dir3 + dir3, MP_TREES))
AI_DoCommand(tile+dir3+dir3, AiNew_GetRoadDirection(tile+dir3, tile+dir3+dir3, tile+dir3+dir3+dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
}
diff --git a/src/command.h b/src/command.h
index 428dd32d6..177663e0b 100644
--- a/src/command.h
+++ b/src/command.h
@@ -205,6 +205,8 @@ static inline bool CmdFailed(CommandCost res)
return res <= (CMD_ERROR | INVALID_STRING_ID);
}
+static inline bool CmdSucceeded(CommandCost res) { return !CmdFailed(res); }
+
/* command.cpp */
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index f9bde39bb..24a5f379f 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -122,7 +122,7 @@ static void Place_LandInfo(TileIndex tile)
GetString(_landinfo_data[1], STR_01A7_OWNER, lastof(_landinfo_data[1]));
str = STR_01A4_COST_TO_CLEAR_N_A;
- if (!CmdFailed(costclear)) {
+ if (CmdSucceeded(costclear)) {
SetDParam(0, costclear);
str = STR_01A5_COST_TO_CLEAR;
}
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 8e54cafd2..c19287614 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -810,7 +810,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1,
ret = DoCommand(tile, p1, signals, flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
/* Be user-friendly and try placing signals as much as possible */
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
error = false;
total_cost += ret;
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 7f29577e6..ade4794f9 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -704,7 +704,7 @@ CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint3
/* try to remove the halves. */
if (bits != 0) {
ret = DoCommand(tile, rt << 4 | bits, 0, flags, CMD_REMOVE_ROAD);
- if (!CmdFailed(ret)) cost += ret;
+ if (CmdSucceeded(ret)) cost += ret;
}
if (tile == end_tile) break;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 9cb7f7131..bcb4b0886 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1441,7 +1441,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
CommandCost ret = RemoveRoadStop(st, flags, tile);
/* If the stop was a drive-through stop replace the road */
- if ((flags & DC_EXEC) && !CmdFailed(ret) && is_drive_through) {
+ if ((flags & DC_EXEC) && CmdSucceeded(ret) && is_drive_through) {
/* Rebuild the drive throuhg road stop. As a road stop can only be
* removed by the owner of the roadstop, _current_player is the
* owner of the road stop. */
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 783137e48..ddb298977 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1063,7 +1063,7 @@ static void GrowTownInTile(TileIndex* tile_ptr, RoadBits mask, int block, Town*
default:
build_road_and_exit:
- if (!CmdFailed(DoCommand(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
+ if (CmdSucceeded(DoCommand(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
_grow_town_result = -1;
}
return;
@@ -1096,7 +1096,7 @@ build_road_and_exit:
do {
byte bridge_type = RandomRange(MAX_BRIDGES - 1);
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
- if (!CmdFailed(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
+ if (CmdSucceeded(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
_grow_town_result = -1;
/* obviously, if building any bridge would fail, there is no need to try other bridge-types */
@@ -1235,7 +1235,7 @@ static bool GrowTown(Town *t)
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
/* Only work with plain land that not already has a house */
if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
- if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
+ if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
_current_player = old_player;
return true;
@@ -1587,7 +1587,7 @@ static bool CheckBuildHouseMode(TileIndex tile, Slope tileh, int mode)
if (b)
return false;
- return !CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
+ return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index c6515fe19..e1bc27d7a 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1725,7 +1725,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uin
ret = DoCommand(tile, v->index, 0, flags, stop_command);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
return_value = 0;
/* We know that the command is valid for at least one vehicle.
* If we haven't set DC_EXEC, then there is no point in continueing because it will be valid */
@@ -1781,7 +1781,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uin
ret = DoCommand(tile, v->index, 1, flags, sell_command);
- if (!CmdFailed(ret)) cost += ret;
+ if (CmdSucceeded(ret)) cost += ret;
}
free(engines);
@@ -1829,7 +1829,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uin
}
ret = MaybeReplaceVehicle(v, !(flags & DC_EXEC), false);
- if (!CmdFailed(ret)) {
+ if (CmdSucceeded(ret)) {
cost += ret;
if (!(flags & DC_EXEC)) break;
/* There is a problem with autoreplace and newgrf
@@ -1972,7 +1972,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (w->cargo_type != v->cargo_type || w->cargo_subtype != v->cargo_type) {
cost = DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8) | 1U << 16 , flags, GetCmdRefitVeh(v));
- if (!CmdFailed(cost)) total_cost += cost;
+ if (CmdSucceeded(cost)) total_cost += cost;
}
if (w->type == VEH_TRAIN && EngineHasArticPart(w)) {
@@ -2240,7 +2240,7 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service,
* In this case we know that at least one vehicle can be sent to a depot
* and we will issue the command. We can now safely quit the loop, knowing
* it will succeed at least once. With DC_EXEC we really need to send them to the depot */
- if (!CmdFailed(ret) && !(flags & DC_EXEC)) {
+ if (CmdSucceeded(ret) && !(flags & DC_EXEC)) {
free((void*)sort_list);
return 0;
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 5bffa340d..02123969b 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -343,7 +343,7 @@ static void VehicleRefitWndProc(Window *w, WindowEvent *e)
cost = DoCommand(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8,
DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type));
- if (!CmdFailed(cost)) {
+ if (CmdSucceeded(cost)) {
SetDParam(0, WP(w, refit_d).cargo->cargo);
SetDParam(1, _returned_refit_capacity);
SetDParam(2, cost);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 1a06c3ff6..1b6f5c0f1 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -588,7 +588,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
case MP_CLEAR:
case MP_TREES:
_current_player = OWNER_WATER;
- if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
MakeShore(target);
MarkTileDirtyByTile(target);
}
@@ -603,7 +603,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
Vehicle *v = FindFloodableVehicleOnTile(target);
if (v != NULL) FloodVehicle(v);
- if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
MakeWater(target);
MarkTileDirtyByTile(target);
}