Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/game/inc/1.3528.0.0/offset_halo1.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ DefOffset(OFFSET_HALO1_PF_OBJECT_TRY_AND_GET, 0xB389A4) // void* (int object, un
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

// hot join (module/entry/halo1/hotjoin.cpp)
DefOffset(OFFSET_HALO1_PF_PLAYERS_UPDATE, 0xAD0720) // void (state*) - each tick: the players' respawns (calls the below)
DefOffset(OFFSET_HALO1_PF_PLAYER_SPAWN, 0xAD4184) // void (int player) - a start location or the co-op respawn; callers check the unit
DefOffset(OFFSET_HALO1_PF_CHOOSE_START_LOCATION, 0xAD39AC) // int16 (int player) - the best free starting location, -1: none
DefOffset(OFFSET_HALO1_PF_START_LOCATION, 0xAD3940) // entry* (int16 index) - a starting location, 0x34: point, facing +0xC
DefOffset(OFFSET_HALO1_PF_OBJECT_DELETE, 0xC579D4) // void (int object) - object_destroy's; skips a player's unit
DefOffset(OFFSET_HALO1_PF_PLAYER_SET_UNIT, 0xAD2404) // void (int player, int unit) - -1 takes the player out of theirs
DefOffset(OFFSET_HALO1_PF_OBJECT_SET_POSITION, 0xB359E8) // void (int object, point3*, vector3* forward, vector3* up) - null keeps
DefOffset(OFFSET_HALO1_PF_OBJECT_TELEPORTED, 0xBA83EC) // void (int object) - what object_teleport resets after the move
DefOffset(OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE, 0xAD2FBC) // bool (int player, int other, void*) - moves a just-spawned player's unit beside another player (the co-op respawn, players_update 0xAD058F); true when it did

// 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
Expand Down
1 change: 1 addition & 0 deletions lib/game/inc/1.3528.0.0/offset_halo2.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DefOffset(OFFSET_HALO2_PF_PLAYERS_UPDATE, 0x6A3910)
DefOffset(OFFSET_HALO2_PF_COOP_CAMPAIGN, 0x6A6320) // bool () - a co-op campaign: session [0xE80A78] mode +8 == 1, byte +0x2C8
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
DefOffset(OFFSET_HALO2_PF_PLAYER_SPAWN, 0x69E580) // bool (int player) - a new unit at the best starting location (hot join)

