Skip to content

Commit

Permalink
Prevent spamming spyware when facility upgrade fails to apply
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Aug 12, 2024
1 parent a8764ce commit ec9d66b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Source/RP0/SpaceCenter/Projects/FacilityUpgradeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Abort()
}
}

public void Apply()
public bool Apply()
{
RP0Debug.Log($"Upgrading {name} to level {upgradeLevel}");
KCTUtilities.SetFacilityLevel(FacilityType, upgradeLevel);
Expand All @@ -70,6 +70,8 @@ public void Apply()
{
RP0Debug.LogError($"Setting facility level failed, Current: {newLvl} Desired: {upgradeLevel}");
}

return upgradeProcessed;
}

public static List<UpgradeableFacility> GetFacilityReferencesById(string id)
Expand Down Expand Up @@ -136,15 +138,16 @@ protected override void ProcessComplete()
{
if (ScenarioUpgradeableFacilities.Instance != null && !SpaceCenterManagement.Instance.ErroredDuringOnLoad)
{
Apply();

try
{
SCMEvents.OnFacilityUpgradeComplete?.Fire(this);
}
catch (Exception ex)
if (Apply())
{
Debug.LogException(ex);
try
{
SCMEvents.OnFacilityUpgradeComplete?.Fire(this);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
}
Expand Down

0 comments on commit ec9d66b

Please sign in to comment.