diff options
author | bjarni <bjarni@openttd.org> | 2006-05-11 12:42:24 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-05-11 12:42:24 +0000 |
commit | 06156142d4857acb6ed04166c28b2ec787ec9c10 (patch) | |
tree | 0dbe5e2f6a89f5c6defc151d3ac045c35e701942 /train_cmd.c | |
parent | 0bbd367245f0c8b2ab1ae56e2249d2c8346e58df (diff) | |
download | openttd-06156142d4857acb6ed04166c28b2ec787ec9c10.tar.xz |
(svn r4825) - Fix [clone FS#159]: Game crashes when cloning reaches train-limit.
Diffstat (limited to 'train_cmd.c')
-rw-r--r-- | train_cmd.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/train_cmd.c b/train_cmd.c index 37cc2bf27..81cccfc04 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -700,6 +700,7 @@ static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool buildin * @param tile tile of the depot where rail-vehicle is built * @param p1 engine type id * @param p2 bit 0 prevents any free cars from being added to the train + * bit 1 when set, the train will get number 0, otherwise it will get a free number */ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -743,10 +744,14 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v = vl[0]; - unit_num = GetFreeUnitNumber(VEH_Train); - if (unit_num > _patches.max_trains) - return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); - + if (HASBIT(p2, 1)) { + // no number is needed, so we assign 0. The engine is likely intended for a train with more than one engine + unit_num = 0; + } else { + unit_num = GetFreeUnitNumber(VEH_Train); + if (unit_num > _patches.max_trains) + return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); + } if (flags & DC_EXEC) { DiagDirection dir = GetRailDepotDirection(tile); int x = TileX(tile) * TILE_SIZE + _vehicle_initial_x_fract[dir]; |