--- a/src/ai/trolly/trolly.cpp Wed Jun 13 12:05:56 2007 +0000
+++ b/src/ai/trolly/trolly.cpp Tue Jun 19 07:21:01 2007 +0000
@@ -642,7 +642,7 @@
if (new_tile == 0 && p->ainew.tbt == AI_BUS) {
uint x, y, i = 0;
- int r;
+ CommandCost r;
uint best;
uint accepts[NUM_CARGO];
TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4];
@@ -650,7 +650,7 @@
// To find a good spot we scan a range from the center, a get the point
// where we get the most cargo and where it is buildable.
// TODO: also check for station of myself and make sure we are not
- // taking eachothers passangers away (bad result when it does not)
+ // taking eachothers passengers away (bad result when it does not)
for (x = TileX(tile) - AI_FINDSTATION_TILE_RANGE; x <= TileX(tile) + AI_FINDSTATION_TILE_RANGE; x++) {
for (y = TileY(tile) - AI_FINDSTATION_TILE_RANGE; y <= TileY(tile) + AI_FINDSTATION_TILE_RANGE; y++) {
new_tile = TileXY(x, y);
@@ -788,7 +788,8 @@
// To make the depot stand in the middle of the route, we start from the center..
// But first we walk through the route see if we can find a depot that is ours
// this keeps things nice ;)
- int g, i, r;
+ int g, i;
+ CommandCost r;
DiagDirection j;
TileIndex tile;
assert(p->ainew.state == AI_STATE_FIND_DEPOT);
@@ -984,7 +985,7 @@
// Build the stations
static void AiNew_State_BuildStation(Player *p)
{
- int res = 0;
+ CommandCost res = 0;
assert(p->ainew.state == AI_STATE_BUILD_STATION);
if (p->ainew.temp == 0) {
if (!IsTileType(p->ainew.from_tile, MP_STATION))
@@ -1037,8 +1038,8 @@
// We don't want that, so try building some road left or right of the station
int dir1, dir2, dir3;
TileIndex tile;
- int i, ret;
- for (i=0;i<2;i++) {
+ CommandCost ret;
+ for (int i = 0; i < 2; i++) {
if (i == 0) {
tile = p->ainew.from_tile + TileOffsByDiagDir(p->ainew.from_direction);
dir1 = p->ainew.from_direction - 1;
@@ -1056,11 +1057,11 @@
}
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);
}
@@ -1068,11 +1069,11 @@
}
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);
}
@@ -1080,11 +1081,11 @@
}
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);
}
@@ -1102,7 +1103,7 @@
// Builds the depot
static void AiNew_State_BuildDepot(Player *p)
{
- int res = 0;
+ CommandCost res = 0;
assert(p->ainew.state == AI_STATE_BUILD_DEPOT);
if (IsTileType(p->ainew.depot_tile, MP_STREET) && GetRoadTileType(p->ainew.depot_tile) == ROAD_TILE_DEPOT) {
@@ -1137,7 +1138,7 @@
// Build vehicles
static void AiNew_State_BuildVehicle(Player *p)
{
- int res;
+ CommandCost res;
assert(p->ainew.state == AI_STATE_BUILD_VEHICLE);
// Check if we need to build a vehicle
@@ -1277,7 +1278,7 @@
if (!AiNew_SetSpecialVehicleFlag(p, v, AI_VEHICLEFLAG_SELL)) return;
{
- int ret = 0;
+ CommandCost ret = 0;
if (v->type == VEH_ROAD)
ret = AI_DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_ROADVEH_TO_DEPOT);
// This means we can not find a depot :s