summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2005-12-10 12:05:39 +0000
committerpeter1138 <peter1138@openttd.org>2005-12-10 12:05:39 +0000
commit809b03c81a841fcc428943c65760c74f3d26df57 (patch)
tree4ae75b1c93989fadb955dd408fcc2c0589671b22 /ai
parent6a6e1450106f9944f74021edcd9aec54b3cc11ab (diff)
downloadopenttd-809b03c81a841fcc428943c65760c74f3d26df57.tar.xz
(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
Diffstat (limited to 'ai')
-rw-r--r--ai/default/default.c12
-rw-r--r--ai/trolly/trolly.c10
2 files changed, 11 insertions, 11 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index b8648dbe2..72383ab12 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -1677,7 +1677,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, DC_NO_TOWN_RATING);
- if (*cost != CMD_ERROR && AiCheckTrackResources(tile, p->data, cargo))
+ if (!CmdFailed(*cost) && AiCheckTrackResources(tile, p->data, cargo))
return i;
}
}
@@ -1804,7 +1804,7 @@ static void AiStateBuildDefaultRailBlocks(Player *p)
_default_rail_track_data[rule]->data,
DC_EXEC | DC_NO_TOWN_RATING
);
- assert(r != CMD_ERROR);
+ assert(!CmdFailed(r));
}
} while (++aib,--j);
}
@@ -2529,7 +2529,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 (*cost != CMD_ERROR && AiCheckRoadResources(tile, p->data, cargo))
+ if (!CmdFailed(*cost) && AiCheckRoadResources(tile, p->data, cargo))
return i;
}
}
@@ -2690,7 +2690,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p)
_road_default_block_data[rule]->data,
DC_EXEC | DC_NO_TOWN_RATING
);
- assert(r != CMD_ERROR);
+ assert(!CmdFailed(r));
}
} while (++aib,--j);
} while (--i);
@@ -3392,7 +3392,7 @@ static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli,
continue;
*cost = AiDoBuildDefaultAirportBlock(tile, p, 0);
- if (*cost != CMD_ERROR && AiCheckAirportResources(tile, p, cargo))
+ if (!CmdFailed(*cost) && AiCheckAirportResources(tile, p, cargo))
return i;
}
return -1;
@@ -3463,7 +3463,7 @@ static void AiStateBuildDefaultAirportBlocks(Player *p)
_airport_default_block_data[rule],
DC_EXEC | DC_NO_TOWN_RATING
);
- assert(r != CMD_ERROR);
+ assert(!CmdFailed(r));
}
} while (++aib,--j);
} while (--i);
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index 2ddd8fb58..a2a0f8a35 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -659,7 +659,7 @@ static void AiNew_State_FindStation(Player *p)
if (accepts[p->ainew.cargo] >> 3 == 0) continue;
// See if we can build the station
r = AiNew_Build_Station(p, p->ainew.tbt, new_tile, 0, 0, 0, DC_QUERY_COST);
- if (r == CMD_ERROR) continue;
+ if (CmdFailed(r)) continue;
// We can build it, so add it to found_spot
found_spot[i] = new_tile;
found_best[i++] = accepts[p->ainew.cargo];
@@ -846,7 +846,7 @@ static void AiNew_State_FindDepot(Player *p)
if (ti.tileh != 0) continue;
// Check if everything went okay..
r = AiNew_Build_Depot(p, tile + TileOffsByDir(j), j ^ 2, 0);
- if (r == CMD_ERROR) continue;
+ if (CmdFailed(r)) continue;
// Found a spot!
p->ainew.new_cost += r;
p->ainew.depot_tile = tile + TileOffsByDir(j);
@@ -989,7 +989,7 @@ static void AiNew_State_BuildStation(Player *p)
res = AiNew_Build_Station(p, p->ainew.tbt, p->ainew.to_tile, 0, 0, p->ainew.to_direction, DC_EXEC);
p->ainew.state = AI_STATE_BUILD_PATH;
}
- if (res == CMD_ERROR) {
+ if (CmdFailed(res)) {
DEBUG(ai,0)("[AiNew - BuildStation] Strange but true... station can not be build!");
p->ainew.state = AI_STATE_NOTHING;
// If the first station _was_ build, destroy it
@@ -1119,7 +1119,7 @@ static void AiNew_State_BuildDepot(Player *p)
return;
res = AiNew_Build_Depot(p, p->ainew.depot_tile, p->ainew.depot_direction, DC_EXEC);
- if (res == CMD_ERROR) {
+ if (CmdFailed(res)) {
DEBUG(ai,0)("[AiNew - BuildDepot] Strange but true... depot can not be build!");
p->ainew.state = AI_STATE_NOTHING;
return;
@@ -1152,7 +1152,7 @@ static void AiNew_State_BuildVehicle(Player *p)
// Build the vehicle
res = AiNew_Build_Vehicle(p, p->ainew.depot_tile, DC_EXEC);
- if (res == CMD_ERROR) {
+ if (CmdFailed(res)) {
// This happens when the AI can't build any more vehicles!
p->ainew.state = AI_STATE_NOTHING;
return;