summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-09-05 23:43:42 +0000
committerDarkvater <darkvater@openttd.org>2006-09-05 23:43:42 +0000
commit3fee2555433c62735640c7e99f8a777ba060e5e5 (patch)
treea8ac54e5dd4a340b2ca6f298551d019e3ebc747c
parent80814dbb1d01f651ba7c60547dc1b52c1c209378 (diff)
downloadopenttd-3fee2555433c62735640c7e99f8a777ba060e5e5.tar.xz
(svn r6407) -Fix: Check return values of DoCommand() with CmdFailed and that of DoCommandP
with a boolean type.
-rw-r--r--ai/default/default.c2
-rw-r--r--clear_cmd.c2
-rw-r--r--vehicle.c9
3 files changed, 9 insertions, 4 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index aa1058709..acc7b8166 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -292,7 +292,7 @@ static void AiRestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
uint i;
for (i = 0; bak->order[i].type != OT_NOTHING; i++) {
- if (CmdFailed(DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)))
+ if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
break;
}
}
diff --git a/clear_cmd.c b/clear_cmd.c
index c12d30755..0093d8bca 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -138,7 +138,7 @@ static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
ret = DoCommand(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
- if (ret == CMD_ERROR) {
+ if (CmdFailed(ret)) {
_terraform_err_tile = tile;
return -1;
}
diff --git a/vehicle.c b/vehicle.c
index 26ac7d8a0..9b8d1b491 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -2047,8 +2047,13 @@ int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID own
/* Send all the vehicles to a depot */
for (i = 0; i < n; i++) {
const Vehicle *v = sort_list[i];
- if (!DoCommand(v->tile, v->index, service | DEPOT_DONT_CANCEL, flags, CMD_SEND_TO_DEPOT(type)) && !(flags & DC_EXEC)) {
- /* At least one vehicle is valid to send the command to, so the mass goto depot is valid. No need to check the rest */
+ int32 ret = DoCommand(v->tile, v->index, service | DEPOT_DONT_CANCEL, flags, CMD_SEND_TO_DEPOT(type));
+
+ /* Return 0 if DC_EXEC is not set this is a valid goto depot command)
+ * 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)) {
free((void*)sort_list);
return 0;
}