diff options
author | rubidium <rubidium@openttd.org> | 2009-12-14 19:17:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-14 19:17:18 +0000 |
commit | a190ae9a71cd51d50c03be53d7695b8b85f2bdc0 (patch) | |
tree | 9839c6593863802f54fd6ce0d3cdd3201c94e317 /src/vehicle_cmd.cpp | |
parent | 620ca5e6c18cc0929f255d5ced094f214c6df15a (diff) | |
download | openttd-a190ae9a71cd51d50c03be53d7695b8b85f2bdc0.tar.xz |
(svn r18498) -Fix [FS#2616]: cloning of vehicles could create vehicles with invalid cargo sub types for the build year of the vehicle. Fall back to another cargo sub type with the exact same name, otherwise fallback to cargo sub type 0.
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r-- | src/vehicle_cmd.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index e710b905d..f696d1153 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -536,8 +536,10 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (flags & DC_EXEC) { assert(w != NULL); - if (w->cargo_type != v->cargo_type || w->cargo_subtype != v->cargo_subtype) { - CommandCost cost = DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8) | 1U << 16, flags, GetCmdRefitVeh(v)); + /* Find out what's the best sub type */ + byte subtype = GetBestFittingSubType(v, w); + if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) { + CommandCost cost = DoCommand(0, w->index, v->cargo_type | (subtype << 8) | 1U << 16, flags, GetCmdRefitVeh(v)); if (CmdSucceeded(cost)) total_cost.AddCost(cost); } |