diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/FPCalc.cs b/ConfusedPolarBear.Plugin.IntroSkipper/FPCalc.cs index 01eb919..565a307 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/FPCalc.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/FPCalc.cs @@ -14,6 +14,11 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper; /// public static class FPCalc { + /// + /// Minimum fpcalc version that can be used. + /// + private static Version minimumFPCalcVersion = new Version(1, 4, 3); + /// /// Gets or sets the logger. /// @@ -27,9 +32,29 @@ public static class FPCalc { try { - var version = GetOutput("-version", 2000); - Logger?.LogDebug("fpcalc version: {Version}", version); - return version.StartsWith("fpcalc version", StringComparison.OrdinalIgnoreCase); + var rawVersion = GetOutput("-version", 2000).TrimEnd(); + if (!rawVersion.StartsWith("fpcalc version", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + Logger?.LogDebug("raw fpcalc version: {Version}", rawVersion); + + var version = Version.Parse(rawVersion.AsSpan(15)); + + Logger?.LogDebug("Found fpcalc version {Version}", version); + + var okay = version >= minimumFPCalcVersion; + + if (!okay) + { + Logger?.LogError( + "installed fpcalc version of {Version} is too old (minimum is {Minimum})", + version, + minimumFPCalcVersion); + } + + return okay; } catch {