// spawning (mcc/spawn)
DefOffset(OFFSET_HALO2_PV_TAG_INSTANCES, 0x15E4B30) // {u32 group, u32 datum, u32 address, u32 size}[tag count]
Expand Down
27 changes: 27 additions & 0 deletions lib/game/inc/1.3528.0.0/patterns_halo1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ const OffsetPatterns kHalo1Patterns[] = {
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_PLAYERS_UPDATE, 0xad0720, Code, {
At("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 D8 FB FF FF", 0x0),
Rel("48 8D 4C 24 30 E8 ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 38 58 03 74 ?? F3 0F 10 05", 0x6, 0xa, 0x0)}},
{&OFFSET_HALO1_PF_PLAYER_SPAWN, 0xad4184, Code, {
At("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D 68 A1 48 81 EC 00 01 00 00 0F 29 70 C8 48 8B 05", 0x0),
Rel("E8 ?? ?? ?? ?? 39 6F 64 74 ?? 8B 4C 24 2C 41 0F B7 D6 4C 8D 04 52", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_CHOOSE_START_LOCATION, 0xad39ac, Code, {
At("48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 57 48 83 EC 50 0F 29 70 E8 83 CF FF", 0x0),
Rel("E8 ?? ?? ?? ?? 45 33 DB 66 41 3B C5 0F 84 ?? ?? ?? ?? 48 8B 35 ?? ?? ?? ?? 41 8B CB", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_START_LOCATION, 0xad3940, Code, {
At("4C 8B 05 ?? ?? ?? ?? 33 D2 66 85 C9 78 ?? 0F BF C1 41 3B 80 54 03 00 00", 0x0),
Rel("E8 ?? ?? ?? ?? 48 8B F8 66 39 68 10 0F 87 ?? ?? ?? ?? 4C 8D 40 14 8B CD", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_OBJECT_DELETE, 0xc579d4, Code, {
At("83 F9 FF 74 1C 53 48 83 EC 20 8B D9 E8 ?? ?? ?? ?? 84 C0 75", 0x0),
Rel("48 0F BF C9 8B 0C 88 EB ?? 8B CA 3B CA 74 ?? E8 ?? ?? ?? ?? 48 83 C4 28", 0x10, 0x14, 0x0)}},
{&OFFSET_HALO1_PF_PLAYER_SET_UNIT, 0xad2404, Code, {
At("48 89 6C 24 08 48 89 74 24 10 48 89 7C 24 18 41 54", 0x0),
Rel("E8 ?? ?? ?? ?? 8B 4D C8 89 4B 4C 8A 4D C8 88 8B CE 00 00 00", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_OBJECT_SET_POSITION, 0xb359e8, Code, {
At("48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 55 41 56 41 57 48 83 EC 60 4C 8B 3D", 0x0),
Rel("E8 ?? ?? ?? ?? B8 D4 01 00 00 49 8D 9F 08 02 00 00 48 03 DF", 0x1, 0x5, 0x0)}},
{&OFFSET_HALO1_PF_OBJECT_TELEPORTED, 0xba83ec, Code, {
At("83 F9 FF 74 1F 80 3D ?? ?? ?? ?? 00 74 ?? 48 8B 05 ?? ?? ?? ?? 0F B7 C9 48 69 D1 4C 0D 00 00", 0x0),
Rel("8B CB E8 ?? ?? ?? ?? 33 D2 8B CF E8 ?? ?? ?? ?? 48 8B 5C 24 30 48 83 C4 20", 0x3, 0x7, 0x0)}},
{&OFFSET_HALO1_PF_PLAYER_MOVE_BESIDE, 0xad2fbc, Code, {
At("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 05 ?? ?? ?? ?? 8B EA", 0x0),
Rel("49 81 C0 90 00 00 00 4D 03 C1 44 3B CD 4C 0F 44 C0 E8 ?? ?? ?? ??", 0x12, 0x16, 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)}},
Expand Down
3 changes: 3 additions & 0 deletions lib/game/inc/1.3528.0.0/patterns_halo2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ 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_PF_PLAYER_SPAWN, 0x69e580, Code, {
At("40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 60 EF FF FF", 0x0),
Rel("E8 ?? ?? ?? ?? B0 01 EB ?? 32 C0 48 8B 5C 24 30 48 8B 74 24 38 48 8B 7C 24 40", 0x1, 0x5, 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)}},
Expand Down
2 changes: 2 additions & 0 deletions src/mcc/CGameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "mcc/mcc.h"
#include "mcc/settings/MenuSettings.h"
#include "log/MatchLog.h"
#include "mcc/splitscreen/Splitscreen.h"

#include <cstdio>
#include <guiddef.h>
Expand Down Expand Up @@ -164,6 +165,7 @@ void CGameManager::apply_profiles() {
if (profile) {
memcpy(&profile->profile, base_profile, sizeof(CUserProfile));
memcpy(&profile->mapping, base_mapping, sizeof(CGamepadMapping));
MCC::Splitscreen::ApplySpecies(i, profile->profile);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/mcc/CGameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
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).
// Local players in the game right now (see CGameManagerSplitscreen.cpp: Halo 4 starts with two; a hot-join
// Halo CE or Halo 2 mission is told of all four and holds back the others, Splitscreen::HotJoinSlots).
static int active_player_count();
// The current map runs: from its Running state until a map loads or the session exits.
static bool running();

private:
static void track_state(eState state);
Expand Down
23 changes: 17 additions & 6 deletions src/mcc/CGameManagerSplitscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using AlphaRing::MatchLog::Describe;
using AlphaRing::MatchLog::FirstThisMatch;
#include "input/MenuConfig.h"
#include "mcc/spawn/Spawn.h"
#include "mcc/splitscreen/Splitscreen.h"

#include <atomic>

Expand Down Expand Up @@ -43,21 +44,27 @@ static constexpr ULONGLONG kDeferredJoinDelayMs = 3000;
static std::atomic<ULONGLONG> s_running_since; // 0 until the current session first runs

static std::atomic<unsigned> s_load_generation;
static std::atomic<bool> s_map_running; // from the Running state until a map loads or the session exits

unsigned CGameManager::load_generation() { return s_load_generation; }

bool CGameManager::running() { return s_map_running; }

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();
if (state == Running || state == Loading || state == Exit || state == Exiting)
s_map_running = state == Running;
}

// MCC ends every session with a restart after the exit states. The clock is cleared there,
// not on the exit states: dropping players while the engine is still shutting down can hang
// it, and the next session queries its players before its own loading state.
void CGameManager::end_session() {
s_running_since = 0;
s_map_running = false;
}

static int deferred_player_count(int count) {
Expand All @@ -78,7 +85,7 @@ static int deferred_player_count(int count) {

int CGameManager::active_player_count() {
static std::atomic<int> s_last_logged = -1;
int active = deferred_player_count(AlphaRing::Global::MCC::Splitscreen()->player_count);
int active = deferred_player_count(MCC::Splitscreen::PlayerCount());

if (active != s_last_logged) {
s_last_logged = active;
Expand All @@ -100,7 +107,8 @@ static bool get_xbox_user_id_inner(CGameManager *self, __int64 *pId, wchar_t *pN
return CGameManager::ppOriginal.get_xbox_user_id(self, pId, pName, size, index);
}

if (index >= CGameManager::active_player_count()) {
// MCC counts the local players it asks for here (all four slots in a Halo CE or Halo 2 hot-join mission)
if (index >= MCC::Splitscreen::HotJoinSlots(CGameManager::active_player_count())) {
*path = "beyond player_count";
return false;
}
Expand Down Expand Up @@ -212,9 +220,11 @@ bool CGameManager::get_key_state(CGameManager *self, DWORD index, input_data_t *
MATCH_LOG("input player={} first press buttons={:#06x} (input_user={})", index,
p_device->state.Gamepad.wButtons, p_device->input_user);

// While the player's spawn menu is open it has the pad, which the game sees released; after it closes, what
// was held then is taken out of the pad until released.
if (MCC::Spawn::HandlePlayerInput(index, p_device->state.Gamepad))
// Until what a player who just joined pressed is let go (Players window, hot join), and while the player's
// spawn menu is open, which then has the pad, the game sees it released; after a menu closes, what was held
// then is taken out of the pad until released.
if (MCC::Splitscreen::JoinPressHeld(p_device->input_user, p_device->state.Gamepad) ||
MCC::Spawn::HandlePlayerInput(index, p_device->state.Gamepad))
memset(&p_device->state.Gamepad, 0, sizeof(p_device->state.Gamepad));
}

Expand Down Expand Up @@ -265,7 +275,7 @@ CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid)
// Reach initializes armor into the player-0 profile after game_setup fires, so the
// snapshot taken by apply_profiles() is stale. Sync armor from the live player-0
// profile on every call while preserving the per-player custom colors and look
// settings we applied.
// settings we applied, and a species chosen in the Players window.
auto* gg = GameGlobal();
if (gg && gg->current_game == CGameGlobal::HaloReach) {
auto* base = ppOriginal.get_player_profile(self, get_xuid(0));
Expand Down Expand Up @@ -293,6 +303,7 @@ CUserProfile* CGameManager::get_player_profile(CGameManager *self, __int64 xid)
dest->profile.HorizontalLookSensitivity = horizSens;
// and the armor picked for this player in the advanced menu
AlphaRing::MenuSettings::ApplyArmor(get_index(xid), dest->profile);
MCC::Splitscreen::ApplySpecies(index, dest->profile);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/mcc/module/entry/halo1/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Halo1::Entry::Graphics {
Halo1Entry(entry, OFFSET_HALO1_PF_GAME_START, __int64, detour, void* self, void* manager, unsigned char* game_options, void* a4) {
MCC::Splitscreen::ClassicGraphicsScope classic(game_options, CGameGlobal::Halo1);
HotJoin::Start(MCC::Splitscreen::HotJoinOn());
return ((detour_t)entry.m_pOriginal)(self, manager, game_options, a4);
}
}
4 changes: 4 additions & 0 deletions src/mcc/module/entry/halo1/halo1.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ namespace Halo1::Entry {
namespace Anniversary {
bool Quad(__int64 module); // 3-4 players drawn in quarters, Anniversary graphics (anniversary.cpp)
}

namespace HotJoin {
void Start(bool on); // as a mission starts (graphics.cpp): whether it's a hot-join one (hotjoin.cpp)
}
}
Loading
Loading