From 3ed650c0ba93447cf3ebcb3c071be7d177105a52 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 27 Jul 2021 15:17:14 +1000 Subject: [PATCH] And silence the print flood from Database again --- src/BizHawk.Client.EmuHawk/MainForm.cs | 2 +- .../Database/Database.cs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index c41057f60f..7ff9fcad6c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -292,7 +292,7 @@ namespace BizHawk.Client.EmuHawk } //do this threaded stuff early so it has plenty of time to run in background - Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"), warnForCollisions: false); + Database.InitializeDatabase(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb.txt"), silent: true); BootGodDb.Initialize(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb")); Config = config; diff --git a/src/BizHawk.Emulation.Common/Database/Database.cs b/src/BizHawk.Emulation.Common/Database/Database.cs index 94e36124ab..05cfd23255 100644 --- a/src/BizHawk.Emulation.Common/Database/Database.cs +++ b/src/BizHawk.Emulation.Common/Database/Database.cs @@ -38,7 +38,7 @@ namespace BizHawk.Emulation.Common return hash; } - private static void LoadDatabase_Escape(string line, string path, bool warnForCollisions) + private static void LoadDatabase_Escape(string line, string path, bool silent) { if (!line.ToUpperInvariant().StartsWith("#INCLUDE")) { @@ -49,8 +49,8 @@ namespace BizHawk.Emulation.Common var filename = Path.Combine(path, line); if (File.Exists(filename)) { - Util.DebugWriteLine($"loading external game database {line}"); - initializeWork(filename, warnForCollisions); + if (!silent) Util.DebugWriteLine($"loading external game database {line}"); + initializeWork(filename, silent); } else { @@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Common private static bool initialized = false; - private static void initializeWork(string path, bool warnForCollisions) + private static void initializeWork(string path, bool silent) { //reminder: this COULD be done on several threads, if it takes even longer using var reader = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)); @@ -109,7 +109,7 @@ namespace BizHawk.Emulation.Common if (line.StartsWith("#")) { - LoadDatabase_Escape(line, Path.GetDirectoryName(path), warnForCollisions); + LoadDatabase_Escape(line, Path.GetDirectoryName(path), silent); continue; } @@ -144,7 +144,7 @@ namespace BizHawk.Emulation.Common ForcedCore = items.Length >= 8 ? items[7].ToLowerInvariant() : "" }; - if (warnForCollisions && DB.ContainsKey(game.Hash)) + if (!silent && DB.ContainsKey(game.Hash)) { Console.WriteLine("gamedb: Multiple hash entries {0}, duplicate detected on \"{1}\" and \"{2}\"", game.Hash, game.Name, DB[game.Hash].Name); } @@ -160,14 +160,14 @@ namespace BizHawk.Emulation.Common acquire.Set(); } - public static void InitializeDatabase(string path, bool warnForCollisions) + public static void InitializeDatabase(string path, bool silent) { if (initialized) throw new InvalidOperationException("Did not expect re-initialize of game Database"); initialized = true; var stopwatch = Stopwatch.StartNew(); ThreadPool.QueueUserWorkItem(_=> { - initializeWork(path, warnForCollisions); + initializeWork(path, silent); Util.DebugWriteLine("GameDB load: " + stopwatch.Elapsed + " sec"); }); }