diff options
| author | Shrey Ratna <shreyratna4445@hotmail.com> | 2026-11-23 00:24:49 +0530 |
|---|---|---|
| committer | Shrey Ratna <shreyratna4445@hotmail.com> | 2026-11-23 00:24:49 +0530 |
| commit | a14ddbc63c9bf4b7588ceb024f70cee45959ab9d (patch) | |
| tree | 6c7ccdbc1d42f8d39e453ed82f393d631de0921a /runtime/src/main.cpp | |
| parent | 162821017ea3c286c8bec860f3ff94f037912061 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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 @@ | |||
| 19 | #include <windows.h> | 19 | #include <windows.h> |
| 20 | 20 | ||
| 21 | #include <cstdio> | 21 | #include <cstdio> |
| 22 | #include <filesystem> | ||
| 22 | #include <map> | 23 | #include <map> |
| 23 | #include <string> | 24 | #include <string> |
| 25 | #include <system_error> | ||
| 24 | #include <vector> | 26 | #include <vector> |
| 25 | 27 | ||
| 26 | #include "base_reservation.h" | 28 | #include "base_reservation.h" |
| @@ -76,7 +78,16 @@ int wmain(int argc, wchar_t** argv) { | |||
| 76 | if (image.empty()) return usage(); | 78 | if (image.empty()) return usage(); |
| 77 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. | 79 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. |
| 78 | if (dry_run + init + run != 1) return usage(); | 80 | if (dry_run + init + run != 1) return usage(); |
| 79 | if (game_dir.empty()) game_dir = image.parent_path(); | 81 | // The console folders are fixed once, as absolute paths. A bare image name (`gta6rt --run game.exe` from the |
| 82 | // game folder) has an empty parent path, which left GAME: with no root; and a relative --game-dir or --overlay | ||
| 83 | // would follow the title's later SetCurrentDirectory. If absolute() fails the path stays as given. | ||
| 84 | const auto absolute_or_same = [](const std::filesystem::path& p) { | ||
| 85 | std::error_code ec; | ||
| 86 | std::filesystem::path a = std::filesystem::absolute(p, ec); | ||
| 87 | return ec ? p : a; | ||
| 88 | }; | ||
| 89 | game_dir = game_dir.empty() ? absolute_or_same(image).parent_path() : absolute_or_same(game_dir); | ||
| 90 | if (!overlay_dir.empty()) overlay_dir = absolute_or_same(overlay_dir); | ||
| 80 | // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new | 91 | // An image without relocations whose range this process already uses (arm64 Wine on macOS) runs in a new |
| 81 | // process that has the range reserved from the start (base_reservation.h); that process does not do this again. | 92 | // process that has the range reserved from the start (base_reservation.h); that process does not do this again. |
| 82 | if (!rt::base_reservation::inherited()) | 93 | if (!rt::base_reservation::inherited()) |