diff options
author | rubidium <rubidium@openttd.org> | 2009-12-14 19:19:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-14 19:19:47 +0000 |
commit | 42507923892ee30e4ec2e9d079e1a63aab53c48a (patch) | |
tree | b31f34d32f48b08b7f6997695f1e86ba3b982292 | |
parent | a190ae9a71cd51d50c03be53d7695b8b85f2bdc0 (diff) | |
download | openttd-42507923892ee30e4ec2e9d079e1a63aab53c48a.tar.xz |
(svn r18499) -Fix/Change/Feature [FS#3159]: autoreplace and autorenew always reset their cargo sub type to 0. Now find a sub cargo type with the exact same name and use that, otherwise fallback to 0. So cargo sub types can be maintained via autoreplace *if* the new vehicle supports the same cargo sub type.
-rw-r--r-- | src/autoreplace_cmd.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 751175c27..bf1104d34 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -271,8 +271,13 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic *new_vehicle = new_veh; /* Refit the vehicle if needed */ + byte subtype = GetBestFittingSubType(old_veh, new_veh); + /* If the subtype isn't zero and the refit cargo is not set, + * we're better off setting the refit cargo too. */ + if (subtype != 0 && refit_cargo == CT_NO_REFIT) refit_cargo = old_veh->cargo_type; + if (refit_cargo != CT_NO_REFIT) { - cost.AddCost(DoCommand(0, new_veh->index, refit_cargo, DC_EXEC, GetCmdRefitVeh(new_veh))); + cost.AddCost(DoCommand(0, new_veh->index, refit_cargo | (subtype << 8), DC_EXEC, GetCmdRefitVeh(new_veh))); assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace() } |