diff options
author | frosch <frosch@openttd.org> | 2010-08-20 17:36:09 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-08-20 17:36:09 +0000 |
commit | 514edcc19d158f3b95232507ce0e3dab11affbbf (patch) | |
tree | 6fae14a7ccbd145e719e696f40c605aa1175cd54 /src | |
parent | 79027229b9ab70ff7bdaa069fee3957e4b8adabc (diff) | |
download | openttd-514edcc19d158f3b95232507ce0e3dab11affbbf.tar.xz |
(svn r20583) -Fix: Autoreplace failed while attaching non-replaced wagons to the new chain, if to-be-sold-engines would become front-engines and the unitnumber limit would be exceeded.
Diffstat (limited to 'src')
-rw-r--r-- | src/autoreplace_cmd.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 8771ef936..6341c7b1b 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -459,6 +459,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon /* Append engines to the new chain * We do this from back to front, so that the head of the temporary vehicle chain does not change all the time. + * That way we also have less trouble when exceeding the unitnumber limit. * OTOH the vehicle attach callback is more expensive this way :s */ Train *last_engine = NULL; ///< Shall store the last engine unit after this step if (cost.Succeeded()) { @@ -467,6 +468,13 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) continue; + if (new_vehs[i] != NULL) { + /* Move the old engine to a separate row with DC_AUTOREPLACE. Else + * moving the wagon in front may fail later due to unitnumber limit. + * (We have to attach wagons without DC_AUTOREPLACE.) */ + MoveVehicle(old_vehs[i], NULL, DC_EXEC | DC_AUTOREPLACE, false); + } + if (last_engine == NULL) last_engine = append; cost.AddCost(MoveVehicle(append, new_head, DC_EXEC, false)); if (cost.Failed()) break; |