From 78bf7c43e58fc8b75b5fb7fbfc3c3986106210b6 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 17 Jul 2024 00:19:49 +0100 Subject: [PATCH] TBTR: Fix wrong replacement count when train only differed by refit --- src/tbtr_template_vehicle_func.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tbtr_template_vehicle_func.cpp b/src/tbtr_template_vehicle_func.cpp index ac192ae0ea..48aea7835e 100644 --- a/src/tbtr_template_vehicle_func.cpp +++ b/src/tbtr_template_vehicle_func.cpp @@ -280,11 +280,12 @@ void NeutralizeStatus(Train *t) TBTRDiffFlags TrainTemplateDifference(const Train *t, const TemplateVehicle *tv) { TBTRDiffFlags diff = TBTRDF_NONE; + const bool check_refit_as_template = tv->refit_as_template; while (t != nullptr && tv != nullptr) { if (t->engine_type != tv->engine_type) { return TBTRDF_ALL; } - if (tv->refit_as_template && (t->cargo_type != tv->cargo_type || t->cargo_subtype != tv->cargo_subtype)) { + if (check_refit_as_template && (t->cargo_type != tv->cargo_type || t->cargo_subtype != tv->cargo_subtype)) { diff |= TBTRDF_REFIT; } if (HasBit(t->flags, VRF_REVERSE_DIRECTION) != HasBit(tv->ctrl_flags, TVCF_REVERSED)) {