summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-11-04 15:04:24 +0000
committermichi_cc <michi_cc@openttd.org>2011-11-04 15:04:24 +0000
commitad2fdd8d6fefe8cde63aa4147ae5cd77ebae49d5 (patch)
treea2d4023cab37416a582f13f59d057126e3dee4cf /src/vehicle_gui.cpp
parent9782b7bb0af914d749b125c3a0ae56cccc99c8e3 (diff)
downloadopenttd-ad2fdd8d6fefe8cde63aa4147ae5cd77ebae49d5.tar.xz
(svn r23111) -Fix: Keep subtype when automatically choosing the cargo for auto-refitting.
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 5a2993516..abd1e3317 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -213,9 +213,10 @@ static const uint MAX_REFIT_CYCLE = 256;
* Assuming they are going to carry the same cargo ofcourse!
* @param v_from the vehicle to match the subtype from
* @param v_for the vehicle to get the subtype for
+ * @param dest_cargo_type Destination cargo type, taken from #v_from if set to #INVALID_CARGO.
* @return the best sub type
*/
-byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for)
+byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
{
const Engine *e_from = v_from->GetEngine();
const Engine *e_for = v_for->GetEngine();
@@ -229,8 +230,10 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for)
return 0;
}
+ if (dest_cargo_type == INVALID_CARGO) dest_cargo_type = v_from->cargo_type;
+
/* It has to be possible for v_for to carry the cargo of v_from. */
- if (!HasBit(e_for->info.refit_mask, v_from->cargo_type)) return 0;
+ if (!HasBit(e_for->info.refit_mask, dest_cargo_type)) return 0;
StringID expected_string = GetCargoSubtypeText(v_from);
@@ -239,7 +242,7 @@ byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for)
byte ret_refit_cyc = 0;
/* Set the 'destination' cargo */
- v_for->cargo_type = v_from->cargo_type;
+ v_for->cargo_type = dest_cargo_type;
/* Cycle through the refits */
for (uint refit_cyc = 0; refit_cyc < MAX_REFIT_CYCLE; refit_cyc++) {