summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-07-09 20:55:47 +0000
committersmatz <smatz@openttd.org>2008-07-09 20:55:47 +0000
commit447ec39f49e89689dc9070fe88c8eafc39a60fbe (patch)
treed7f550bb34964fafacec7f8c559f7e43aa32e91e /src/train_cmd.cpp
parent33150af3e2ca85326e5b84999ae8729ec65b338c (diff)
downloadopenttd-447ec39f49e89689dc9070fe88c8eafc39a60fbe.tar.xz
(svn r13691) -Codechange: make it easier to determine whether a command is ran in the context of autoreplace or not
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 88fa3d194..cb923e81d 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -685,8 +685,7 @@ static void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool buildin
* @param tile tile of the depot where rail-vehicle is built
* @param flags type of operation
* @param p1 engine type id
- * @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number
- * bit 1 prevents any free cars from being added to the train
+ * @param p2 bit 1 prevents any free cars from being added to the train
*/
CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -725,7 +724,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
Vehicle *v = vl[0];
- UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
+ UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
if (unit_num > _settings_game.vehicle.max_trains)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -798,7 +797,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
TrainConsistChanged(v);
UpdateTrainGroupID(v);
- if (!HasBit(p2, 1)) { // check if the cars should be added to the new vehicle
+ if (!HasBit(p2, 1) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle
NormalizeTrainVehInDepot(v);
}