summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-09-22 19:28:53 +0000
committerfrosch <frosch@openttd.org>2008-09-22 19:28:53 +0000
commitfb1fae001ac12a0fdb5cdc3cc350c2f2de35e649 (patch)
treee752fa0a1238c11e52e9e8a073391109f8ef5cab
parenta756b23dc45a795141e2fba390340059677a0f5e (diff)
downloadopenttd-fb1fae001ac12a0fdb5cdc3cc350c2f2de35e649.tar.xz
(svn r14384) -Fix: Moving the first vehicle of a train elsewhere might require a new unitnumber for the remaining chain.
-rw-r--r--src/train_cmd.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index e940cb22f..7a21aa82f 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1121,6 +1121,14 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (flags & DC_EXEC) src->unitnumber = unit_num;
}
+ /* When we move the front vehicle, the second vehicle might need a unitnumber */
+ if (!HasBit(p2, 0) && (IsFreeWagon(src) || IsFrontEngine(src)) && (flags & DC_AUTOREPLACE) == 0) {
+ Vehicle *second = GetNextUnit(src);
+ if (second != NULL && IsTrainEngine(second) && GetFreeUnitNumber(VEH_TRAIN) > _settings_game.vehicle.max_trains) {
+ return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
+ }
+ }
+
/*
* Check whether the vehicles in the source chain are in the destination
* chain. This can easily be done by checking whether the first vehicle