From a14ddbc63c9bf4b7588ceb024f70cee45959ab9d Mon Sep 17 00:00:00 2001 From: Shrey Ratna Date: Mon, 23 Nov 2026 00:24:49 +0530 Subject: gta6rt: GAME: and the overlay are absolute, so a bare image name has a game folder `gta6rt --run game.exe`, started from the game folder, set the game folder to the image's parent path, which is empty for a bare name: the run printed `console paths: GAME: -> , writes -> overlay` and every GAME: open failed with ERROR_PATH_NOT_FOUND. A relative --game-dir or --overlay worked only until the title changed its current directory. main.cpp now makes both absolute at startup (keeping the path as given if absolute() fails). New CTest run_tiny_game_dir: tiny_game's opt-in `game-file` check moves its current directory, then reads GAME:\tiny_game_probe.txt; check_game_dir.cmake runs it by bare name and with `--game-dir .`. Without the fix both fail (open errors 3 and 2); with it both pass. Co-Authored-By: Claude Opus 5.5 --- runtime/src/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'runtime/src/main.cpp') diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 06baae387..ae80b5dff 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -19,8 +19,10 @@ #include #include +#include #include #include +#include #include #include "base_reservation.h" @@ -76,7 +78,16 @@ int wmain(int argc, wchar_t** argv) { if (image.empty()) return usage(); // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. if (dry_run + init + run != 1) return usage(); - if (game_dir.empty()) game_dir = image.parent_path(); + // The console folders are fixed once, as absolute paths. A bare image name (`gta6rt --run game.exe` from the + // game folder) has an empty parent path, which left GAME: with no root; and a relative --game-dir or --overlay + // would follow the title's later SetCurrentDirectory. If absolute() fails the path stays as given. + const auto absolute_or_same = [](const std::filesystem::path& p) { + std::error_code ec; + std::filesystem::path a = std::filesystem::absolute(p, ec); + return ec ? p : a; + }; + game_dir = game_dir.empty() ? absolute_or_same(image).parent_path() : absolute_or_same(game_dir); + if (!overlay_dir.empty()) overlay_dir = absolute_or_same(overlay_dir); // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new // process that has the range reserved from the start (base_reservation.h); that process does not do this again. if (!rt::base_reservation::inherited()) -- cgit v1.2.3