This commit is contained in:
2026-08-11 20:11:23 +02:00
parent 4c7592582c
commit bc9bb8e862
4 changed files with 27 additions and 48 deletions
+2 -2
View File
@@ -55,8 +55,8 @@ The console launcher is meant for browsing a games directory and can launch ZIP
- Only display subfolders and ZIP files; ignore other file types and hidden files. - Only display subfolders and ZIP files; ignore other file types and hidden files.
- Navigation and control exclusively with these keys: - Navigation and control exclusively with these keys:
- Arrow down/up: scroll by single entries - Arrow down/up: scroll by single entries
- Enter: open folder or launch ZIP with Hatari - Enter / RightArrow: open folder or launch ZIP with Hatari
- Backspace: jump to parent directory (never outside root) - Backspace / LeftArrow: jump to parent directory (never outside root)
- ESC: exit the program - ESC: exit the program
- PageUp/PageDown: jump by one page up/down through the file list - PageUp/PageDown: jump by one page up/down through the file list
- `?`: show a help box with key bindings - `?`: show a help box with key bindings
+12 -46
View File
@@ -2,56 +2,19 @@
## Critical Bugs ## Critical Bugs
### 1. ArgsTemplate `{cfg}` placeholder not handled when ConfigFile is empty _No open critical bugs._
**Location**: `HatariLauncher.cs:36`
**Problem**: If `Hatari.ConfigFile` is empty string (allowed per config) but `ArgsTemplate` contains `{cfg}`, the replacement produces `-c "" --disk-a "path"` which Hatari may reject.
**Fix**: Conditionally remove `-c "{cfg}"` when `_cfgPath` is empty, or validate template matches config.
### 2. `MenuRenderer.RedrawEntry()` potential crash on console resize
**Location**: `MenuRenderer.cs:67-98`
**Problem**: If console resizes smaller since last draw, `row` parameter may exceed new `availableLines`. The `else` branch writes directly via `WriteConsoleLine` without bounds checking against actual console height, risking `ArgumentOutOfRangeException` on `Console.SetCursorPosition`.
**Fix**: Validate `row < Console.WindowHeight` before writing, or clamp to valid range.
## Medium Bugs ## Medium Bugs
### 3. `HatariLauncher` constructor doesn't validate `ArgsTemplate` _No open medium bugs._
**Location**: `HatariLauncher.cs:12-24`
**Problem**: Constructor validates `exePath` existence but allows empty/null `argsTemplate`. `Launch()` will fail at runtime with empty string replace. Defense-in-depth validation missing.
**Fix**: Add `if (string.IsNullOrWhiteSpace(argsTemplate) || !argsTemplate.Contains("{zip}")) throw ...;`
### 4. ZIP launch doesn't validate file exists on disk
**Location**: `InputController.cs:185-196`
**Problem**: `PatchPath` or `RootPath` used directly without checking `File.Exists()`. Overlay logic should prevent this, but no defense-in-depth.
**Fix**: Validate `File.Exists(zipToLaunch)` before calling `_hatariLauncher.Launch()`.
## Documentation Inconsistencies ## Documentation Inconsistencies
### 5. `Hatari.ConfigFile` required status unclear _No open documentation inconsistencies._
**Location**: `README.md:96` vs `LauncherApp.cs:67-68`
**Conflict**: README marks `Hatari.ConfigFile` as required (✅). Code allows empty string and only validates if non-empty. If template uses `{cfg}` but ConfigFile empty → broken args.
**Resolution**: ConfigFile is now optional. When empty, the bundled `MarcerGameDvd-Hatari.cfg` (shipped in the release) is used automatically. README updated to reflect this. ✅ Fixed
### 6. `RightArrow` key binding missing from AGENTS.md requirements
**Location**: `AGENTS.md:57-58` vs `InputController.cs:172-173`
**Conflict**: AGENTS.md lists only Arrow up/down, Enter, Backspace, ESC, PageUp/Down, `?`. Code also handles `ConsoleKey.RightArrow` as alias for Enter (open folder/launch ZIP). README correctly documents it.
**Resolution**: Update AGENTS.md to include RightArrow.
### 7. `ShowModalUntilReturnReleased` race condition on resize
**Location**: `ProgramHelpers.cs:62-98`
**Problem**: Captures `lastRow = AvailableLines` at start. If console resizes during the modal wait loop, the clear writes to stale row position.
**Fix**: Re-read `AvailableLines` before clearing, or lock console during modal (not easily possible).
## Code Quality / Minor ## Code Quality / Minor
### 8. `ProgramHelpers.ShowConsoleMessage` signature could use `params` _No open code quality issues._
**Location**: `ProgramHelpers.cs:110`
**Current**: `public static void ShowConsoleMessage(string[] lines, ...)`
**Called as**: `ShowConsoleMessage([...], ...)` (collection expression)
**Suggestion**: Change to `params string[] lines` for more idiomatic usage.
### 9. `OverlayDirectoryBrowser` patch path computation order
**Location**: `OverlayDirectoryBrowser.cs:47-50`
**Observation**: Path traversal protection (`IsSubPathOf`) runs after `Path.Combine` but before `Directory.Exists`. Logic appears correct, but worth verifying with `rel` containing `..` when patch layer enabled.
--- ---
@@ -68,13 +31,16 @@
| `Hatari.ConfigFile` optional with bundled fallback | ✅ Done | Empty ConfigFile falls back to bundled `MarcerGameDvd-Hatari.cfg` | | `Hatari.ConfigFile` optional with bundled fallback | ✅ Done | Empty ConfigFile falls back to bundled `MarcerGameDvd-Hatari.cfg` |
| `FavoritesService.Save()` swallow comment | ✅ Done | Explains intentional behavior | | `FavoritesService.Save()` swallow comment | ✅ Done | Explains intentional behavior |
| `UIErrorService` no-rethrow doc | ✅ Done | Explains design decision | | `UIErrorService` no-rethrow doc | ✅ Done | Explains design decision |
| ArgsTemplate `{cfg}` empty ConfigFile fallback | ✅ Done | `HatariLauncher.Launch()` falls back to bundled config |
| `MenuRenderer.RedrawEntry()` resize bounds check | ✅ Done | Row validated against `availableLines` + `Console.WindowHeight`, catch in `WriteConsoleLine` |
| `HatariLauncher` ArgsTemplate validation | ✅ Done | Constructor validates both `{zip}` and `{cfg}` placeholders |
| ZIP launch file existence check | ✅ Done | `File.Exists` defense-in-depth in `InputController` |
| `RightArrow`/`LeftArrow` in AGENTS.md | ✅ Done | Added to key bindings |
| `OverlayDirectoryBrowser` path traversal | ✅ Non-issue | `..` segments filtered at entry, `IsSubPathOf` as additional safety net |
| `ShowConsoleMessage` params overload | ✅ Done | Added convenience overload with flat argument list |
--- ---
## Priority Recommendation ## Priority Recommendation
1. **Fix #1 (ArgsTemplate `{cfg}`)** - ✅ Fixed: empty ConfigFile now falls back to bundled config All identified issues have been resolved. See the Fixed table above for details.
2. **Fix #2 (RedrawEntry bounds)** - Potential crash on resize
3. **Fix #3 (HatariLauncher validation)** - ✅ Done (per BUGS.md Fixed table)
4. **Fix #4 (ZIP path validation)** - User-facing robustness
5. **Sync #5 & #6 (docs)** - ✅ Done: ConfigFile documented as optional with fallback
@@ -163,6 +163,13 @@ namespace MarcerGameDvdLauncher
if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[navigationController.SelectedIndex].Kind == EntryKind.Zip) if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[navigationController.SelectedIndex].Kind == EntryKind.Zip)
{ {
string zipToLaunch = _gameEntries[navigationController.SelectedIndex].InPatch ? _gameEntries[navigationController.SelectedIndex].PatchPath : _gameEntries[navigationController.SelectedIndex].RootPath; string zipToLaunch = _gameEntries[navigationController.SelectedIndex].InPatch ? _gameEntries[navigationController.SelectedIndex].PatchPath : _gameEntries[navigationController.SelectedIndex].RootPath;
if (!File.Exists(zipToLaunch))
{
errorService.ShowError($"ZIP file not found: {zipToLaunch}");
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
break;
}
try try
{ {
hatariLauncher.Launch(zipToLaunch); hatariLauncher.Launch(zipToLaunch);
@@ -120,5 +120,11 @@ namespace MarcerGameDvdLauncher
} }
if (waitForKey) Console.ReadKey(intercept: true); if (waitForKey) Console.ReadKey(intercept: true);
} }
// Convenience overload: flate argument list instead of explicit array.
public static void ShowConsoleMessage(params string[] lines)
{
ShowConsoleMessage(lines, ConsoleColor.Gray, clear: true, waitForKey: true);
}
} }
} }