summaryrefslogtreecommitdiff
path: root/ai.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-30 13:03:32 +0000
committerbjarni <bjarni@openttd.org>2005-01-30 13:03:32 +0000
commit5987455d359375ab574dd0accc6a1871602c87ae (patch)
treef4389cf976643959c60cee2389c87e647cddcfd5 /ai.c
parentcc7f7220c0f098da69be630a33bad75b6505788b (diff)
downloadopenttd-5987455d359375ab574dd0accc6a1871602c87ae.tar.xz
(svn r1727) - Fix: now CmdBuildRailVehicle() behaves correctly if DC_EXEC is set
this commit alters ai.c a little to get rid of the workaround from r1725 so AI players could still build locomotives
Diffstat (limited to 'ai.c')
-rw-r--r--ai.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ai.c b/ai.c
index 0014f075c..edc7b2703 100644
--- a/ai.c
+++ b/ai.c
@@ -116,7 +116,7 @@ static void AiStateVehLoop(Player *p)
p->ai.state_counter = 0;
}
-static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag)
+static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag, TileIndex tile)
{
int best_veh_index = -1;
byte best_veh_score = 0;
@@ -131,7 +131,7 @@ static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag)
|| !HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
- r = DoCommandByTile(0, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
+ r = DoCommandByTile(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
if (r != CMD_ERROR &&
(!(_cmd_build_rail_veh_var1&1) || !(flag&1)) &&
r <= money &&
@@ -238,7 +238,7 @@ static int AiChooseTrainToReplaceWith(Player *p, Vehicle *v)
}
// XXX: check if a wagon
- return AiChooseTrainToBuild(v->u.rail.railtype, avail_money, 0);
+ return AiChooseTrainToBuild(v->u.rail.railtype, avail_money, 0, v->tile);
}
static int AiChooseShipToReplaceWith(Player *p, Vehicle *v)
@@ -2393,7 +2393,7 @@ static void AiStateBuildRailVeh(Player *p)
}
// Which locomotive to build?
- veh = AiChooseTrainToBuild(p->ai.railtype_to_use, p->player_money, (cargo!=CT_PASSENGERS)?1:0);
+ veh = AiChooseTrainToBuild(p->ai.railtype_to_use, p->player_money, (cargo!=CT_PASSENGERS)?1:0, tile);
if (veh == -1) {
handle_nocash:
// after a while, if AI still doesn't have cash, get out of this block by selling the wagons.