From 8a7bfc5395388d84bf536a653d3d1065dd717164 Mon Sep 17 00:00:00 2001 From: John P <7864917+kirklandsig@users.noreply.github.com> Date: Thu, 19 Nov 2026 14:07:24 -0500 Subject: [PATCH 01/12] fix: restore the Halo CE and Halo 2 HUD offsets lost merging #43 Merging master-chief into #43 (after #44) resolved the conflicts in the Halo CE and Halo 2 offset headers by keeping #44's side only, so the per-player HUD's offsets and byte patterns there were dropped while the code using them stayed: master-chief stopped compiling (C2065 'OFFSET_HALO2_PF_HUD_ASPECT_LOCK' in CModule.cpp, and the HUD files). Both blocks are kept now, as the two PRs had them: - offset_halo1.h / patterns_halo1.inc: hud_calculate_point, the HUD viewport bounds and the drawing player (3); - offset_halo2.h / patterns_halo2.inc: the "HUD anchor: Centered" je and global, the drawing player, the HUD view bounds and the offset unit scale (5). Only lines are added; the values and patterns are #43's. Co-Authored-By: Claude Opus 5.5 --- lib/game/inc/1.3528.0.0/offset_halo1.h | 4 ++++ lib/game/inc/1.3528.0.0/offset_halo2.h | 7 +++++++ lib/game/inc/1.3528.0.0/patterns_halo1.inc | 9 +++++++++ lib/game/inc/1.3528.0.0/patterns_halo2.inc | 14 ++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/lib/game/inc/1.3528.0.0/offset_halo1.h b/lib/game/inc/1.3528.0.0/offset_halo1.h index 9edb083..0aa7e91 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo1.h +++ b/lib/game/inc/1.3528.0.0/offset_halo1.h @@ -82,3 +82,7 @@ DefOffset(OFFSET_HALO1_PV_FIRST_PERSON_MODELS, 0x2B050E8) // the renderer's firs DefOffset(OFFSET_HALO1_PF_OBJECT_HIDDEN_VIEWS, 0xAB2890) // int (int object) - views (bits 0, 1) the object is hidden in DefOffset(OFFSET_HALO1_PF_DIRECTOR_CAMERA_MODE, 0xB14EA4) // short (int local) - 0 in first person DefOffset(OFFSET_HALO1_PV_HIDDEN_OBJECT_CAMERA, 0x1B87A20) // bool on, int16 mode at +2 (2 hides), int object at +0x34 +// Per-player HUD (mcc/hud, module/entry/halo1/hud.cpp) +DefOffset(OFFSET_HALO1_PF_HUD_CALCULATE_POINT, 0xB56A58) // (player, placement, header, -, bool, float, short2* out, int mcc element) +DefOffset(OFFSET_HALO1_PV_HUD_VIEWPORT_BOUNDS, 0x29AF2F0) // int16 top, left, bottom, right of the view being drawn +DefOffset(OFFSET_HALO1_PV_HUD_DRAWING_PLAYER, 0x29AF2B8) // int16 local player whose HUD is being drawn diff --git a/lib/game/inc/1.3528.0.0/offset_halo2.h b/lib/game/inc/1.3528.0.0/offset_halo2.h index ce8f599..8ed2b12 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo2.h +++ b/lib/game/inc/1.3528.0.0/offset_halo2.h @@ -81,3 +81,10 @@ DefOffset(OFFSET_HALO2_PV_FIRST_PERSON_MODELS, 0x1AB11C0) // entries*, int count DefOffset(OFFSET_HALO2_PV_MODEL_LEVELS, 0x1DC36F0) // unsigned char* detail levels, int count at +8 - the current one is the last DefOffset(OFFSET_HALO2_PF_SABER_OBJECT_SHOW, 0x69C30) // void (object*) DefOffset(OFFSET_HALO2_PF_SABER_OBJECT_HIDE, 0x69CA0) // void (object*) +// Per-player HUD (mcc/hud). With "HUD anchor: Centered" on a screen wider than 16:9, 0x954DD0 insets the whole-screen +// HUD frame to a centred 16:9 box, which 0x7E0A40 splits among the players. +DefOffset(OFFSET_HALO2_PF_HUD_ASPECT_LOCK, 0x954DF2) // je (74 3C) that skips the centred 16:9 HUD frame when the profile's aspect lock is off +DefOffset(OFFSET_HALO2_PV_HUD_ASPECT_LOCK, 0x197EE40) // bool: the profiles' LockMaxAspectRatio ("HUD anchor: Centered"), the last loaded wins +DefOffset(OFFSET_HALO2_PV_HUD_DRAWING_PLAYER, 0x165C398) // int local player whose HUD is being drawn +DefOffset(OFFSET_HALO2_PV_HUD_VIEW_BOUNDS, 0x165C298) // int16 top, left, bottom, right of that player's HUD (window bounds) +DefOffset(OFFSET_HALO2_PV_HUD_UNIT_SCALE, 0xE14F28) // float: pixels per HUD offset unit (times the element's scale) diff --git a/lib/game/inc/1.3528.0.0/patterns_halo1.inc b/lib/game/inc/1.3528.0.0/patterns_halo1.inc index ba65819..f54f4d4 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo1.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo1.inc @@ -208,4 +208,13 @@ const OffsetPatterns kHalo1Patterns[] = { {&OFFSET_HALO1_PV_HIDDEN_OBJECT_CAMERA, 0x1b87a20, Data, { Rel("40 88 35 ?? ?? ?? ?? 48 81 C3 F8 00 00 00 C6 05 ?? ?? ?? ?? 01 66 83 FF 04", 0x3, 0x7, 0x0), Rel("80 3D ?? ?? ?? ?? 00 74 ?? B8 02 00 00 00 66 39 05 ?? ?? 0D 01 75 ?? 44 39 0D", 0x2, 0x7, 0x0)}}, + {&OFFSET_HALO1_PF_HUD_CALCULATE_POINT, 0xb56a58, Code, { + At("48 8B C4 48 89 58 18 48 89 70 20 55 57 41 55 41 56", 0x0), + Rel("E8 ?? ?? ?? ?? 0F B7 45 E2 66 89 45 D2 0F B7 C3 66 03 45 4A", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PV_HUD_VIEWPORT_BOUNDS, 0x29af2f0, Data, { + Rel("0F BF 05 ?? ?? ?? ?? F3 0F 59 D7 0F 5B C0 66 0F 6E C8 0F 5B C9", 0x3, 0x7, 0x0), + Rel("44 0F B7 35 ?? ?? ?? ?? 41 0F B7 F4 8A 84 04 D8 00 00 00 FE C8", 0x4, 0x8, 0x0)}}, + {&OFFSET_HALO1_PV_HUD_DRAWING_PLAYER, 0x29af2b8, Data, { + Rel("0F B7 35 ?? ?? ?? ?? B8 03 00 00 00 66 B9 04 00 66 3B F8 75", 0x3, 0x7, 0x0), + Rel("0F BF 0D ?? ?? ?? ?? 89 4D 67 48 8B C8 48 C1 E9 10 48 89 45 6F", 0x3, 0x7, 0x0)}}, }; diff --git a/lib/game/inc/1.3528.0.0/patterns_halo2.inc b/lib/game/inc/1.3528.0.0/patterns_halo2.inc index 5e7b6a9..8444359 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo2.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo2.inc @@ -153,4 +153,18 @@ const OffsetPatterns kHalo2Patterns[] = { {&OFFSET_HALO2_PF_SABER_OBJECT_HIDE, 0x69ca0, Code, { At("4C 8B C1 48 85 C9 74 58 44 8B 49 0C 41 F6 C1 01 74", 0x0), Rel("E8 ?? ?? ?? ?? 45 84 E4 0F 84 ?? ?? ?? ?? 48 8B 43 08 48 85 C0 74 ?? 48 8B 00", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO2_PF_HUD_ASPECT_LOCK, 0x954df2, Code, { + At("74 3C F3 0F 10 15 ?? ?? ?? ?? 66 0F 6E CF 66 0F 6E C3 0F 5B C9", 0x0)}}, + {&OFFSET_HALO2_PV_HUD_ASPECT_LOCK, 0x197ee40, Data, { + Rel("88 05 ?? ?? ?? ?? 48 8B 01 FF 50 60 8B 54 24 54 8B 4C 24 50", 0x2, 0x6, 0x0), + Rel("38 15 ?? ?? ?? ?? 44 0F B7 C2 74 ?? F3 0F 10 15 ?? ?? ?? ?? 66 0F 6E CF 66 0F 6E C3", 0x2, 0x6, 0x0)}}, + {&OFFSET_HALO2_PV_HUD_DRAWING_PLAYER, 0x165c398, Data, { + Rel("8B 0D ?? ?? ?? ?? F3 0F 59 C6 F3 0F 11 44 24 50 F2 0F 10 00", 0x2, 0x6, 0x0), + Rel("48 63 35 ?? ?? ?? ?? 8B CE 48 89 7C 24 60 0F 29 74 24 50 E8", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_HUD_VIEW_BOUNDS, 0x165c298, Data, { + Rel("66 41 F7 D8 48 8B 05 ?? ?? ?? ?? 66 F7 DA 48 89 44 24 50 E8", 0x7, 0xb, 0x0), + Rel("0F BF 15 ?? ?? ?? ?? 41 8B F0 45 8B E1 44 8B DA 41 8B FA 66 0F 6E C8", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_HUD_UNIT_SCALE, 0xe14f28, Data, { + Rel("F3 0F 11 0D ?? ?? ?? ?? 4C 8D 9C 24 A0 04 00 00 49 8B 73 18", 0x4, 0x8, 0x0), + Rel("0F 5B C0 F3 0F 59 05 ?? ?? ?? ?? F3 0F 2C C0 48 83 C4 28 C3", 0x7, 0xb, 0x0)}}, }; From 041ad931bb68e3e484d1b0b6966773c1f7c43104 Mon Sep 17 00:00:00 2001 From: John P <7864917+kirklandsig@users.noreply.github.com> Date: Wed, 7 Oct 2026 12:59:47 -0400 Subject: [PATCH 02/12] feat(offsets): spawning addresses for Halo CE, 2, 3 and ODST The addresses the spawn menus use, as DefOffsets with their byte patterns (gen_patterns.py; values and patterns as in the kirklandsig fork, same 1.3528 build): - Halo CE (11): the console-script compiler the commands come in through, the players array, tag iteration and lookup, object placement, creation, origin and lookup, actor_customize_unit and ai_attach_free; - Halo 2 (14): the console-script compiler, the tag table and names, the map's and the shared map's tag bases, the object headers and memory, object placement, creation and origin, ai_place and the living count; - Halo 3 (4): the tag base, the scenario, ai_place and the loaded-tag test (its tags header and object functions were already here); - ODST (9): the same as Halo 3's. Halo 2's ai_living_count (0x619B10) is a 13-byte thunk no pattern can find again, so the fork left it to the known build. The offset is now the function it jumps to (0x6198E0), which the spawn code calls with the thunk's own arguments (0, null, null). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs --- lib/game/inc/1.3528.0.0/offset_halo1.h | 13 ++++++ lib/game/inc/1.3528.0.0/offset_halo2.h | 19 +++++++++ lib/game/inc/1.3528.0.0/offset_halo3.h | 6 +++ lib/game/inc/1.3528.0.0/offset_halo3odst.h | 11 +++++ lib/game/inc/1.3528.0.0/patterns_halo1.inc | 32 +++++++++++++++ lib/game/inc/1.3528.0.0/patterns_halo2.inc | 41 +++++++++++++++++++ lib/game/inc/1.3528.0.0/patterns_halo3.inc | 12 ++++++ .../inc/1.3528.0.0/patterns_halo3odst.inc | 27 ++++++++++++ 8 files changed, 161 insertions(+) diff --git a/lib/game/inc/1.3528.0.0/offset_halo1.h b/lib/game/inc/1.3528.0.0/offset_halo1.h index 0aa7e91..bf799f1 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo1.h +++ b/lib/game/inc/1.3528.0.0/offset_halo1.h @@ -4,6 +4,7 @@ DefOffset(OFFSET_HALO1_PF_RENDER, 0x1F05B0) DefOffset(OFFSET_HALO1_PF_GAME_START, 0x939D0) // engine game_start(self, manager, game_options) +DefOffset(OFFSET_HALO1_PF_HS_COMPILE, 0xB21470) // compile + run a console script: (const char* text) DefOffset(OFFSET_HALO1_PF_4PLAYERS, 0x67492) DefOffset(OFFSET_HALO1_PF_PAUSE, 0x427978) @@ -11,6 +12,18 @@ DefOffset(OFFSET_HALO1_PF_IDK, 0x85428) DefOffset(OFFSET_HALO1_PV_PLAYER_COUNT, 0x1B7B910) +// spawning (mcc/spawn; found through the retail cheat_spawn_warthog / cheat_all_chars / ai_attach_free script functions) +DefOffset(OFFSET_HALO1_PV_PLAYERS, 0x1C40480) // players data array*, element 0xC20, unit index at +0x64 +DefOffset(OFFSET_HALO1_PF_TAG_ITERATOR_NEXT, 0xA9B43C) // int (tag_iterator*) +DefOffset(OFFSET_HALO1_PF_TAG_GET_NAME, 0xA9B25C) // const char* (int tag) +DefOffset(OFFSET_HALO1_PF_TAG_GET, 0xA9B648) // void* (int tag) - tag definition data +DefOffset(OFFSET_HALO1_PF_OBJECT_PLACEMENT_DATA_NEW, 0xB35EBC) // (data*, int tag, int owner_object) +DefOffset(OFFSET_HALO1_PF_OBJECT_NEW, 0xB35F80) // int (data*) +DefOffset(OFFSET_HALO1_PF_OBJECT_GET_ORIGIN, 0xB37DE0) // (int object, vector3* out) +DefOffset(OFFSET_HALO1_PF_OBJECT_TRY_AND_GET, 0xB389A4) // void* (int object, unsigned type_mask) - object data, or null +DefOffset(OFFSET_HALO1_PF_ACTOR_CUSTOMIZE_UNIT, 0xC01DD0) // (int actor_variant, int unit) - weapon, grenades, colors +DefOffset(OFFSET_HALO1_PF_AI_ATTACH_FREE, 0xBFF120) // (int unit, int actor_variant) - creates an encounterless actor + // Left/Right split screen (mcc/splitscreen/LeftRight) DefOffset(OFFSET_HALO1_PF_SPLIT_GRID, 0xAC4108) // void (int views, int* columns, int* rows) - the window grid, rows first DefOffset(OFFSET_HALO1_PF_SPLIT_WINDOW, 0xAC4154) // void (int view, int views, short rect[4], short copy[4]) - a view's window diff --git a/lib/game/inc/1.3528.0.0/offset_halo2.h b/lib/game/inc/1.3528.0.0/offset_halo2.h index 8ed2b12..21e6617 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo2.h +++ b/lib/game/inc/1.3528.0.0/offset_halo2.h @@ -5,6 +5,7 @@ DefOffset(OFFSET_HALO2_PF_LOAD, 0x4F980) DefOffset(OFFSET_HALO2_PF_GAME, 0x67A220) DefOffset(OFFSET_HALO2_PF_COPY_GAME_OPTIONS, 0x39CE0) // copy_game_options(game_options) +DefOffset(OFFSET_HALO2_PF_HS_COMPILE, 0x6E17C0) // compile a console script: (const char* text, bool) DefOffset(OFFSET_HALO2_PF_ADD_LOCAL_PLAYER, 0x69D2C0)//0x69D290 @@ -30,6 +31,24 @@ DefOffset(OFFSET_HALO2_PF_COOP_CAMPAIGN, 0x6A6320) // bool () - a co-op campaign DefOffset(OFFSET_HALO2_PF_COOP_RESPAWN_ALLOWED, 0x6A5D40) // bool () - not with the Iron skull (11), not on Legendary DefOffset(OFFSET_HALO2_PV_SCENARIO, 0xE6F768) // the loaded scenario*: int starting locations +0x100 +// spawning (mcc/spawn) +DefOffset(OFFSET_HALO2_PV_TAG_INSTANCES, 0x15E4B30) // {u32 group, u32 datum, u32 address, u32 size}[tag count] +DefOffset(OFFSET_HALO2_PV_TAG_COUNT, 0x15E4B60) +DefOffset(OFFSET_HALO2_PV_TAG_NAME_OFFSETS, 0x15E4B68) // int32[tag count] into the name buffer +DefOffset(OFFSET_HALO2_PV_TAG_NAMES, 0x15E4B78) +DefOffset(OFFSET_HALO2_PV_TAG_BASE, 0xE80AB0) // tag block address -> map tag data + address +DefOffset(OFFSET_HALO2_PV_SHARED_TAG_BASE, 0xE80AC0) // addresses with the top bit set are in the shared map +// OFFSET_HALO2_PV_PLAYERS (above): data array (data at +*(+0x48)): 0x224 each, unit +0x2C +DefOffset(OFFSET_HALO2_PV_OBJECTS, 0x18B7398) // object headers: data array of 0xC, object data offset +8 +DefOffset(OFFSET_HALO2_PV_OBJECT_MEMORY, 0x18B7360) // object data = ((pool + 0x57) & ~0xF) + offset +DefOffset(OFFSET_HALO2_PF_OBJECT_GET_ORIGIN, 0x8D6780) // (int object, real_point3d*) +DefOffset(OFFSET_HALO2_PF_OBJECT_PLACEMENT_DATA_NEW, 0x8D8880) // (data* [0xC4], int tag, int owner, void*) +DefOffset(OFFSET_HALO2_PF_OBJECT_NEW, 0x8D79D0) // int (data*) +DefOffset(OFFSET_HALO2_PF_AI_PLACE, 0x618890) // (int ai_index); starting location = (3 << 30) | (squad << 16) | location +// int (int ai_index, short, int*, float*) - living actors; a squad's ai index is its index. ai_living_count (0x619B10) +// is a 13-byte thunk to it with 0, null, null, too generic to find again by pattern. +DefOffset(OFFSET_HALO2_PF_AI_LIVING_COUNT, 0x6198E0) + // Left/Right split screen (mcc/splitscreen/LeftRight) DefOffset(OFFSET_HALO2_PF_SPLIT_GRID, 0x7E09D0) // void (int views, int mode, short grid[2] columns, rows) - mode 1 stacks, others side by side DefOffset(OFFSET_HALO2_PF_SPLIT_CELL, 0x7E0BD0) // void (int view, int views, int mode, short grid[2], short cell[2], short span[2]) diff --git a/lib/game/inc/1.3528.0.0/offset_halo3.h b/lib/game/inc/1.3528.0.0/offset_halo3.h index 0923633..19f3b9c 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo3.h +++ b/lib/game/inc/1.3528.0.0/offset_halo3.h @@ -39,6 +39,12 @@ DefOffset(OFFSET_HALO3_PF_OBJECT_PLACEMENT_DATA_NEW, 0x341508) // (data*, int ta DefOffset(OFFSET_HALO3_PF_OBJECT_NEW, 0x341AE8) // int (data*) DefOffset(OFFSET_HALO3_PF_OBJECT_POST_CREATE, 0x1EA04) // (int object) - called by the engine after object_new +// spawning (mcc/spawn), with the three above and OFFSET_HALO3_PV_TAGS_HEADER / OFFSET_HALO3_PV_TAG_NAMES +DefOffset(OFFSET_HALO3_PV_TAG_BASE, 0x1FCF4C8) // tag data = base + (instance address << 2) +DefOffset(OFFSET_HALO3_PV_SCENARIO, 0xA46A08) // scenario tag data* +DefOffset(OFFSET_HALO3_PF_AI_PLACE, 0x577AA4) // (int ai_index, bool) - ai_scripting_place_internal +DefOffset(OFFSET_HALO3_PF_TAG_LOADED, 0x12C9EC) // bool (int tag): in the loaded zone set (object_new refuses others) + // c_splitscreen_config::m_config_table; the black-bar patches rewrite entries 8, 9 and 12 (0x8AE150, 0x8AE164, 0x8AE1A0) DefOffset(OFFSET_HALO3_PV_SPLITSCREEN_TABLE, 0x8AE0B0)//0x8AD0C0 diff --git a/lib/game/inc/1.3528.0.0/offset_halo3odst.h b/lib/game/inc/1.3528.0.0/offset_halo3odst.h index 01af1a4..68d5d5e 100644 --- a/lib/game/inc/1.3528.0.0/offset_halo3odst.h +++ b/lib/game/inc/1.3528.0.0/offset_halo3odst.h @@ -16,6 +16,17 @@ DefOffset(OFFSET_HALO3ODST_PF_ADD_LOCAL_PLAYER, 0xFBFE4)//0xFBEE4 #define OFFSET_HALO3ODST_V_ENTRY_PLAYERS 0x2 #define OFFSET_HALO3ODST_V_ENTRY_PLAYERS_ACTION 0xB +// spawning (mcc/spawn; the Halo 3 functions and globals of the same names, matched by signature and call order) +DefOffset(OFFSET_HALO3ODST_PV_TAGS_HEADER, 0x20F3068) +DefOffset(OFFSET_HALO3ODST_PV_TAG_BASE, 0x2022AA8) +DefOffset(OFFSET_HALO3ODST_PV_TAG_NAMES, 0xA9EFC8) +DefOffset(OFFSET_HALO3ODST_PV_SCENARIO, 0xA9C9B8) +DefOffset(OFFSET_HALO3ODST_PF_OBJECT_PLACEMENT_DATA_NEW, 0x37C954) +DefOffset(OFFSET_HALO3ODST_PF_OBJECT_NEW, 0x37CF34) +DefOffset(OFFSET_HALO3ODST_PF_OBJECT_POST_CREATE, 0x20B80) +DefOffset(OFFSET_HALO3ODST_PF_AI_PLACE, 0x5BE6A0) // (int ai_index, bool); ai index type 4 = a squad's single location +DefOffset(OFFSET_HALO3ODST_PF_TAG_LOADED, 0x14D4C8) // bool (int tag): in the loaded zone set (object_new refuses others) + // c_splitscreen_config::m_config_table; the black-bar patches rewrite entries 8, 9 and 12 (0x8F1FB0, 0x8F1FC4, 0x8F2000) DefOffset(OFFSET_HALO3ODST_PV_SPLITSCREEN_TABLE, 0x8F1F10)//0x8F1F20 diff --git a/lib/game/inc/1.3528.0.0/patterns_halo1.inc b/lib/game/inc/1.3528.0.0/patterns_halo1.inc index f54f4d4..bed06e3 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo1.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo1.inc @@ -7,6 +7,9 @@ const OffsetPatterns kHalo1Patterns[] = { At("40 57 48 83 EC 40 48 C7 44 24 20 FE FF FF FF 48 89 5C 24 50 48 89 6C 24 60 48 89 74 24 68 8B F2", 0x0)}}, {&OFFSET_HALO1_PF_GAME_START, 0x939d0, Code, { At("40 53 56 57 48 81 EC 50 02 00 00 48 8B 05 ?? ?? ?? ?? 48 33 C4", 0x0)}}, + {&OFFSET_HALO1_PF_HS_COMPILE, 0xb21470, Code, { + At("48 89 5C 24 10 48 89 74 24 18 57 48 81 EC 40 04 00 00", 0x0), + Rel("66 89 0D ?? ?? 22 02 48 8B CA 66 89 05 ?? ?? 22 02 E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? 00", 0x12, 0x16, 0x0)}}, {&OFFSET_HALO1_PF_4PLAYERS, 0x67492, Code, { At("85 C0 75 11 C7 05 ?? ?? ?? ?? 04 00 00 00 48 89 35 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? 01", 0x2)}}, {&OFFSET_HALO1_PF_PAUSE, 0x427978, Code, { @@ -16,6 +19,35 @@ const OffsetPatterns kHalo1Patterns[] = { {&OFFSET_HALO1_PV_PLAYER_COUNT, 0x1b7b910, Data, { Rel("0F BF 15 ?? ?? ?? ?? 45 33 FF 48 63 F8 45 8D 77 01 41 2B D6", 0x3, 0x7, 0x0), Rel("0F B7 05 ?? ?? ?? ?? 66 89 81 24 01 00 00 0F B7 8A 58 01 00 00", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO1_PV_PLAYERS, 0x1c40480, Data, { + Rel("48 8B 05 ?? ?? ?? ?? 83 4D FC FF 48 89 45 F0 66 89 7D F8 EB", 0x3, 0x7, 0x0), + Rel("48 8B 35 ?? ?? ?? ?? 33 DB 0F 1F 80 00 00 00 00 44 0F B7 46 22", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO1_PF_TAG_ITERATOR_NEXT, 0xa9b43c, Code, { + At("48 8B 05 ?? ?? ?? ?? 83 CA FF 44 0F BF 41 08 4C 8B C9 44 8B 58 0C", 0x0), + Rel("C7 44 24 68 74 69 6E 75 E8 ?? ?? ?? ?? 41 BE 08 00 00 00 EB", 0x9, 0xd, 0x0)}}, + {&OFFSET_HALO1_PF_TAG_GET_NAME, 0xa9b25c, Code, { + At("48 8B 05 ?? ?? ?? ?? 48 0F BF D1 48 C1 E2 05 48 63 4C 02 10", 0x0), + Rel("E8 ?? ?? ?? ?? 48 89 46 50 48 8B CE 41 0F 10 80 80 00 00 00", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_TAG_GET, 0xa9b648, Code, { + At("48 8B 05 ?? ?? ?? ?? 48 0F BF D1 48 C1 E2 05 48 63 4C 02 14", 0x0), + Rel("E8 ?? ?? ?? ?? 4C 8B C0 41 8B D2 48 63 80 E8 02 00 00 85 C0", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_OBJECT_PLACEMENT_DATA_NEW, 0xb35ebc, Code, { + At("48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 41 8B F0 8B DA", 0x0), + Rel("E8 ?? ?? ?? ?? F2 41 0F 10 45 00 F2 0F 11 45 A3 41 8B 45 08", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_OBJECT_NEW, 0xb35f80, Code, { + At("48 83 EC 28 8A 05 ?? ?? ?? ?? 4C 8B C9 F6 D8 45 1B C0 41 83 E0 04", 0x0), + Rel("F3 0F 11 55 B4 E8 ?? ?? ?? ?? 41 83 CB FF 8B D8 41 3B C3 0F 84", 0x6, 0xa, 0x0)}}, + {&OFFSET_HALO1_PF_OBJECT_GET_ORIGIN, 0xb37de0, Code, { + At("48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 20 48 8B 35 ?? ?? ?? ?? 4C 8B D2", 0x0), + Rel("E8 ?? ?? ?? ?? F3 0F 10 06 F3 0F 5C 44 24 20 F3 0F 10 4E 04", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_OBJECT_TRY_AND_GET, 0xb389a4, Code, { + At("40 53 48 83 EC 20 8B DA 8B D1 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 4C 8B D8 33 C0 4D 85 DB 74 ?? 41 0F B6 4B 03", 0x0), + Rel("E8 ?? ?? ?? ?? 83 C9 FF 48 85 C0 0F 45 CB 8B C1 48 83 C4 20", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_ACTOR_CUSTOMIZE_UNIT, 0xc01dd0, Code, { + At("48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 81 EC 10 01 00 00", 0x0), + Rel("E8 ?? ?? ?? ?? 8B 06 B9 02 00 00 00 44 88 7C 24 58 45 8B CE", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO1_PF_AI_ATTACH_FREE, 0xbff120, Code, { + At("48 83 EC 68 48 8B 05 ?? ?? ?? ?? 41 BB 02 00 00 00 44 8B C2", 0x0)}}, {&OFFSET_HALO1_PF_SPLIT_GRID, 0xac4108, Code, { At("48 89 5C 24 08 BB 01 00 00 00 4D 8B D8 44 8B CB", 0x0), Rel("E8 ?? ?? ?? ?? 44 8B 5C 24 58 41 8B C3 0F AF 44 24 50 3B C3", 0x1, 0x5, 0x0)}}, diff --git a/lib/game/inc/1.3528.0.0/patterns_halo2.inc b/lib/game/inc/1.3528.0.0/patterns_halo2.inc index 8444359..b8c873b 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo2.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo2.inc @@ -12,6 +12,9 @@ const OffsetPatterns kHalo2Patterns[] = { {&OFFSET_HALO2_PF_COPY_GAME_OPTIONS, 0x39ce0, Code, { At("40 53 48 81 EC 30 03 00 00 48 8B D1 48 8D 1D ?? ?? ?? ?? 48 8B CB", 0x0), Rel("48 8B CF E8 ?? ?? ?? ?? 8B 4F 10 E8 ?? ?? ?? ?? B9 10 00 00 00 48 89 05", 0x4, 0x8, 0x0)}}, + {&OFFSET_HALO2_PF_HS_COMPILE, 0x6e17c0, Code, { + At("48 89 5C 24 08 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 C0 EE FF FF", 0x0), + Rel("E8 ?? ?? ?? ?? 4C 8B C3 48 8D 4C 24 20 BA C8 00 00 00 FF 15", 0x1, 0x5, 0x0)}}, {&OFFSET_HALO2_PF_ADD_LOCAL_PLAYER, 0x69d2c0, Code, { At("48 89 5C 24 08 57 48 83 EC 20 48 8B FA 8B D1 48 8B 0D", 0x0), Rel("E8 ?? ?? ?? ?? FF C3 48 81 C7 D4 00 00 00 83 FB 10 7C ?? E8 ?? ?? ?? ?? E8", 0x1, 0x5, 0x0)}}, @@ -44,6 +47,44 @@ const OffsetPatterns kHalo2Patterns[] = { {&OFFSET_HALO2_PV_SCENARIO, 0xe6f768, Data, { Rel("48 8B 05 ?? ?? ?? ?? 8B DE 48 89 7C 24 68 39 98 10 02 00 00", 0x3, 0x7, 0x0), Rel("48 8B 05 ?? ?? ?? ?? 33 D2 4C 63 80 6C 01 00 00 41 83 F8 FF", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_TAG_INSTANCES, 0x15e4b30, Data, { + Rel("48 8B 05 ?? ?? ?? ?? 48 03 C9 4C 89 7C 24 50 4C 63 74 C8 08", 0x3, 0x7, 0x0), + Rel("66 90 0F B7 C8 48 8B 05 ?? ?? ?? ?? 48 03 C9 48 63 5C C8 08", 0x8, 0xc, 0x0)}}, + {&OFFSET_HALO2_PV_TAG_COUNT, 0x15e4b60, Data, { + Rel("0F 29 05 ?? ?? ?? ?? 8B 52 2C E8 ?? ?? ?? ?? 0F B6 F8 84 C0 0F 84 ?? ?? ?? ?? 48 8B 1D", 0x3, 0x7, 0x0), + Rel("48 83 EC 20 33 DB 48 89 1D ?? ?? ?? ?? E8 ?? ?? ?? ?? 39 1D ?? ?? ?? ?? 74 ?? 48 8B 15", 0x14, 0x18, 0x0)}}, + {&OFFSET_HALO2_PV_TAG_NAME_OFFSETS, 0x15e4b68, Data, { + Rel("48 8B 05 ?? ?? ?? ?? 48 63 14 90 3B 15 ?? ?? ?? ?? 73 ?? 48 8B C2 48 03 05", 0x3, 0x7, 0x0), + Rel("48 83 EC 20 33 DB 48 89 1D ?? ?? ?? ?? E8 ?? ?? ?? ?? 39 1D ?? ?? ?? ?? 74 ?? 48 8B 15 ?? ?? ?? ??", 0x1d, 0x21, 0x0)}}, + {&OFFSET_HALO2_PV_TAG_NAMES, 0x15e4b78, Data, { + Rel("48 8B 05 ?? ?? ?? ?? 48 63 14 90 3B 15 ?? ?? ?? ?? 73 ?? 48 8B C2 48 03 05 ?? ?? ?? ??", 0x19, 0x1d, 0x0), + Rel("48 89 1D ?? ?? ?? ?? 89 1D ?? ?? ?? ?? 88 1D ?? ?? ?? ?? 48 89 1D ?? ?? ?? ?? 48 89 1D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 89 1D ?? ?? ?? ?? 48 89 1D ?? ?? ?? ?? 48 83 C4 20", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_TAG_BASE, 0xe80ab0, Data, { + Rel("4C 8B 05 ?? ?? ?? ?? 48 89 5C 24 40 48 89 7C 24 50 0F 1F 00", 0x3, 0x7, 0x0), + Rel("48 03 0D ?? ?? ?? ?? 48 0F BF C3 48 C1 E0 06 8B 54 08 34 E8", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_SHARED_TAG_BASE, 0xe80ac0, Data, { + Rel("0F B7 C9 0F BA F2 1F 48 03 15 ?? ?? ?? ?? 48 6B C1 38 48 03 C2", 0xa, 0xe, 0x0), + Rel("4C 8B 35 ?? ?? ?? ?? 83 F8 FF 74 ?? 85 C0 79 ?? 8B C8 0F BA F1 1F", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PV_OBJECTS, 0x18b7398, Data, { + Rel("48 89 5C 24 10 56 48 83 EC 20 48 8B 05 ?? ?? ?? ?? 33 DB 8B F1", 0xd, 0x11, 0x0), + Rel("75 ?? 8B DE 48 8B 05 ?? ?? ?? ?? 0F B7 C9 48 69 F9 A0 08 00 00", 0x7, 0xb, 0x0)}}, + {&OFFSET_HALO2_PV_OBJECT_MEMORY, 0x18b7360, Data, { + Rel("4C 8D 3C 49 48 8B 0D ?? ?? ?? ?? 42 8B 54 BA 08 E8 ?? ?? ?? ?? 48 8B 15", 0x7, 0xb, 0x0), + Rel("48 8B 0D ?? ?? ?? ?? 8B 54 B2 08 E8 ?? ?? ?? ?? 48 8D 4D D7 4C 8D 48 7C", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO2_PF_OBJECT_GET_ORIGIN, 0x8d6780, Code, { + At("48 89 5C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 05 ?? ?? ?? ?? 48 8B FA", 0x0), + Rel("E8 ?? ?? ?? ?? F3 0F 10 55 B4 F3 0F 5C 56 1C F3 0F 10 45 B0", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO2_PF_OBJECT_PLACEMENT_DATA_NEW, 0x8d8880, Code, { + At("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 41 8B E8 8B DA 33 D2", 0x0), + Rel("E8 ?? ?? ?? ?? F2 0F 10 44 24 20 48 8D 4C 24 30 8B 44 24 28", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO2_PF_OBJECT_NEW, 0x8d79d0, Code, { + At("40 53 55 56 57 41 54 41 55 41 56 41 57 48 81 EC F8 00 00 00 48 C7 44 24 40 FE FF FF FF 48 8B F1", 0x0), + Rel("E8 ?? ?? ?? ?? 83 F8 FF 74 ?? 8B 4F 18 41 B8 04 00 00 00 8B D0", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO2_PF_AI_PLACE, 0x618890, Code, { + At("83 F9 FF 0F 84 ?? ?? ?? ?? 57 48 83 EC 60 8B C1 48 89 5C 24 70", 0x0)}}, + {&OFFSET_HALO2_PF_AI_LIVING_COUNT, 0x6198e0, Code, { + At("48 8B C4 53 57 41 56 48 83 EC 60 0F 29 70 D8 44 8B D1", 0x0), + Rel("45 33 C0 E9 ?? ?? ?? ?? BA 02 00 00 00 45 33 C9 45 33 C0 E9", 0x4, 0x8, 0x0)}}, {&OFFSET_HALO2_PF_SPLIT_GRID, 0x7e09d0, Code, { At("48 89 5C 24 08 BB 01 00 00 00 44 8B D2 44 8B D9", 0x0), Rel("E8 ?? ?? ?? ?? 44 8B 84 24 E0 00 00 00 48 8D 84 24 C8 00 00 00", 0x1, 0x5, 0x0)}}, diff --git a/lib/game/inc/1.3528.0.0/patterns_halo3.inc b/lib/game/inc/1.3528.0.0/patterns_halo3.inc index a498ea5..1e35dbd 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo3.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo3.inc @@ -78,6 +78,18 @@ const OffsetPatterns kHalo3Patterns[] = { {&OFFSET_HALO3_PF_OBJECT_POST_CREATE, 0x1ea04, Code, { At("4C 8B DC 49 89 5B 08 49 89 6B 18 49 89 73 20 57 41 56 41 57 48 83 EC 50", 0x0), Rel("E8 ?? ?? ?? ?? 8B FB 4C 8D 9C 24 E0 01 00 00 8B C7 49 8B 5B 30", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO3_PV_TAG_BASE, 0x1fcf4c8, Data, { + Rel("48 8B 05 ?? ?? ?? ?? 48 8D 0C 90 48 81 C1 3C 03 00 00 33 D2", 0x3, 0x7, 0x0), + Rel("48 8B 05 ?? ?? ?? ?? 48 8D 0C 90 8B 85 10 01 00 00 C1 E8 02", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3_PV_SCENARIO, 0xa46a08, Data, { + Rel("48 39 15 ?? ?? ?? ?? 8B C1 C7 47 38 00 09 00 02 66 89 4F 3C", 0x3, 0x7, 0x0), + Rel("48 39 15 ?? ?? ?? ?? F2 41 0F 11 03 41 89 43 08 48 0F BE 4E 01", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3_PF_AI_PLACE, 0x577aa4, Code, { + At("48 89 5C 24 08 48 89 74 24 10 57 48 81 EC 80 00 00 00 83 CF FF", 0x0), + Rel("83 38 FF 74 ?? 8B 08 B2 01 E8 ?? ?? ?? ?? 33 D2 8B CB E8 ?? ?? ?? ?? 48 83 C4 20", 0xa, 0xe, 0x0)}}, + {&OFFSET_HALO3_PF_TAG_LOADED, 0x12c9ec, Code, { + At("83 F9 FF 74 25 48 8B 05 ?? ?? ?? ?? 8B D1 48 C1 E9 05 83 E2 1F", 0x0), + Rel("E8 ?? ?? ?? ?? 84 C0 8B CB 45 0F 45 01 41 8B D0 E8 ?? ?? ?? ?? 48 83 C4 20", 0x1, 0x5, 0x0)}}, {&OFFSET_HALO3_PV_SPLITSCREEN_TABLE, 0x8ae0b0, Data, { Rel("48 8D 0D ?? ?? ?? ?? F3 0F 10 44 91 08 F3 0F 5C 04 91 0F 2F 05", 0x3, 0x7, 0x0)}}, {&OFFSET_HALO3_PV_SCREEN_SIZE, 0x8ac3e8, Data, { diff --git a/lib/game/inc/1.3528.0.0/patterns_halo3odst.inc b/lib/game/inc/1.3528.0.0/patterns_halo3odst.inc index 0cab920..10f06a8 100644 --- a/lib/game/inc/1.3528.0.0/patterns_halo3odst.inc +++ b/lib/game/inc/1.3528.0.0/patterns_halo3odst.inc @@ -18,6 +18,33 @@ const OffsetPatterns kHalo3odstPatterns[] = { {&OFFSET_HALO3ODST_PF_ADD_LOCAL_PLAYER, 0xfbfe4, Code, { At("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 44 8B 0D ?? ?? ?? ?? 48 8B FA", 0x0), Rel("44 8A 47 21 48 8D 55 97 41 8B CE E8 ?? ?? ?? ?? 3B C6 74 ?? EB", 0xc, 0x10, 0x0)}}, + {&OFFSET_HALO3ODST_PV_TAGS_HEADER, 0x20f3068, Data, { + Rel("48 8B 1D ?? ?? ?? ?? 45 33 D2 0F BF C2 45 8B DA 3B 43 10 73", 0x3, 0x7, 0x0), + Rel("48 8B 0D ?? ?? ?? ?? FF C7 48 83 C3 10 3B 79 30 7C ?? 48 8B 15", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3ODST_PV_TAG_BASE, 0x2022aa8, Data, { + Rel("48 8B 15 ?? ?? ?? ?? 4D 8B 5C FE 10 41 0F B7 03 41 8B 4C C0 04", 0x3, 0x7, 0x0), + Rel("48 8B 3D ?? ?? ?? ?? 0F B7 C9 8B 44 CD 04 85 C0 75 ?? 33 F6 EB", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3ODST_PV_TAG_NAMES, 0xa9efc8, Data, { + Rel("48 8B 1D ?? ?? ?? ?? 0F B7 CD 48 63 04 8B 48 05 00 00 02 00", 0x3, 0x7, 0x0), + Rel("48 89 05 ?? ?? ?? ?? 8B D7 48 8B 01 FF 10 48 89 7C 24 38 33 D2", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3ODST_PV_SCENARIO, 0xa9c9b8, Data, { + Rel("48 39 15 ?? ?? ?? ?? 8B C1 C7 47 38 00 09 00 03 66 89 4F 3C", 0x3, 0x7, 0x0), + Rel("48 39 15 ?? ?? ?? ?? F2 41 0F 11 03 41 89 43 08 48 0F BE 4E 01", 0x3, 0x7, 0x0)}}, + {&OFFSET_HALO3ODST_PF_OBJECT_PLACEMENT_DATA_NEW, 0x37c954, Code, { + At("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 41 8B E8 8B DA", 0x0), + Rel("E8 ?? ?? ?? ?? 8B 44 24 48 F2 0F 10 44 24 50 F2 0F 11 45 BC", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO3ODST_PF_OBJECT_NEW, 0x37cf34, Code, { + At("48 8B C4 53 55 56 57 41 54 41 55 41 56 41 57 48 81 EC 88 00 00 00", 0x0), + Rel("E8 ?? ?? ?? ?? 8B D8 3B C6 74 ?? 44 8B 8D 20 01 00 00 44 8B C0", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO3ODST_PF_OBJECT_POST_CREATE, 0x20b80, Code, { + At("4C 8B DC 49 89 5B 08 49 89 6B 18 49 89 73 20 57 41 56 41 57 48 83 EC 70", 0x0), + Rel("E8 ?? ?? ?? ?? 8B FB 4C 8D 9C 24 C0 01 00 00 8B C7 49 8B 5B 30", 0x1, 0x5, 0x0)}}, + {&OFFSET_HALO3ODST_PF_AI_PLACE, 0x5be6a0, Code, { + At("48 89 5C 24 08 48 89 74 24 10 48 89 7C 24 18 55 48 8B EC 48 83 EC 70 83 C8 FF", 0x0), + Rel("83 38 FF 74 ?? 8B 08 B2 01 E8 ?? ?? ?? ?? 33 D2 8B CB E8 ?? ?? ?? ?? 48 83 C4 20", 0xa, 0xe, 0x0)}}, + {&OFFSET_HALO3ODST_PF_TAG_LOADED, 0x14d4c8, Code, { + At("83 F9 FF 74 25 48 8B 05 ?? ?? ?? ?? 8B D1 48 C1 E9 05 83 E2 1F", 0x0), + Rel("E8 ?? ?? ?? ?? 84 C0 8B CB 45 0F 45 01 41 8B D0 E8 ?? ?? ?? ?? 48 83 C4 20", 0x1, 0x5, 0x0)}}, {&OFFSET_HALO3ODST_PV_SPLITSCREEN_TABLE, 0x8f1f10, Data, { Rel("48 8D 0D ?? ?? ?? ?? F3 0F 10 44 91 08 F3 0F 5C 04 91 0F 2F 05", 0x3, 0x7, 0x0)}}, {&OFFSET_HALO3ODST_PV_SCREEN_SIZE, 0x8f0278, Data, { From f1879a696c4c491995ac527b41abf8cd19672682 Mon Sep 17 00:00:00 2001 From: John P <7864917+kirklandsig@users.noreply.github.com> Date: Wed, 7 Oct 2026 13:00:38 -0400 Subject: [PATCH 03/12] feat(spawn): spawning in Halo CE, 2, 3 and ODST, and the Spawn window Vehicles, weapons, equipment and AI characters (their own side, ally or enemy, with a chosen weapon) in front of any player, ported from the kirklandsig fork (src/mcc/spawn): - Command: spawning calls into the game, so it runs on the game's thread through two fixed verbs registered in code, spawn_list and spawn, posted only by AlphaRing's menus. Halo 3 and ODST run them on their World tick (the task queue in module/entry/halo3/world.cpp and halo3odst/world.cpp, which only get a registration; one task a tick, as before). Halo CE and Halo 2 get them through MCC's execute_command ("HS: @ar ...") at their console-script compiler, which is hooked (module/entry/halo1/console.cpp, halo2/console.cpp): text starting with "@ar " goes to the registered handlers, anything else to the game unchanged. A task is dropped once another map has loaded (CGameManager::load_generation, counted from MCC's Loading state), and a handler's temporary edits to game data are put back if the game faults in one of its calls. - Backends: objects with each engine's object_placement_data_new and object_new. Halo CE characters are a unit armed by actor_customize_unit and given a free actor (ai_attach_free); Halo 2, 3 and ODST place a character by pointing the nearest starting location of an empty mission squad at the player for one ai_place, armed from the scenario's weapon palette, then putting it back. - The Spawn window, in the debug overlay's menu bar beside Splitscreen and HUD: player, page, search, side and weapon. It writes no file, its place in imgui.ini included (ImGuiWindowFlags_NoSavedSettings). Each game's spawning is an AlphaRing::Feature of every offset it uses, with the hook that runs its commands: the World hook's offset for Halo 3 and ODST; for Halo CE and Halo 2 the console hook is an EntryFeature that requires the spawning feature, so it goes in only with all of it. On an MCC build missing one of them the game offers no spawning. Halo 2's characters also need ai_place and the living count; without them objects still spawn. check_gates.py reviews gen3.cpp's features, which are built from each game's table of offsets, as in the fork. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs --- src/mcc/CGameManager.h | 3 + src/mcc/CGameManagerSplitscreen.cpp | 6 + src/mcc/module/entry/halo1/console.cpp | 19 + src/mcc/module/entry/halo2/console.cpp | 19 + src/mcc/module/entry/halo3/world.cpp | 7 + src/mcc/module/entry/halo3odst/world.cpp | 7 + src/mcc/spawn/Backend.h | 146 ++++++ src/mcc/spawn/Command.cpp | 152 +++++++ src/mcc/spawn/Command.h | 47 ++ src/mcc/spawn/Spawn.cpp | 279 ++++++++++++ src/mcc/spawn/Spawn.h | 65 +++ src/mcc/spawn/gen3.cpp | 525 ++++++++++++++++++++++ src/mcc/spawn/halo1.cpp | 136 ++++++ src/mcc/spawn/halo2.cpp | 309 +++++++++++++ src/render/imgui/game/mcc/CMCCContext.cpp | 3 + tools/offsets/check_gates.py | 9 + 16 files changed, 1732 insertions(+) create mode 100644 src/mcc/module/entry/halo1/console.cpp create mode 100644 src/mcc/module/entry/halo2/console.cpp create mode 100644 src/mcc/spawn/Backend.h create mode 100644 src/mcc/spawn/Command.cpp create mode 100644 src/mcc/spawn/Command.h create mode 100644 src/mcc/spawn/Spawn.cpp create mode 100644 src/mcc/spawn/Spawn.h create mode 100644 src/mcc/spawn/gen3.cpp create mode 100644 src/mcc/spawn/halo1.cpp create mode 100644 src/mcc/spawn/halo2.cpp diff --git a/src/mcc/CGameManager.h b/src/mcc/CGameManager.h index a51a03b..c96fcff 100644 --- a/src/mcc/CGameManager.h +++ b/src/mcc/CGameManager.h @@ -26,6 +26,7 @@ }; enum eState { + Loading = 0, Running = 1, Exit = 5, Exiting = 10, @@ -38,6 +39,8 @@ static Profile_t* get_profile(int index); static CInputDevice* get_controller(int index); static void apply_profiles(); + // Increments every time a map starts loading. + static unsigned load_generation(); // Local players in the game right now (see CGameManagerSplitscreen.cpp: Halo 4 starts with two). static int active_player_count(); diff --git a/src/mcc/CGameManagerSplitscreen.cpp b/src/mcc/CGameManagerSplitscreen.cpp index cd9cbbf..01a4d34 100644 --- a/src/mcc/CGameManagerSplitscreen.cpp +++ b/src/mcc/CGameManagerSplitscreen.cpp @@ -40,7 +40,13 @@ static constexpr int kDeferredJoinStartPlayers = 2; static constexpr ULONGLONG kDeferredJoinDelayMs = 3000; static std::atomic s_running_since; // 0 until the current session first runs +static std::atomic s_load_generation; + +unsigned CGameManager::load_generation() { return s_load_generation; } + void CGameManager::track_state(eState state) { + if (state == Loading) + ++s_load_generation; if (state == Running && !s_running_since) // also re-sent after level transitions s_running_since = GetTickCount64(); } diff --git a/src/mcc/module/entry/halo1/console.cpp b/src/mcc/module/entry/halo1/console.cpp new file mode 100644 index 0000000..aeb2ef4 --- /dev/null +++ b/src/mcc/module/entry/halo1/console.cpp @@ -0,0 +1,19 @@ +#include "halo1.h" + +#include "mcc/CGameGlobal.h" +#include "mcc/spawn/Command.h" + +namespace MCC::Spawn::Halo1 { const AlphaRing::Feature& Offsets(); } + +namespace Halo1::Entry::Console { + // Game-thread entry for AlphaRing commands, see mcc/spawn/Command.h. Only spawning posts them, so the hook goes + // in only where Halo CE's spawning has every offset it uses (mcc/spawn/halo1.cpp). + EntryFeature("Halo CE spawning commands", OFFSET_HALO1_PF_HS_COMPILE); + const bool s_requires_spawning = (entry_feature->Requires(MCC::Spawn::Halo1::Offsets()), true); + + Halo1Entry(entry, OFFSET_HALO1_PF_HS_COMPILE, void, detour, const char* text) { + if (MCC::Command::Dispatch(CGameGlobal::Halo1, text)) + return; + ((detour_t)entry.m_pOriginal)(text); + } +} diff --git a/src/mcc/module/entry/halo2/console.cpp b/src/mcc/module/entry/halo2/console.cpp new file mode 100644 index 0000000..16ec162 --- /dev/null +++ b/src/mcc/module/entry/halo2/console.cpp @@ -0,0 +1,19 @@ +#include "halo2.h" + +#include "mcc/CGameGlobal.h" +#include "mcc/spawn/Command.h" + +namespace MCC::Spawn::Halo2 { const AlphaRing::Feature& Offsets(); } + +namespace Halo2::Entry::Console { + // Game-thread entry for AlphaRing commands, see mcc/spawn/Command.h. Only spawning posts them, so the hook goes + // in only where Halo 2's spawning has every offset it uses (mcc/spawn/halo2.cpp). + EntryFeature("Halo 2 spawning commands", OFFSET_HALO2_PF_HS_COMPILE); + const bool s_requires_spawning = (entry_feature->Requires(MCC::Spawn::Halo2::Offsets()), true); + + Halo2Entry(entry, OFFSET_HALO2_PF_HS_COMPILE, bool, detour, const char* text, bool flag) { + if (MCC::Command::Dispatch(CGameGlobal::Halo2, text)) + return false; + return ((detour_t)entry.m_pOriginal)(text, flag); + } +} diff --git a/src/mcc/module/entry/halo3/world.cpp b/src/mcc/module/entry/halo3/world.cpp index db1e741..4b72782 100644 --- a/src/mcc/module/entry/halo3/world.cpp +++ b/src/mcc/module/entry/halo3/world.cpp @@ -2,6 +2,9 @@ #include "common.h" +#include "mcc/CGameGlobal.h" +#include "mcc/spawn/Command.h" + #include #include @@ -38,3 +41,7 @@ namespace Halo3::Entry::World { Epilogue(); } } + +// Spawning's engine calls must run on this (the simulation) thread (mcc/spawn/Command.h). +static const bool s_registered_scheduler = + (MCC::Command::RegisterScheduler(CGameGlobal::Halo3, Halo3::Entry::World::AddTask), true); diff --git a/src/mcc/module/entry/halo3odst/world.cpp b/src/mcc/module/entry/halo3odst/world.cpp index 9c079af..f9b85e1 100644 --- a/src/mcc/module/entry/halo3odst/world.cpp +++ b/src/mcc/module/entry/halo3odst/world.cpp @@ -1,6 +1,9 @@ #include "halo3odst.h" #include "common.h" + +#include "mcc/CGameGlobal.h" +#include "mcc/spawn/Command.h" #include #include @@ -37,3 +40,7 @@ namespace Halo3ODST::Entry::World { Epilogue(); } } + +// Spawning's engine calls must run on this (the simulation) thread (mcc/spawn/Command.h). +static const bool s_registered_scheduler = + (MCC::Command::RegisterScheduler(CGameGlobal::Halo3ODST, Halo3ODST::Entry::World::AddTask), true); diff --git a/src/mcc/spawn/Backend.h b/src/mcc/spawn/Backend.h new file mode 100644 index 0000000..15ae9d0 --- /dev/null +++ b/src/mcc/spawn/Backend.h @@ -0,0 +1,146 @@ +#pragma once + +// Helpers shared by the per-game spawn backends (implementation detail of mcc/spawn). + +#include "Spawn.h" +#include "Command.h" + +#include +#include +#include + +namespace MCC::Spawn { + struct Vector3 { float x, y, z; }; + + // Calls a function inside a game module: EngineCall(game, rva, args...). + template + inline R EngineCall(int game, __int64 rva, A... args) { + return reinterpret_cast(MCC::Command::ModuleBase(game) + rva)(args...); + } + + // Reads a global variable of a game module. + template + inline T EngineGlobal(int game, __int64 rva) { return *(T*)(MCC::Command::ModuleBase(game) + rva); } + + // Blam group tags are four characters packed big-endian: 'vehi' -> 0x76656869. + constexpr unsigned int GroupTag(const char (&s)[5]) { + return (unsigned)s[0] << 24 | (unsigned)s[1] << 16 | (unsigned)s[2] << 8 | (unsigned)s[3]; + } + + // Where to put a spawned object: `distance` ahead of an origin along its horizontal + // facing, raised by `height`, facing the same way. + struct Placement { + Vector3 position, forward, up; + // Yaw of a character standing here looking back at the player. + float YawToPlayer() const { return std::atan2(-forward.y, -forward.x); } + }; + + inline Placement PlaceAhead(const Vector3& origin, const Vector3& facing, float distance, float height) { + float fx = facing.x, fy = facing.y; + float length = std::sqrt(fx * fx + fy * fy); + if (length < 1e-3f) { fx = 1.0f; fy = 0.0f; } else { fx /= length; fy /= length; } + return {{origin.x + fx * distance, origin.y + fy * distance, origin.z + height}, {fx, fy, 0.0f}, {0.0f, 0.0f, 1.0f}}; + } + + inline float Distance2(const Vector3& a, const Vector3& b) { + float dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z; + return dx * dx + dy * dy + dz * dz; + } + + // Weapon tags nobody can carry: mounted on a vehicle or a stand, or built into a character + // (a Monitor's welder beam). + inline bool MountedWeapon(const char* path) { + return path == nullptr || strstr(path, "\\turrets\\") || strstr(path, "\\vehicles\\") || + strstr(path, "\\characters\\") || strstr(path, "_integrated"); + } + + // The most common of the weapons voted for (tag -> votes), or -1. + template + inline int MostVoted(const Votes& votes) { + int best = -1, most = 0; + for (auto& [weapon, count] : votes) + if (count > most) { best = weapon; most = count; } + return best; + } + + // Writes a value over game data for as long as it's in scope, then puts the old one back + // (also if the game faults in the meantime: see Command::RecordChange). + template + struct ScopedPoke { + T* at = nullptr; + T saved{}; + + ScopedPoke() = default; + ScopedPoke(const ScopedPoke&) = delete; + ScopedPoke& operator=(const ScopedPoke&) = delete; + ~ScopedPoke() { + if (at == nullptr) return; + *at = saved; + MCC::Command::ForgetChange(at); + } + + void Set(T* where, T value) { + MCC::Command::RecordChange(where, sizeof(T)); + at = where; + saved = *where; + *where = value; + } + }; + + // Squads arm their actors from the scenario's weapon palette (H2/H3/ODST): the index of the + // palette entry that places `weapon` - its own entry, or else the last one, lent to `weapon` + // through `lent` - or -1 for none. `tag_at(i)` is the tag index of entry i of `count`. + template + short WeaponPaletteIndex(int weapon, int count, TagAt tag_at, ScopedPoke& lent) { + if (weapon == -1 || count == 0) return -1; + for (short i = 0; i < count; ++i) + if (*tag_at(i) == weapon) return i; + lent.Set(tag_at(count - 1), weapon); + return (short)(count - 1); + } + + // Blam team indices: 2 human (the players' side), 3 covenant; `own` keeps the character's. + inline short EngineTeam(Team team, short own) { return team == TeamAlly ? 2 : team == TeamEnemy ? 3 : own; } + + inline std::string SpawnResult(bool spawned, const std::string& name) { + return (spawned ? "Spawned " : "Couldn't spawn ") + name; + } + + // Spawn distances per category: vehicles need room, pickups land at the player's feet. + inline float SpawnDistance(Category category) { + switch (category) { + case Vehicles: return 5.0f; + case Characters: return 3.0f; + default: return 1.5f; + } + } + + // "objects\characters\brute\ai\brute_captain" -> "Brute Captain": the last part of a tag + // path, in words. Short vowel-less words are acronyms ("smg" -> "SMG", "br_ammo" -> "BR Ammo"). + inline std::string DisplayName(const char* path) { + const char* start = path ? path : ""; + if (const char* slash = strrchr(start, '\\')) start = slash + 1; + + std::string name, word; + auto flush = [&] { + if (word.empty()) return; + bool acronym = word.size() <= 4 && word.find_first_of("aeiouy") == std::string::npos; + for (auto& c : word) c = acronym ? (char)toupper((unsigned char)c) : c; + word[0] = (char)toupper((unsigned char)word[0]); + if (word == "Odst") word = "ODST"; + name += (name.empty() ? "" : " ") + word; + word.clear(); + }; + for (const char* p = start; *p; ++p) { + if (*p == '_' || *p == ' ') flush(); + else word += *p; + } + flush(); + return name.empty() ? "Unnamed" : name; + } + + // "Marine" armed with objects\weapons\rifle\battle_rifle -> "Marine with Battle Rifle". + inline std::string WithWeapon(const std::string& name, const char* weapon_path) { + return name + " with " + DisplayName(weapon_path); + } +} diff --git a/src/mcc/spawn/Command.cpp b/src/mcc/spawn/Command.cpp new file mode 100644 index 0000000..8cba8cd --- /dev/null +++ b/src/mcc/spawn/Command.cpp @@ -0,0 +1,152 @@ +#include "Command.h" + +#include "common.h" + +#include "mcc/mcc.h" +#include "mcc/CGameEngine.h" +#include "mcc/CGameGlobal.h" +#include "mcc/CGameManager.h" +#include "mcc/module/Module.h" + +#include +#include +#include +#include +#include +#include + +namespace MCC::Command { + static constexpr const char* kPrefix = "@ar "; + static constexpr int kGames = MCC::Module::MODULE_MCC; // one slot per game module + + static std::unordered_map& Handlers() { + static std::unordered_map handlers; + return handlers; + } + + void Register(const char* verb, Handler handler) { + Handlers()[verb] = handler; + } + + static Scheduler s_schedulers[kGames]; // constant-initialized, so safe to fill from static initializers + + void RegisterScheduler(int game, Scheduler scheduler) { + if ((unsigned)game < kGames) s_schedulers[game] = scheduler; + } + + // A task belongs to the map it was queued in: after another map loads it would act on the + // new map's data, so it's dropped. + bool Schedule(int game, const std::function& task) { + if ((unsigned)game >= kGames || s_schedulers[game] == nullptr) return false; + s_schedulers[game]([generation = CGameManager::load_generation(), task] { + if (generation == CGameManager::load_generation()) task(); + }); + return true; + } + + __int64 ModuleBase(int game) { + auto p_module = MCC::Module::GetSubModule(game); + return p_module ? p_module->info().hModule : 0; + } + + bool Post(const char* format, ...) { + auto p_engine = GameEngine(); + auto p_global = GameGlobal(); + if (p_engine == nullptr || p_global == nullptr || !MCC::IsInGame()) + return false; + + char text[1024]; + int written = snprintf(text, sizeof(text), "%s", kPrefix); + va_list args; + va_start(args, format); + vsnprintf(text + written, sizeof(text) - written, format, args); + va_end(args); + + int game = p_global->current_game; + std::string command = text; + if (!Schedule(game, [game, command] { Dispatch(game, command.c_str()); })) + p_engine->execute_command("HS: %s", text); // reaches the console hook on the game thread + return true; + } + + static Args Tokenize(const char* text) { + Args args; + std::string current; + bool quoted = false, has_token = false; + for (const char* p = text; *p; ++p) { + if (*p == '"') { quoted = !quoted; has_token = true; continue; } + if (!quoted && (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')) { + if (has_token) { args.push_back(current); current.clear(); has_token = false; } + continue; + } + current += *p; + has_token = true; + } + if (has_token) args.push_back(current); + return args; + } + + struct Change { + char* at; + std::vector saved; + }; + static thread_local std::vector t_changes; + + void RecordChange(void* at, size_t size) { + t_changes.push_back({(char*)at, std::vector((char*)at, (char*)at + size)}); + } + + void ForgetChange(void* at) { + for (auto it = t_changes.rbegin(); it != t_changes.rend(); ++it) + if (it->at == at) { + t_changes.erase(std::next(it).base()); + return; + } + } + + // After a fault: the recorded changes, newest first. + static void RestoreChanges() { + for (auto it = t_changes.rbegin(); it != t_changes.rend(); ++it) + memcpy(it->at, it->saved.data(), it->saved.size()); + t_changes.clear(); + } + + static int RecordFault(EXCEPTION_POINTERS* info, DWORD* code, void** address) { + *code = info->ExceptionRecord->ExceptionCode; + *address = info->ExceptionRecord->ExceptionAddress; + return EXCEPTION_EXECUTE_HANDLER; + } + + // Engine calls made by handlers can fault on unexpected game state; keep the game alive. + static bool CallHandler(Handler handler, int game, const Args& args, DWORD* code, void** address) { + __try { + handler(game, args); + t_changes.clear(); // anything a handler recorded is back by now + return true; + } __except (RecordFault(GetExceptionInformation(), code, address)) { + RestoreChanges(); + return false; + } + } + + bool Dispatch(int game, const char* text) { + if (text == nullptr || strncmp(text, kPrefix, strlen(kPrefix)) != 0) + return false; + + auto args = Tokenize(text + strlen(kPrefix)); + if (args.empty()) return true; + + auto it = Handlers().find(args[0]); + if (it == Handlers().end()) { + LOG_WARNING("Command: unknown '{}'", args[0]); + return true; + } + + DWORD code = 0; + void* address = nullptr; + if (!CallHandler(it->second, game, args, &code, &address)) + LOG_ERROR("Command: '{}' faulted ({:#x} at module+{:#x})", text + strlen(kPrefix), code, + (unsigned __int64)address - (unsigned __int64)ModuleBase(game)); + return true; + } +} diff --git a/src/mcc/spawn/Command.h b/src/mcc/spawn/Command.h new file mode 100644 index 0000000..689a2f0 --- /dev/null +++ b/src/mcc/spawn/Command.h @@ -0,0 +1,47 @@ +#pragma once + +#include +#include +#include + +// Game-thread execution for AlphaRing features (spawning). +// +// Engines with a simulation-tick hook register a Scheduler that runs a task on that thread +// (Halo 3 and ODST, whose console scripts compile on another thread). For the others, MCC +// hands every "HS: