From f5cbbaf892df078364e70dc26e575abf2291a7d7 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 8 Feb 2017 11:58:16 -0500 Subject: Fix Shiftorium init bugs. --- ShiftOS_TheReturn/Shiftorium.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 06a189f..4e31427 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -191,19 +191,18 @@ namespace ShiftOS.Engine { if (SaveSystem.CurrentSave != null) { - if (SaveSystem.CurrentSave.Upgrades == null) + if (!IsInitiated) Init(); } try { return SaveSystem.CurrentSave.Upgrades[id]; } - catch (Exception ex) + catch { - if(LogOrphanedUpgrades == true) - Console.WriteLine($"WHOA, Developers! Upgrade ID '{id}' is unaccounted for in the Shiftorium.txt resource!"); - return false; + throw new ShiftoriumUpgradeLookupException(id); } + } //LEAVE THIS AS FALSE. The game will set it when the save is loaded. @@ -238,6 +237,16 @@ namespace ShiftOS.Engine List GetDefaults(); } + public class ShiftoriumUpgradeLookupException : Exception + { + public ShiftoriumUpgradeLookupException(string id) : base("A shiftorium upgrade of ID \"" + id + "\" was not found in the system.") + { + ID = id; + } + + public string ID { get; private set; } + } + public class ShiftoriumUpgrade { public string Name { get; set; } -- cgit v1.2.3