diff options
author | bjarni <bjarni@openttd.org> | 2005-01-30 13:42:11 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2005-01-30 13:42:11 +0000 |
commit | e8f4b7cf192a55cad0ed587411cea5e1efee22eb (patch) | |
tree | 348ca9e9ea285936ce9cd64a991a7486b766ca18 | |
parent | 5987455d359375ab574dd0accc6a1871602c87ae (diff) | |
download | openttd-e8f4b7cf192a55cad0ed587411cea5e1efee22eb.tar.xz |
(svn r1728) - Fix: now a player can only build a road vehicle in depots he owns (hacked client protection)
-rw-r--r-- | ai.c | 8 | ||||
-rw-r--r-- | roadveh_cmd.c | 4 |
2 files changed, 8 insertions, 4 deletions
@@ -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; diff --git a/roadveh_cmd.c b/roadveh_cmd.c index 445530008..64e92d28f 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -118,6 +118,10 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2) if (!IsEngineBuildable(p1, VEH_Road)) return CMD_ERROR; + if (!IsRoadDepotTile((TileIndex)tile)) return CMD_ERROR; + + if (_map_owner[tile] != _current_player) return CMD_ERROR; + SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); cost = EstimateRoadVehCost(p1); |