From 09c57cf86e8d91930c97e0887334d6796f3690e5 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:25:29 +0200 Subject: [PATCH] cleanup ICycleTiming header value setting notably don't unset the ClockRate just because the current cycle count is invalid --- src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs | 14 +++++--------- src/BizHawk.Client.EmuHawk/MainForm.Movie.cs | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index 8ac524dde6..32977a366e 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -51,19 +51,15 @@ namespace BizHawk.Client.Common public void SetCycleValues() //TODO IEmulator should not be an instance prop of movies, it should be passed in to every call (i.e. from MovieService) --yoshi { // The saved cycle value will only be valid if the end of the movie has been emulated. - if (this.IsAtEnd()) + if (this.IsAtEnd() && Emulator.AsCycleTiming() is { } cycleCore) { - var cycleCore = Emulator.AsCycleTiming(); - if (cycleCore != null) - { - Header[HeaderKeys.CycleCount] = cycleCore.CycleCount.ToString(); - Header[HeaderKeys.ClockRate] = cycleCore.ClockRate.ToString(CultureInfo.InvariantCulture); - } + // legacy movies may incorrectly have no ClockRate header value set + Header[HeaderKeys.ClockRate] = cycleCore.ClockRate.ToString(NumberFormatInfo.InvariantInfo); + Header[HeaderKeys.CycleCount] = cycleCore.CycleCount.ToString(); } else { - Header.Remove(HeaderKeys.CycleCount); - Header.Remove(HeaderKeys.ClockRate); + Header.Remove(HeaderKeys.CycleCount); // don't allow invalid cycle count fields to stay set } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs index e3bbcd687d..dcf0e287f3 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Globalization; using System.Windows.Forms; using BizHawk.Client.Common; @@ -279,8 +280,7 @@ namespace BizHawk.Client.EmuHawk if (Emulator.HasCycleTiming()) { - movie.HeaderEntries.Add(HeaderKeys.CycleCount, "0"); - movie.HeaderEntries.Add(HeaderKeys.ClockRate, "0"); + movie.HeaderEntries.Add(HeaderKeys.ClockRate, Emulator.AsCycleTiming().ClockRate.ToString(NumberFormatInfo.InvariantInfo)); } } }