TBTR: Fix wrong replacement count when train only differed by refit

This commit is contained in:
Jonathan G Rennison
2024-07-17 00:19:49 +01:00
parent 422bcc3e26
commit 78bf7c43e5

View File

@@ -280,11 +280,12 @@ void NeutralizeStatus(Train *t)
TBTRDiffFlags TrainTemplateDifference(const Train *t, const TemplateVehicle *tv) TBTRDiffFlags TrainTemplateDifference(const Train *t, const TemplateVehicle *tv)
{ {
TBTRDiffFlags diff = TBTRDF_NONE; TBTRDiffFlags diff = TBTRDF_NONE;
const bool check_refit_as_template = tv->refit_as_template;
while (t != nullptr && tv != nullptr) { while (t != nullptr && tv != nullptr) {
if (t->engine_type != tv->engine_type) { if (t->engine_type != tv->engine_type) {
return TBTRDF_ALL; 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; diff |= TBTRDF_REFIT;
} }
if (HasBit(t->flags, VRF_REVERSE_DIRECTION) != HasBit(tv->ctrl_flags, TVCF_REVERSED)) { if (HasBit(t->flags, VRF_REVERSE_DIRECTION) != HasBit(tv->ctrl_flags, TVCF_REVERSED)) {