mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r3390) -Fix: [autoreplace] fixed issue where autoreplace failed to attach the cars if the front engine was replaced
and the front engine was multiheaded and the first vehicle after it was the rear part of that engine
This commit is contained in:
parent
461d76a40c
commit
8958c8b7b1
15
vehicle.c
15
vehicle.c
@ -1654,10 +1654,17 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
|
|||||||
new_front = true;
|
new_front = true;
|
||||||
|
|
||||||
new_v->current_order = old_v->current_order;
|
new_v->current_order = old_v->current_order;
|
||||||
if (old_v->type == VEH_Train){
|
if (old_v->type == VEH_Train && GetNextVehicle(old_v) != NULL){
|
||||||
// move the entire train to the new engine, including the old engine. It will be sold in a moment anyway
|
Vehicle *temp_v = GetNextVehicle(old_v);
|
||||||
if (GetNextVehicle(old_v) != NULL) {
|
|
||||||
DoCommand(0, 0, (new_v->index << 16) | GetNextVehicle(old_v)->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
// move the entire train to the new engine, excluding the old engine
|
||||||
|
if (IsMultiheaded(old_v) && temp_v == old_v->u.rail.other_multiheaded_part) {
|
||||||
|
// we got front and rear of a multiheaded engine right after each other. We should work with the next in line instead
|
||||||
|
temp_v = GetNextVehicle(temp_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp_v != NULL) {
|
||||||
|
DoCommand(0, 0, (new_v->index << 16) | temp_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user