mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r11043) -Fix (r10039) [FS#1185]: Autorenew/autoreplace fails silently with multiple multi-headed engines
This commit is contained in:
parent
222e105ec7
commit
b50a3d7522
@ -247,14 +247,18 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
|||||||
}
|
}
|
||||||
} else { // flags & DC_EXEC not set
|
} else { // flags & DC_EXEC not set
|
||||||
CommandCost tmp_move;
|
CommandCost tmp_move;
|
||||||
if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v) && old_v->Next() != NULL) {
|
|
||||||
|
if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) {
|
||||||
|
Vehicle *next_veh = IsMultiheaded(old_v) ? old_v->Next()->Next() : old_v->Next();
|
||||||
|
if (next_veh != NULL) {
|
||||||
/* Verify that the wagons can be placed on the engine in question.
|
/* Verify that the wagons can be placed on the engine in question.
|
||||||
* This is done by building an engine, test if the wagons can be added and then sell the test engine. */
|
* This is done by building an engine, test if the wagons can be added and then sell the test engine. */
|
||||||
DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v));
|
DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v));
|
||||||
Vehicle *temp = GetVehicle(_new_vehicle_id);
|
Vehicle *temp = GetVehicle(_new_vehicle_id);
|
||||||
tmp_move = DoCommand(0, (temp->index << 16) | old_v->Next()->index, 1, 0, CMD_MOVE_RAIL_VEHICLE);
|
tmp_move = DoCommand(0, (temp->index << 16) | next_veh->index, 1, 0, CMD_MOVE_RAIL_VEHICLE);
|
||||||
DoCommand(0, temp->index, 0, DC_EXEC, GetCmdSellVeh(old_v));
|
DoCommand(0, temp->index, 0, DC_EXEC, GetCmdSellVeh(old_v));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure that the player will not end up having negative money while autoreplacing
|
/* Ensure that the player will not end up having negative money while autoreplacing
|
||||||
* This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
|
* This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
|
||||||
|
Loading…
Reference in New Issue
Block a user