diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-11-30 23:21:16 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 41fa16f3254ffa9f44b85d6570a2293e8438b427 (patch) | |
tree | a508634b7dea7a0937e92c143db0a392cd99a4b0 /src/autoreplace_cmd.cpp | |
parent | 57b82e2e99aa30a649d1fd80f192ccf5338dc7c4 (diff) | |
download | openttd-41fa16f3254ffa9f44b85d6570a2293e8438b427.tar.xz |
Codechange: Don't use globals for return values from vehicle command procs.
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r-- | src/autoreplace_cmd.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 9fef03839..5bdf8d0e5 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -345,17 +345,18 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic } /* Build the new vehicle */ - cost = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, CT_INVALID, INVALID_CLIENT_ID); + VehicleID new_veh_id; + std::tie(cost, new_veh_id, std::ignore, std::ignore) = Command<CMD_BUILD_VEHICLE>::Do(DC_EXEC | DC_AUTOREPLACE, old_veh->tile, e, true, CT_INVALID, INVALID_CLIENT_ID); if (cost.Failed()) return cost; - Vehicle *new_veh = Vehicle::Get(_new_vehicle_id); + Vehicle *new_veh = Vehicle::Get(new_veh_id); *new_vehicle = new_veh; /* Refit the vehicle if needed */ if (refit_cargo != CT_NO_REFIT) { byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo); - cost.AddCost(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, new_veh->index, refit_cargo, subtype, false, false, 0)); + cost.AddCost(std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, new_veh->index, refit_cargo, subtype, false, false, 0))); assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace() } |