summaryrefslogtreecommitdiff
path: root/ai.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-30 13:42:11 +0000
committerbjarni <bjarni@openttd.org>2005-01-30 13:42:11 +0000
commite8f4b7cf192a55cad0ed587411cea5e1efee22eb (patch)
tree348ca9e9ea285936ce9cd64a991a7486b766ca18 /ai.c
parent5987455d359375ab574dd0accc6a1871602c87ae (diff)
downloadopenttd-e8f4b7cf192a55cad0ed587411cea5e1efee22eb.tar.xz
(svn r1728) - Fix: now a player can only build a road vehicle in depots he owns (hacked client protection)
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 edc7b2703..ed5df3334 100644
--- a/ai.c
+++ b/ai.c
@@ -144,7 +144,7 @@ static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag, TileIndex
return best_veh_index;
}
-static int AiChooseRoadVehToBuild(byte cargo, int32 money)
+static int AiChooseRoadVehToBuild(byte cargo, int32 money, TileIndex tile)
{
int best_veh_index = -1;
int32 best_veh_cost = 0;
@@ -157,7 +157,7 @@ static int AiChooseRoadVehToBuild(byte cargo, int32 money)
if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
- r = DoCommandByTile(0, i, 0, 0, CMD_BUILD_ROAD_VEH);
+ r = DoCommandByTile(tile, i, 0, 0, CMD_BUILD_ROAD_VEH);
if (r != CMD_ERROR && r <= money && r >= best_veh_cost) {
best_veh_cost = r;
best_veh_index = i;
@@ -218,7 +218,7 @@ static int AiChooseShipToBuild(byte cargo, int32 money)
static int AiChooseRoadVehToReplaceWith(Player *p, Vehicle *v)
{
int32 avail_money = p->player_money + v->value;
- return AiChooseRoadVehToBuild(v->cargo_type, avail_money);
+ return AiChooseRoadVehToBuild(v->cargo_type, avail_money, v->tile);
}
static int AiChooseAircraftToReplaceWith(Player *p, Vehicle *v)
@@ -3173,7 +3173,7 @@ static void AiStateBuildRoadVehicles(Player *p)
for(;ptr->mode != 0;ptr++) {}
tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
- veh = AiChooseRoadVehToBuild(p->ai.cargo_type, p->player_money);
+ veh = AiChooseRoadVehToBuild(p->ai.cargo_type, p->player_money, tile);
if (veh == -1) {
p->ai.state = AIS_0;
return;