From c94c3a6fb1ec66e1f368899d30cf423b3222f9c1 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:01:34 +0200 Subject: [PATCH] Don't generate `LogKey:` in GenerateLogKey this would cause `LogKey:LogKey:...` to get written when setting the value with the result of a GenerateLogKey call. Luckily this was not an issue for us because the reading code indescriminately replaces all occurances of `LogKey` with nothing. --- .../movie/bk2/Bk2LogEntryGenerator.cs | 1 - .../movie/bk2/Bk2Movie.InputLog.cs | 11 ++--------- src/BizHawk.Client.Common/movie/import/SmvImport.cs | 7 ++++--- .../tools/Macros/MacroInput.ButtonSelect.cs | 4 ++-- src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs | 6 +++--- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index a91e029ddb..7c57e4dae7 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -54,7 +54,6 @@ namespace BizHawk.Client.Common public string GenerateLogKey() { var sb = new StringBuilder(); - sb.Append("LogKey:"); foreach (var group in _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0)) { diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs index 9b407f3d49..8cd9a167ec 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs @@ -13,15 +13,8 @@ namespace BizHawk.Client.Common public void WriteInputLog(TextWriter writer) { writer.WriteLine("[Input]"); - if (string.IsNullOrEmpty(LogKey)) - { - var lg = LogGeneratorInstance(Session.MovieController); - writer.WriteLine(lg.GenerateLogKey()); - } - else - { - writer.WriteLine($"LogKey:{LogKey}"); - } + writer.Write("LogKey:"); + writer.WriteLine(string.IsNullOrEmpty(LogKey) ? LogGeneratorInstance(Session.MovieController).GenerateLogKey() : LogKey); foreach (var record in Log) { diff --git a/src/BizHawk.Client.Common/movie/import/SmvImport.cs b/src/BizHawk.Client.Common/movie/import/SmvImport.cs index b6889eb760..28980fde54 100644 --- a/src/BizHawk.Client.Common/movie/import/SmvImport.cs +++ b/src/BizHawk.Client.Common/movie/import/SmvImport.cs @@ -190,9 +190,10 @@ namespace BizHawk.Client.Common.movie.import Result.Movie.HeaderEntries[HeaderKeys.GameName] = gameName; } - var _controllers = new Snes9xControllers(ss); - Result.Movie.LogKey = new Bk2LogEntryGenerator("SNES", new Bk2Controller(_controllers.ControllerDefinition)).GenerateLogKey(); - SimpleController controllers = new(_controllers.ControllerDefinition); + ControllerDefinition definition = new Snes9xControllers(ss).ControllerDefinition; + SimpleController controllers = new(definition); + + Result.Movie.LogKey = new Bk2LogEntryGenerator(VSystemID.Raw.SNES, new Bk2Controller(definition)).GenerateLogKey(); r.BaseStream.Position = firstFrameOffset; /* diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs index 14482020a4..fc7e1cdf1b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs @@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk // Update the selected zone's key var lg = MovieSession.Movie.LogGeneratorInstance(MovieSession.MovieController); string key = lg.GenerateLogKey(); - key = key.Replace("LogKey:", "").Replace("#", ""); + key = key.Replace("#", ""); foreach (var box in _buttonBoxes) { @@ -88,4 +88,4 @@ namespace BizHawk.Client.EmuHawk PositionBoxes(); } } -} \ No newline at end of file +} diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index 0a3cc1fb0f..626ca548fa 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk key = lg.GenerateLogKey(); } - key = key.Replace("LogKey:", "").Replace("#", ""); + key = key.Replace("#", ""); key = key.Substring(startIndex: 0, length: key.Length - 1); // drop last char _inputKey = key; @@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk var logGenerator = movieSession.Movie.LogGeneratorInstance(_controller); logGenerator.GenerateLogEntry(); // Reference and create all buttons. - string movieKey = logGenerator.GenerateLogKey().Replace("LogKey:", "").Replace("#", ""); + string movieKey = logGenerator.GenerateLogKey().Replace("#", ""); movieKey = movieKey.Substring(startIndex: 0, length: movieKey.Length - 1); // drop last char if (key == movieKey) { @@ -238,7 +238,7 @@ namespace BizHawk.Client.EmuHawk _inputKey = readText[0]; var lg = _movieSession.Movie.LogGeneratorInstance(_movieSession.MovieController); string key = lg.GenerateLogKey(); - key = key.Replace("LogKey:", "").Replace("#", ""); + key = key.Replace("#", ""); key = key.Substring(startIndex: 0, length: key.Length - 1); // drop last char string[] emuKeys = key.Split('|'); string[] macroKeys = _inputKey.Split('|');