From dc4d1c1bb1a682a332f91c177f1fd58330dceb03 Mon Sep 17 00:00:00 2001 From: Aleksander Lygren Toppe Date: Tue, 9 Feb 2021 22:21:12 +0100 Subject: [PATCH] Fixes a NPE in onGUI check for game state. Didn't guard some variables that was not initialized under intro guide. Bumps version to 0.4.1 --- MineralExhaustionNotifier/MinerNotificationUI.cs | 13 +++++++++---- .../MineralExhaustionNotifier.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 ++-- MineralExhaustionNotifier/README.md | 3 +++ MineralExhaustionNotifier/changelog.md | 8 ++++++++ MineralExhaustionNotifier/manifest.json | 2 +- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/MineralExhaustionNotifier/MinerNotificationUI.cs b/MineralExhaustionNotifier/MinerNotificationUI.cs index 54f13b5..4bacd7f 100644 --- a/MineralExhaustionNotifier/MinerNotificationUI.cs +++ b/MineralExhaustionNotifier/MinerNotificationUI.cs @@ -92,11 +92,16 @@ private static void Init() public static void OnGUI() { - if (!isInit && GameMain.isRunning) { Init(); } - var uiGame = BGMController.instance.uiGame; - var shouldShowByGameState = !(uiGame.techTree.active || uiGame.dysonmap.active || uiGame.starmap.active || uiGame.escMenu.active || uiGame.hideAllUI0 || uiGame.hideAllUI1) && - DSPGame.GameDesc != null && DSPGame.IsMenuDemo == false && DSPGame.Game.running && (UIGame.viewMode == EViewMode.Normal || UIGame.viewMode == EViewMode.Sail); + var shouldShowByGameState = DSPGame.GameDesc != null && uiGame != null && uiGame.gameData != null && uiGame.guideComplete && DSPGame.IsMenuDemo == false && DSPGame.Game.running && (UIGame.viewMode == EViewMode.Normal || UIGame.viewMode == EViewMode.Sail) && + !(uiGame.techTree.active || uiGame.dysonmap.active || uiGame.starmap.active || uiGame.escMenu.active || uiGame.hideAllUI0 || uiGame.hideAllUI1) && uiGame.gameMenu.active; + + if (!shouldShowByGameState) + { + return; + } + + if (!isInit && GameMain.isRunning) { Init(); } if (Show && shouldShowByGameState) { diff --git a/MineralExhaustionNotifier/MineralExhaustionNotifier.cs b/MineralExhaustionNotifier/MineralExhaustionNotifier.cs index 2eea86a..035ac39 100644 --- a/MineralExhaustionNotifier/MineralExhaustionNotifier.cs +++ b/MineralExhaustionNotifier/MineralExhaustionNotifier.cs @@ -9,7 +9,7 @@ namespace DSPPlugins_ALT { - [BepInPlugin("net.toppe.bepinex.dsp.veinexhaustion", "Mineral Vein Exhaustion Plug-In", "0.4.0.0")] + [BepInPlugin("net.toppe.bepinex.dsp.veinexhaustion", "Mineral Vein Exhaustion Plug-In", "0.4.1.0")] public class MineralExhaustionNotifier : BaseUnityPlugin { public static bool showDialog = true; diff --git a/MineralExhaustionNotifier/Properties/AssemblyInfo.cs b/MineralExhaustionNotifier/Properties/AssemblyInfo.cs index 591f7f7..0c9ce1f 100644 --- a/MineralExhaustionNotifier/Properties/AssemblyInfo.cs +++ b/MineralExhaustionNotifier/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.4.0.0")] -[assembly: AssemblyFileVersion("0.4.0.0")] +[assembly: AssemblyVersion("0.4.1.0")] +[assembly: AssemblyFileVersion("0.4.1.0")] diff --git a/MineralExhaustionNotifier/README.md b/MineralExhaustionNotifier/README.md index 539cc74..94d98f8 100644 --- a/MineralExhaustionNotifier/README.md +++ b/MineralExhaustionNotifier/README.md @@ -36,10 +36,13 @@ If you have cleared out all faulty miners by default this will allow a popup not ### MineralExhaustionNotified v0.4 +* v0.4.1 - Fixes a nullpointer exception when starting a new game. + * Fixed the issue where vein type was none for completely exhausted veins. * Added textures for the resources/veins and for the menu button. * Calculate estimated time until exhaustion for the veins. + ## Verified working with game versions * Dyson Sphere Project 0.6.16.5759 diff --git a/MineralExhaustionNotifier/changelog.md b/MineralExhaustionNotifier/changelog.md index 4237b04..8baab5f 100644 --- a/MineralExhaustionNotifier/changelog.md +++ b/MineralExhaustionNotifier/changelog.md @@ -1,4 +1,12 @@  +## MineralExhaustionNotified v0.4.1 + +* Fixes a nullpointer exception when starting a new game. + +### Commit log from 'v0.4' to 'v0.4.1' (most recent changes are listed on top): +e18721e Fixes a NPE in onGUI check for game state. Didn't guard some variables that was not initialized under intro guide. Bumps version to 0.4.1 + + ## MineralExhaustionNotified v0.4 * Fixed the issue where vein type was none for completely exhausted veins. diff --git a/MineralExhaustionNotifier/manifest.json b/MineralExhaustionNotifier/manifest.json index 7c770fe..f65ebd3 100644 --- a/MineralExhaustionNotifier/manifest.json +++ b/MineralExhaustionNotifier/manifest.json @@ -1,6 +1,6 @@ { "name": "MineralExhaustionNotifier", - "version_number": "0.4.0", + "version_number": "0.4.1", "website_url": "https://github.com/alekslt/DSPPlugins_ALT/tree/master/MineralExhaustionNotifier", "description": "Tracks miners with problem conditions and shows you a information window with location, problem, and more.", "dependencies": [