From a190ae9a71cd51d50c03be53d7695b8b85f2bdc0 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 14 Dec 2009 19:17:18 +0000 Subject: (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. --- src/vehicle_cmd.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/vehicle_cmd.cpp') 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); } -- cgit v1.2.3-54-g00ecf