From 62a4c1bc597de8f426f778f0935cad035063bd1d Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Mon, 24 Oct 2022 09:16:05 +0200 Subject: [PATCH 1/2] Fixed bug with data restore causing infinite spinner when MC isn't on --- src/Core/DataManager.cs | 72 ++++++++++++++++++++------------------ src/Core/MissionControl.cs | 3 +- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/Core/DataManager.cs b/src/Core/DataManager.cs index 9deccb05..3d68dfaa 100644 --- a/src/Core/DataManager.cs +++ b/src/Core/DataManager.cs @@ -569,50 +569,52 @@ public void ResetBetweenContracts() { } public void BackupContractOverriddeData() { - Main.Logger.Log($"[MissionControl] Backing up original ContractOverride data for: " + MissionControl.Instance.CurrentContract.Name); + if (Main.Settings.Misc.ContractOverrideDataCleanupMethod == "RestoreFromCopy") { + Main.Logger.Log($"[MissionControl] Backing up original ContractOverride data for: " + MissionControl.Instance.CurrentContract.Name); - // Lance Overrides - ContractOverrideLanceOverrideBackup = new Dictionary>(); + // Lance Overrides + ContractOverrideLanceOverrideBackup = new Dictionary>(); - ContractOverrideLanceOverrideBackup.Add("Player1", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.player1Team.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["Player1"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("Player1", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.player1Team.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["Player1"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("Employer", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.employerTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["Employer"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("Employer", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.employerTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["Employer"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("EmployerAlly", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.employersAllyTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["EmployerAlly"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("EmployerAlly", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.employersAllyTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["EmployerAlly"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("Target", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.targetTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["Target"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("Target", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.targetTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["Target"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("TargetAlly", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.targetsAllyTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["TargetAlly"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("TargetAlly", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.targetsAllyTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["TargetAlly"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("NeutralToAll", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.neutralToAllTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["NeutralToAll"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("NeutralToAll", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.neutralToAllTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["NeutralToAll"].Add(lanceOverride.Copy()); + } - ContractOverrideLanceOverrideBackup.Add("HostileToAll", new List()); - foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.hostileToAllTeam.lanceOverrideList) { - ContractOverrideLanceOverrideBackup["HostileToAll"].Add(lanceOverride.Copy()); - } + ContractOverrideLanceOverrideBackup.Add("HostileToAll", new List()); + foreach (LanceOverride lanceOverride in MissionControl.Instance.CurrentContract.Override.hostileToAllTeam.lanceOverrideList) { + ContractOverrideLanceOverrideBackup["HostileToAll"].Add(lanceOverride.Copy()); + } - // Objective Overrides - ContractOverrideObjectiveOverrideBackup = new List(); - foreach (ObjectiveOverride objectiveOverride in MissionControl.Instance.CurrentContract.Override.objectiveList) { - ContractOverrideObjectiveOverrideBackup.Add(objectiveOverride.Copy()); + // Objective Overrides + ContractOverrideObjectiveOverrideBackup = new List(); + foreach (ObjectiveOverride objectiveOverride in MissionControl.Instance.CurrentContract.Override.objectiveList) { + ContractOverrideObjectiveOverrideBackup.Add(objectiveOverride.Copy()); + } } } diff --git a/src/Core/MissionControl.cs b/src/Core/MissionControl.cs index c2f9abab..441a8b2c 100644 --- a/src/Core/MissionControl.cs +++ b/src/Core/MissionControl.cs @@ -203,6 +203,7 @@ public void SetContract(Contract contract) { Main.Logger.Log($"[MissionControl] Setting contract '{contract.Name}' for contract type '{contract.ContractTypeValue.Name}'"); CurrentContract = contract; Metrics = new Metrics(); + DataManager.Instance.BackupContractOverriddeData(); if (AllowMissionControl()) { Main.Logger.Log($"[MissionControl] Mission Control IS allowed to run. "); @@ -213,8 +214,6 @@ public void SetContract(Contract contract) { IsMCLoadingFinished = false; - DataManager.Instance.BackupContractOverriddeData(); - SetActiveAdditionalLances(contract); Main.Logger.Log($"[MissionControl] Contract map is '{contract.mapName}'"); ContractMapName = contract.mapName; From 278b2d75afaafe9f20f67b21cf2faee6db69fc43 Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Mon, 24 Oct 2022 09:16:10 +0200 Subject: [PATCH 2/2] Version bump --- mod.json | 2 +- src/MissionControl.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod.json b/mod.json index 7111dbf9..202afe94 100644 --- a/mod.json +++ b/mod.json @@ -1,7 +1,7 @@ { "Name": "Mission Control", "Enabled": true, - "Version": "1.5.0", + "Version": "1.5.1", "Description": "A HBS BattleTech mod that adds custom contract types and varies the encounter specifics such as encounter boundary size, spawn locations, lance numbers and objectives", "Author": "CWolf", "Contact": "cwolfs@gmail.com", diff --git a/src/MissionControl.csproj b/src/MissionControl.csproj index ae1ff44b..656b87ed 100644 --- a/src/MissionControl.csproj +++ b/src/MissionControl.csproj @@ -1,6 +1,6 @@ - 1.5.0 + 1.5.1 Library net471