summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-01-29 23:58:07 +0000
committerbjarni <bjarni@openttd.org>2005-01-29 23:58:07 +0000
commitc16c7312cf37f9bf040e03f87d732bd862afb186 (patch)
treebf75218b593ac258be6f2ba79364c886d59dbae4 /train_cmd.c
parentb18851e0b99bca891ab97067af17fc5d37d03f2a (diff)
downloadopenttd-c16c7312cf37f9bf040e03f87d732bd862afb186.tar.xz
(svn r1725) - Fix: now trains can only be built in depots and you have to own the depot too (hacked client protection)
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 08afbd391..2ab61e49e 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -524,15 +524,20 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Vehicle *v, *u;
byte unit_num;
Engine *e;
- uint tile;
+ uint tile = TILE_FROM_XY(x,y);
if (!IsEngineBuildable(p1, VEH_Train)) return CMD_ERROR;
+ /* NOTE: The AI sends build engine commands without DC_EXEC to figure out if
+ it can affort an engine before trying to buy it*/
+ if (!IsTrainDepotTile((TileIndex)tile) && flags & DC_EXEC) return CMD_ERROR;
+
+ if (_map_owner[tile] != _current_player && flags & DC_EXEC) return CMD_ERROR;
+
_cmd_build_rail_veh_var1 = 0;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
- tile = TILE_FROM_XY(x,y);
rvi = RailVehInfo(p1);
if (rvi->flags & RVI_WAGON) {