From 240264c3c50618e4c715db389c3bad1447b320ff Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 21 Jul 2014 22:21:52 +0000 Subject: [PATCH] Since Global.Game is never null now, add a IsNullInstance property to check against instead, and refactor code that checks for null --- BizHawk.Client.EmuHawk/MainForm.cs | 10 +++---- BizHawk.Emulation.Common/Database/GameInfo.cs | 26 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index bba9632136..15c433ed59 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk new AutoResetEvent(false); Icon = Properties.Resources.logo; InitializeComponent(); - Global.Game = GameInfo.GetNullGame(); + Global.Game = GameInfo.NullInstance; if (Global.Config.ShowLogWindow) { LogConsole.ShowConsole(); @@ -312,11 +312,11 @@ namespace BizHawk.Client.EmuHawk ToggleFullscreen(); } - if (cmdLoadState != null && Global.Game != null) + if (cmdLoadState != null && !Global.Game.IsNullInstance) { LoadQuickSave("QuickSave" + cmdLoadState); } - else if (Global.Config.AutoLoadLastSaveSlot && Global.Game != null) + else if (Global.Config.AutoLoadLastSaveSlot && !Global.Game.IsNullInstance) { LoadQuickSave("QuickSave" + Global.Config.SaveSlot); } @@ -1406,7 +1406,7 @@ namespace BizHawk.Client.EmuHawk { var system = string.Empty; - if (Global.Game != null) + if (!Global.Game.IsNullInstance) { system = Global.Game.System; } @@ -3294,7 +3294,7 @@ namespace BizHawk.Client.EmuHawk Global.CoreComm = CreateCoreComm(); CoreFileProvider.SyncCoreCommInputSignals(); Global.Emulator = new NullEmulator(Global.CoreComm); - Global.Game = GameInfo.GetNullGame(); + Global.Game = GameInfo.NullInstance; GlobalWin.Tools.Restart(); diff --git a/BizHawk.Emulation.Common/Database/GameInfo.cs b/BizHawk.Emulation.Common/Database/GameInfo.cs index c6912b0f17..8e953b1f95 100644 --- a/BizHawk.Emulation.Common/Database/GameInfo.cs +++ b/BizHawk.Emulation.Common/Database/GameInfo.cs @@ -45,17 +45,25 @@ namespace BizHawk.Emulation.Common return ret; } - public static GameInfo GetNullGame() + public static GameInfo NullInstance { - return new GameInfo + get { - Name = "Null", - System = "NULL", - Hash = "", - Region = "", - Status = RomStatus.GoodDump, - NotInDatabase = false - }; + return new GameInfo + { + Name = "Null", + System = "NULL", + Hash = "", + Region = "", + Status = RomStatus.GoodDump, + NotInDatabase = false + }; + } + } + + public bool IsNullInstance + { + get { return System == "NULL"; } } internal GameInfo(CompactGameInfo cgi)