upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp13
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())