From 051cd1510a4ba5002c2c06325432cd2e0819b022 Mon Sep 17 00:00:00 2001 From: siimav Date: Sun, 3 Dec 2023 03:01:44 +0200 Subject: [PATCH] Fix fake failed parameters breaking on tracked VPG vessels. On parameters like HasCrewCapacity this caused issues when the state was updated on other non-relevant vessels; causing the param on actually tracked vessel no longer being completable. --- .../Parameter/VesselParameter.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/ContractConfigurator/Parameter/VesselParameter.cs b/source/ContractConfigurator/Parameter/VesselParameter.cs index 1b6f509a..75596ded 100644 --- a/source/ContractConfigurator/Parameter/VesselParameter.cs +++ b/source/ContractConfigurator/Parameter/VesselParameter.cs @@ -193,7 +193,12 @@ protected virtual bool SetState(Vessel vessel, Contracts.ParameterState state) // Force to failure if failWhenUnmet is set if (failWhenUnmet && state == ParameterState.Incomplete) { - SetState(ParameterState.Failed); + // but when using VPG logic only do it when the vessel is the one being tracked + VesselParameterGroup vpg = GetParameterGroupHost(); + if (vpg == null || vpg.TrackedVessel == vessel) + { + SetState(ParameterState.Failed); + } } // Set the state @@ -642,8 +647,9 @@ protected virtual void CheckVessel(Vessel vessel, bool forceStateChange = false) if (vpg != null) { // Set the craft specific state - bool stateChanged = SetState(vessel, VesselMeetsCondition(vessel) ? - Contracts.ParameterState.Complete : Contracts.ParameterState.Incomplete) || forceStateChange; + ParameterState newState = VesselMeetsCondition(vessel) ? + Contracts.ParameterState.Complete : Contracts.ParameterState.Incomplete; + bool stateChanged = SetState(vessel, newState) || forceStateChange; // Update the group if (stateChanged)