From 4b6e1c112caa2274e5725d281e9ef9facb5c3bce Mon Sep 17 00:00:00 2001 From: Chris Yeninas <844685+PhantomGamers@users.noreply.github.com> Date: Sat, 15 Jan 2022 00:13:53 -0500 Subject: [PATCH 1/4] fix universe exploration setting --- .../Patches/Dynamic/UIPlanetDetail_Patch.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs index 06535c2b8..90e949b79 100644 --- a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs @@ -9,8 +9,6 @@ namespace NebulaPatcher.Patches.Dynamic [HarmonyPatch(typeof(UIPlanetDetail))] internal class UIPlanetDetail_Patch { - private static int BackupUniverseObserveLevel = -1; - [HarmonyPostfix] [HarmonyPatch(nameof(UIPlanetDetail.OnNameInputEndEdit))] public static void OnNameInputEndEdit_Postfix(UIPlanetDetail __instance) @@ -58,9 +56,8 @@ public static bool _OnUpdate_Prefix(UIPlanetDetail __instance) [HarmonyPatch(nameof(UIPlanetDetail.RefreshDynamicProperties))] public static bool OnPlanetDataSet_Prefix(UIPlanetDetail __instance) { - if(UIRoot.instance.galaxySelect.starmap.clickText != "") + if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby) { - BackupUniverseObserveLevel = GameMain.history.universeObserveLevel; GameMain.history.universeObserveLevel = 3; } return true; @@ -71,11 +68,26 @@ public static bool OnPlanetDataSet_Prefix(UIPlanetDetail __instance) [HarmonyPatch(nameof(UIPlanetDetail.RefreshDynamicProperties))] public static void OnPlanetDataSet_Postfix(UIPlanetDetail __instance) { - if(BackupUniverseObserveLevel != -1) + if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby) + { + GameMain.history.universeObserveLevel = GetUniverseObserveLevel(); + } + } + + private static int GetUniverseObserveLevel() + { + int level = 0; + // the tech ids of the 4 tiers of Universe Exploration from https://dsp-wiki.com/Upgrades + for (int i = 4104; i >= 4101; i--) { - GameMain.history.universeObserveLevel = BackupUniverseObserveLevel; - BackupUniverseObserveLevel = -1; + if(GameMain.history.TechUnlocked(i)) + { + // set level to last digit of tech id - 1 + level = (i % 10) - 1; + break; + } } + return level; } } } From 2545866217f3fd2726fed6cbbab3b147764ca43d Mon Sep 17 00:00:00 2001 From: Chris Yeninas <844685+PhantomGamers@users.noreply.github.com> Date: Sat, 15 Jan 2022 00:15:04 -0500 Subject: [PATCH 2/4] 0.7.10 --- CHANGELOG.md | 3 ++- version.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2376a779d..ca78f17a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ ## Changelog -0.8.0: +0.7.10: - @starfish: Added WarningSystem syncing - @PhantomGamers: Fixed case of NRE when arriving on another planet +- @PhantomGamers: Fixed issue where Universe Exploration tech would break while in a multiplayer game 0.7.9: diff --git a/version.json b/version.json index 9119901d9..eeccf6343 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.7.9", + "version": "0.7.10", "assemblyVersion": { "precision": "build" }, From 99d9f68200f65907434f8334c235f64b5dfef3a4 Mon Sep 17 00:00:00 2001 From: Chris Yeninas <844685+PhantomGamers@users.noreply.github.com> Date: Sat, 15 Jan 2022 00:51:12 -0500 Subject: [PATCH 3/4] fix exploration on already broken saves --- NebulaNetwork/Server.cs | 2 ++ .../Patches/Dynamic/UIPlanetDetail_Patch.cs | 18 +----------------- NebulaWorld/SimulatedWorld.cs | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/NebulaNetwork/Server.cs b/NebulaNetwork/Server.cs index 1844681b5..e26c2e5ae 100644 --- a/NebulaNetwork/Server.cs +++ b/NebulaNetwork/Server.cs @@ -79,6 +79,8 @@ public override void Start() Config.Options.GetMechaColors(), !string.IsNullOrWhiteSpace(Config.Options.Nickname) ? Config.Options.Nickname : GameMain.data.account.userName), loadSaveFile); + + GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel(); NebulaModAPI.OnMultiplayerGameStarted?.Invoke(); } diff --git a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs index 90e949b79..fcc56dd2b 100644 --- a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs @@ -70,24 +70,8 @@ public static void OnPlanetDataSet_Postfix(UIPlanetDetail __instance) { if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby) { - GameMain.history.universeObserveLevel = GetUniverseObserveLevel(); + GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel(); } } - - private static int GetUniverseObserveLevel() - { - int level = 0; - // the tech ids of the 4 tiers of Universe Exploration from https://dsp-wiki.com/Upgrades - for (int i = 4104; i >= 4101; i--) - { - if(GameMain.history.TechUnlocked(i)) - { - // set level to last digit of tech id - 1 - level = (i % 10) - 1; - break; - } - } - return level; - } } } diff --git a/NebulaWorld/SimulatedWorld.cs b/NebulaWorld/SimulatedWorld.cs index 12f42d76d..dc5387306 100644 --- a/NebulaWorld/SimulatedWorld.cs +++ b/NebulaWorld/SimulatedWorld.cs @@ -651,5 +651,21 @@ public void SetPauseIndicator(bool canPause) } } + + public static int GetUniverseObserveLevel() + { + int level = 0; + // the tech ids of the 4 tiers of Universe Exploration from https://dsp-wiki.com/Upgrades + for (int i = 4104; i >= 4101; i--) + { + if (GameMain.history.TechUnlocked(i)) + { + // set level to last digit of tech id - 1 + level = (i % 10) - 1; + break; + } + } + return level; + } } } From acf72f1bfd0558bc2d385ab1d9fe5eb7380f282b Mon Sep 17 00:00:00 2001 From: Chris Yeninas <844685+PhantomGamers@users.noreply.github.com> Date: Sat, 15 Jan 2022 01:41:58 -0500 Subject: [PATCH 4/4] fix universeObserveLevel offset the valid range is 0-4 so we don't need to subtract 1 from the last digit. --- NebulaNetwork/Server.cs | 2 -- NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs | 2 +- NebulaWorld/MultiplayerSession.cs | 5 +++++ NebulaWorld/SimulatedWorld.cs | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NebulaNetwork/Server.cs b/NebulaNetwork/Server.cs index e26c2e5ae..1844681b5 100644 --- a/NebulaNetwork/Server.cs +++ b/NebulaNetwork/Server.cs @@ -79,8 +79,6 @@ public override void Start() Config.Options.GetMechaColors(), !string.IsNullOrWhiteSpace(Config.Options.Nickname) ? Config.Options.Nickname : GameMain.data.account.userName), loadSaveFile); - - GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel(); NebulaModAPI.OnMultiplayerGameStarted?.Invoke(); } diff --git a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs index fcc56dd2b..30293bb93 100644 --- a/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/UIPlanetDetail_Patch.cs @@ -58,7 +58,7 @@ public static bool OnPlanetDataSet_Prefix(UIPlanetDetail __instance) { if(Multiplayer.IsActive && Multiplayer.Session.IsInLobby) { - GameMain.history.universeObserveLevel = 3; + GameMain.history.universeObserveLevel = 4; } return true; } diff --git a/NebulaWorld/MultiplayerSession.cs b/NebulaWorld/MultiplayerSession.cs index cb2075668..05bd574dd 100644 --- a/NebulaWorld/MultiplayerSession.cs +++ b/NebulaWorld/MultiplayerSession.cs @@ -140,6 +140,11 @@ public void OnGameLoadCompleted() Log.Info("Game load completed"); IsGameLoaded = true; + if (Multiplayer.Session.LocalPlayer.IsHost) + { + GameMain.history.universeObserveLevel = SimulatedWorld.GetUniverseObserveLevel(); + } + if (Multiplayer.Session.LocalPlayer.IsInitialDataReceived) { Multiplayer.Session.World.SetupInitialPlayerState(); diff --git a/NebulaWorld/SimulatedWorld.cs b/NebulaWorld/SimulatedWorld.cs index dc5387306..ac91a7967 100644 --- a/NebulaWorld/SimulatedWorld.cs +++ b/NebulaWorld/SimulatedWorld.cs @@ -660,8 +660,8 @@ public static int GetUniverseObserveLevel() { if (GameMain.history.TechUnlocked(i)) { - // set level to last digit of tech id - 1 - level = (i % 10) - 1; + // set level to last digit of tech id + level = (i % 10); break; } }