Accept .exe binary name on Linux/macOS and fix AlwaysOn battery threshold

build-macos.sh ships the macOS binary as eu07.exe, so IsValidBinaryFile
must accept that extension on non-Windows too. Also fix the AlwaysOn
battery default check to use a proper near-zero epsilon instead of an
overly broad <0.2 threshold that clobbered legitimate low velocities.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Mateusz Włodarczyk
2026-07-06 11:12:32 +02:00
parent 1118771486
commit a3ff2787a7
2 changed files with 5 additions and 3 deletions

View File

@@ -256,8 +256,10 @@ public sealed class Settings
return false;
if (OperatingSystem.IsWindows())
return ext == ".exe";
// Linux / macOS: no extension (eu07) or a known binary suffix
return ext.Length == 0 || ext is ".x86_64" or ".run" or ".appimage";
// Linux / macOS: no extension (eu07), a known binary suffix, or .exe
// (some builds - notably this project's own build-macos.sh - ship the
// macOS binary under the historical "eu07.exe" name).
return ext.Length == 0 || ext is ".exe" or ".x86_64" or ".run" or ".appimage";
}
private static readonly Encoding FileEncoding = ResolveEncoding();

View File

@@ -105,7 +105,7 @@ public partial class MainWindow : Window
trainset.Velocity = Settings.Instance.BatteryDefault switch
{
BatteryDefault.AlwaysOff => 0f,
BatteryDefault.AlwaysOn => trainset.OriginalVelocity < 0.2f ? 0.1f : trainset.OriginalVelocity,
BatteryDefault.AlwaysOn => MathF.Abs(trainset.OriginalVelocity) < 0.01f ? 0.1f : trainset.OriginalVelocity,
_ => trainset.OriginalVelocity
};
}