diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:41:02 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 22:41:02 -0500 |
| commit | db51b7d3f999ab57898cf039f8289d807b63523c (patch) | |
| tree | 19207693ca0e6e6572bbd89711ea87be4005d5b1 /runtime/src/main.cpp | |
| parent | d0835dd9f9ec0a88faee510126436f2427854c2e (diff) | |
Mods: mod.json manifests with archetype swaps, and the Mandy prison-intro mod
gta6rt reads mods/<folder>/mod.json next to gta6rt.exe (or --mods DIR), checks each and logs it. An archetype swap
names two models the game has (by joaat name or 0x hash): when the game asks for `from` it gets `to`. The swaps
are loaded into leonida::mods::active(); they apply once the game's archetype lookup is hooked, which needs the
executable's address for it (docs/modding.md, Day one).
mods/mandy_prison_intro swaps Lucia's player model player_story000_00 (0xE472B687) for cs_mandy (0xD7C0CDFF), the
ids measured in the packs tables; mods_test checks joaat reproduces both. Conditions narrower than "always" are
refused until a hook provides mission state. No game data in either.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 49917bf18..ff15ec451 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <vector> | 26 | #include <vector> |
| 27 | 27 | ||
| 28 | #include "base_reservation.h" | 28 | #include "base_reservation.h" |
| 29 | #include "mods.h" | ||
| 29 | #include "pe_loader.h" | 30 | #include "pe_loader.h" |
| 30 | #include "../shims/d3d12_trace.h" | 31 | #include "../shims/d3d12_trace.h" |
| 31 | #include "../shims/file_system.h" | 32 | #include "../shims/file_system.h" |
| @@ -46,16 +47,16 @@ const char* binding_name(rt::Binding b) { | |||
| 46 | 47 | ||
| 47 | int usage() { | 48 | int usage() { |
| 48 | std::fprintf(stderr, | 49 | std::fprintf(stderr, |
| 49 | "usage: gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR] [--trace FILE]\n" | 50 | "usage: gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR] [--mods DIR] [--trace FILE]\n" |
| 50 | " gta6rt --init <image> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [--trace FILE]\n" | 51 | " gta6rt --init <image> [--game-dir DIR] [--overlay DIR] [--mods DIR] [--trace-d3d12] [--trace FILE]\n" |
| 51 | " gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [--trace FILE] [-- game arguments...]\n"); | 52 | " gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--mods DIR] [--trace-d3d12] [--trace FILE] [-- game arguments...]\n"); |
| 52 | return 2; | 53 | return 2; |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | } // namespace | 56 | } // namespace |
| 56 | 57 | ||
| 57 | int wmain(int argc, wchar_t** argv) { | 58 | int wmain(int argc, wchar_t** argv) { |
| 58 | std::filesystem::path image, game_dir, overlay_dir; | 59 | std::filesystem::path image, game_dir, overlay_dir, mods_dir; |
| 59 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; | 60 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; |
| 60 | std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84) | 61 | std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84) |
| 61 | std::wstring trace_file; | 62 | std::wstring trace_file; |
| @@ -72,6 +73,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 72 | else if (a == L"--trace" && i + 1 < argc) trace_file = argv[++i]; | 73 | else if (a == L"--trace" && i + 1 < argc) trace_file = argv[++i]; |
| 73 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; | 74 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; |
| 74 | else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; | 75 | else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; |
| 76 | else if (a == L"--mods" && i + 1 < argc) mods_dir = argv[++i]; | ||
| 75 | else if (image.empty()) image = a; | 77 | else if (image.empty()) image = a; |
| 76 | else return usage(); | 78 | else return usage(); |
| 77 | } | 79 | } |
| @@ -95,6 +97,27 @@ int wmain(int argc, wchar_t** argv) { | |||
| 95 | // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package. | 97 | // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package. |
| 96 | if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; | 98 | if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; |
| 97 | rt::fs::configure(game_dir, overlay_dir); | 99 | rt::fs::configure(game_dir, overlay_dir); |
| 100 | // Mods (docs/modding.md): <folder of gta6rt.exe>\mods unless --mods names another. Loaded and reported here; | ||
| 101 | // the archetype swaps take effect once the game's archetype lookup is hooked for this executable version. | ||
| 102 | if (mods_dir.empty()) { | ||
| 103 | std::wstring self(32768, L'\0'); | ||
| 104 | const DWORD n = GetModuleFileNameW(nullptr, self.data(), static_cast<DWORD>(self.size())); | ||
| 105 | if (n && n < self.size()) mods_dir = std::filesystem::path(self.substr(0, n)).parent_path() / L"mods"; | ||
| 106 | } | ||
| 107 | { | ||
| 108 | const leonida::mods::LoadResult mods = leonida::mods::load_mods(mods_dir); | ||
| 109 | for (const std::string& e : mods.errors) std::fprintf(stderr, "[rt] mods: skipped %s\n", e.c_str()); | ||
| 110 | for (const auto& m : mods.mods) { | ||
| 111 | std::fprintf(stderr, "[rt] mods: %s%s\n", m.name.c_str(), m.enabled ? "" : " (disabled)"); | ||
| 112 | for (const auto& sw : m.archetype_swaps) | ||
| 113 | std::fprintf(stderr, "[rt] mods: archetype %s (0x%08X) -> %s (0x%08X)\n", sw.from_name.c_str(), | ||
| 114 | sw.from, sw.to_name.c_str(), sw.to); | ||
| 115 | } | ||
| 116 | leonida::mods::set_active(leonida::mods::ArchetypeSwaps(mods.mods)); | ||
| 117 | if (leonida::mods::active().size()) | ||
| 118 | std::fprintf(stderr, "[rt] mods: %zu archetype swap(s) loaded; not applied yet: the archetype lookup hook " | ||
| 119 | "for this executable is not known (docs/modding.md)\n", leonida::mods::active().size()); | ||
| 120 | } | ||
| 98 | rt::d3d12_trace::set_enabled(trace_d3d12); | 121 | rt::d3d12_trace::set_enabled(trace_d3d12); |
| 99 | if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { | 122 | if (int trace_error = 0; !trace_file.empty() && !rt::startup_trace::open(trace_file.c_str(), &trace_error)) { |
| 100 | std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" | 123 | std::fprintf(stderr, trace_error == EEXIST ? "error: the trace file already exists; --trace only creates a new file\n" |