From 96f172b0c6ff932a459a224342af8135a3b23a64 Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Tue, 3 Nov 2026 19:45:16 -0600 Subject: [PATCH 1/6] feat: sar_unlocked_chapters also opens coop courses in the hub Detour CPortalMPGameRules::GetActiveBranches (the hub script's GetHighestActiveBranch) to return at least min(sar_unlocked_chapters, 6). Completion data is left alone, so the hub awards no course achievements. Host side only; Windows signature only. --- docs/cvars.md | 2 +- src/Modules/Client.cpp | 2 +- src/Modules/Client.hpp | 2 ++ src/Modules/Server.cpp | 22 ++++++++++++++++++++++ src/Modules/Server.hpp | 3 +++ src/Offsets/Portal 2 10090.hpp | 3 +++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/cvars.md b/docs/cvars.md index 9449ff65b..68994d769 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -702,7 +702,7 @@ |sar_twitch_chat_channel||The Twitch channel to connect to.| |sar_twitch_chat_color|255 255 255|The color of the Twitch chat messages.| |sar_twitch_chat_enabled|0|Enables Twitch chat integration. 2 enables spectator command !spec| -|sar_unlocked_chapters|-1|Max unlocked chapter.| +|sar_unlocked_chapters|-1|Max unlocked chapter. Also opens coop courses up to this number in the hub (as host) without marking them complete.| |sar_update|cmd|sar_update [release\|pre\|canary] [exit\|restart] [force] - update SAR to the latest version. If exit is given, exit the game upon successful update; if force is given, always re-install, even if it may be a downgrade| |sar_velocitygraph|0|Shows velocity graph.| |sar_velocitygraph_background|0|Background of velocity graph.| diff --git a/src/Modules/Client.cpp b/src/Modules/Client.cpp index 363a59e44..057cf0d4e 100644 --- a/src/Modules/Client.cpp +++ b/src/Modules/Client.cpp @@ -85,7 +85,7 @@ Variable sar_patch_minor_angle_decay("sar_patch_minor_angle_decay", "0", "Patche #endif ); -Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter.\n"); +Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter. Also opens coop courses up to this number in the hub (as host) without marking them complete.\n"); Variable sar_portalcolor_enable("sar_portalcolor_enable", "0", "Enable custom portal colors.\n"); Variable sar_portalcolor_sp_1("sar_portalcolor_sp_1", "64 160 255", "Portal color for Chell's left portal. r_portal_fastpath 0 required.\n"); diff --git a/src/Modules/Client.hpp b/src/Modules/Client.hpp index 979bd995c..289db2668 100644 --- a/src/Modules/Client.hpp +++ b/src/Modules/Client.hpp @@ -200,6 +200,8 @@ class Client : public Module { extern Client *client; +extern Variable sar_unlocked_chapters; + extern Variable cl_showpos; extern Variable cl_sidespeed; extern Variable cl_backspeed; diff --git a/src/Modules/Server.cpp b/src/Modules/Server.cpp index 94d9f74ac..e25d91167 100644 --- a/src/Modules/Server.cpp +++ b/src/Modules/Server.cpp @@ -84,6 +84,7 @@ REDECL(Server::OnRemoveEntity); REDECL(Server::PlayerRunCommand); REDECL(Server::ViewPunch); REDECL(Server::IsInPVS); +REDECL(Server::GetActiveBranches); REDECL(Server::ProcessMovement); REDECL(Server::GetPlayerViewOffset); REDECL(Server::StartTouchChallengeNode); @@ -402,6 +403,24 @@ DETOUR_T(bool, Server::IsInPVS, void *info) { } Hook g_IsInPVS_Hook(&Server::IsInPVS_Hook); +// The coop hub script opens courses 1 to N for N = GetHighestActiveBranch(), which is this +// function. Raising N only opens the hub doors: the per-player completion data (and the +// achievements the hub awards from it) is left alone. +extern Hook g_GetActiveBranches_Hook; +DETOUR(Server::GetActiveBranches) { + g_GetActiveBranches_Hook.Disable(); + auto ret = Server::GetActiveBranches(thisptr); + g_GetActiveBranches_Hook.Enable(); + + if (sar_unlocked_chapters.GetInt() > -1) { + // 6 already opens every course; 7 means "all completed", don't fake that + ret = (std::max)(ret, (std::min)(sar_unlocked_chapters.GetInt(), 6)); + } + + return ret; +} +Hook g_GetActiveBranches_Hook(&Server::GetActiveBranches_Hook); + ON_INIT { NetMessage::RegisterHandler( CM_FLAGS_MESSAGE_TYPE, +[](const void *data, size_t size) { @@ -997,6 +1016,9 @@ bool Server::Init() { if (sar.game->Is(SourceGame_Portal2 | SourceGame_Portal2_2011)) { Server::IsInPVS = (Server::_IsInPVS)Memory::Scan(this->Name(), Offsets::IsInPVS); g_IsInPVS_Hook.SetFunc(IsInPVS); + + Server::GetActiveBranches = (Server::_GetActiveBranches)Memory::Scan(this->Name(), Offsets::GetActiveBranches); + g_GetActiveBranches_Hook.SetFunc(GetActiveBranches); } NetMessage::RegisterHandler(RESET_COOP_PROGRESS_MESSAGE_TYPE, &netResetCoopProgress); diff --git a/src/Modules/Server.hpp b/src/Modules/Server.hpp index 04f44d00c..194021706 100644 --- a/src/Modules/Server.hpp +++ b/src/Modules/Server.hpp @@ -88,6 +88,9 @@ class Server : public Module { // CServerNetworkProperty::IsInPVS DECL_DETOUR_T(bool, IsInPVS, void *info); + // CPortalMPGameRules::GetActiveBranches + DECL_DETOUR(GetActiveBranches); + // CGameMovement::ProcessMovement DECL_DETOUR(ProcessMovement, void *pPlayer, CMoveData *pMove); diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index da96dc59d..5dff82f9f 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -557,6 +557,9 @@ OFFSET_DEFAULT(aircontrol_fling_speedOff, 3, 3) SIGSCAN_DEFAULT(FloorReportalBranch, "75 7D 8B 8E C0 04 00 00", "75 ? 8B 85 ? ? ? ? 8B 0D") // "Portal.open_red" xref(nothing after if) -> CProp_Portal::NewLocation -> first function call CPortal_Base2D::NewLocation -> 4x func call followed by test, [jnz] +SIGSCAN_DEFAULT(GetActiveBranches, "55 8B EC 83 EC 14 53 56 BA 01 00 00 00 8D B1 ? ? ? ? 81 C1 ? ? ? ? 57 C6 45 FE 01", + "") // "Returns which branches should be available in the hub." xref -> GetHighestActiveBranch script binding -> tail jump -> CPortalMPGameRules::GetActiveBranches + SIGSCAN_DEFAULT(CPortal_Player__PollForUseEntity_CheckMP, "74 ? ? ? 8B 82 ? ? ? ? FF D0 84 C0 74 ? 8B CE", "74 ? 8B 10 83 EC 0C 50 FF 92 88 00 00 00 83 C4 10 84 C0 ? ? ? ? ? ? ? ? ? ? ? ? ? 00 00") // "OnJump" xref -> CPortal_Player:PreThink -> CBasePlayer::PreThink -> CBasePlayer::ItemPreFrame -> CBasePlayer::PlayerUse -> CPortal_Player vtable offset -> CPortal_Player::PlayerUse -> Second function call from disassembly -> CPortal_Player::PollForUseEntity -> jz instruction From db75ef3e3a90e684d744926ca096da7597cf19ee Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Tue, 3 Nov 2026 22:17:18 -0600 Subject: [PATCH 2/6] feat: linux signature for GetActiveBranches --- src/Offsets/Portal 2 10090.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index 5dff82f9f..b7b89ec23 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -558,7 +558,7 @@ SIGSCAN_DEFAULT(FloorReportalBranch, "75 7D 8B 8E C0 04 00 00", "75 ? 8B 85 ? ? ? ? 8B 0D") // "Portal.open_red" xref(nothing after if) -> CProp_Portal::NewLocation -> first function call CPortal_Base2D::NewLocation -> 4x func call followed by test, [jnz] SIGSCAN_DEFAULT(GetActiveBranches, "55 8B EC 83 EC 14 53 56 BA 01 00 00 00 8D B1 ? ? ? ? 81 C1 ? ? ? ? 57 C6 45 FE 01", - "") // "Returns which branches should be available in the hub." xref -> GetHighestActiveBranch script binding -> tail jump -> CPortalMPGameRules::GetActiveBranches + "55 31 ED 57 56 53 83 EC 10 8B 44 24 24 C7 44 24 0C 01 00 00 00 C6 44 24 0B 01") // "Returns which branches should be available in the hub." xref -> GetHighestActiveBranch script binding -> CPortalMPGameRules::GetActiveBranches SIGSCAN_DEFAULT(CPortal_Player__PollForUseEntity_CheckMP, "74 ? ? ? 8B 82 ? ? ? ? FF D0 84 C0 74 ? 8B CE", "74 ? 8B 10 83 EC 0C 50 FF 92 88 00 00 00 83 C4 10 84 C0 ? ? ? ? ? ? ? ? ? ? ? ? ? 00 00") // "OnJump" xref -> CPortal_Player:PreThink -> CBasePlayer::PreThink -> CBasePlayer::ItemPreFrame -> CBasePlayer::PlayerUse -> CPortal_Player vtable offset -> CPortal_Player::PlayerUse -> Second function call from disassembly -> CPortal_Player::PollForUseEntity -> jz instruction From 41c098d35dc387c9fdb3c55f44d290c831dbb3eb Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Wed, 4 Nov 2026 00:17:08 -0600 Subject: [PATCH 3/6] feat: sar_unlocked_chapters also unlocks coop maps in the level select and challenge mode lists --- docs/cvars.md | 2 +- src/Modules/Client.cpp | 66 +++++++++++++++++++++++++++++++++- src/Modules/Client.hpp | 8 +++++ src/Offsets/Portal 2 10090.hpp | 6 ++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/docs/cvars.md b/docs/cvars.md index 68994d769..e76766e39 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -702,7 +702,7 @@ |sar_twitch_chat_channel||The Twitch channel to connect to.| |sar_twitch_chat_color|255 255 255|The color of the Twitch chat messages.| |sar_twitch_chat_enabled|0|Enables Twitch chat integration. 2 enables spectator command !spec| -|sar_unlocked_chapters|-1|Max unlocked chapter. Also opens coop courses up to this number in the hub (as host) without marking them complete.| +|sar_unlocked_chapters|-1|Max unlocked chapter. Also unlocks coop courses up to this number (hub doors as host, level select and challenge mode maps) without marking them complete.| |sar_update|cmd|sar_update [release\|pre\|canary] [exit\|restart] [force] - update SAR to the latest version. If exit is given, exit the game upon successful update; if force is given, always re-install, even if it may be a downgrade| |sar_velocitygraph|0|Shows velocity graph.| |sar_velocitygraph_background|0|Background of velocity graph.| diff --git a/src/Modules/Client.cpp b/src/Modules/Client.cpp index 057cf0d4e..5aa021567 100644 --- a/src/Modules/Client.cpp +++ b/src/Modules/Client.cpp @@ -85,7 +85,7 @@ Variable sar_patch_minor_angle_decay("sar_patch_minor_angle_decay", "0", "Patche #endif ); -Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter. Also opens coop courses up to this number in the hub (as host) without marking them complete.\n"); +Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter. Also unlocks coop courses up to this number (hub doors as host, level select and challenge mode maps) without marking them complete.\n"); Variable sar_portalcolor_enable("sar_portalcolor_enable", "0", "Enable custom portal colors.\n"); Variable sar_portalcolor_sp_1("sar_portalcolor_sp_1", "64 160 255", "Portal color for Chell's left portal. r_portal_fastpath 0 required.\n"); @@ -130,6 +130,10 @@ REDECL(Client::ApplyMouse_Mid_Continue); #endif REDECL(Client::DrawPortal); REDECL(Client::GetChapterProgress); +REDECL(Client::IsLevelComplete); +#ifdef _WIN32 +REDECL(Client::SetChapterAndMapInfo); +#endif CMDECL(Client::GetAbsOrigin, Vector, m_vecAbsOrigin); @@ -1014,6 +1018,53 @@ DETOUR(Client::GetChapterProgress) { } Hook g_GetChapterProgressHook(&Client::GetChapterProgress_Hook); +// The coop menus (hub level select, challenge mode and leaderboard lists) lock every map +// neither player has completed. Treat the maps of courses 1 to N as completed there; the +// real completion data is left alone. +extern Hook g_IsLevelCompleteHook; +DETOUR_T(bool, Client::IsLevelComplete, int branch, int level) { + if (branch >= 0 && branch < sar_unlocked_chapters.GetInt()) + return true; + + g_IsLevelCompleteHook.Disable(); + auto ret = Client::IsLevelComplete(thisptr, branch, level); + g_IsLevelCompleteHook.Enable(); + return ret; +} +Hook g_IsLevelCompleteHook(&Client::IsLevelComplete_Hook); + +#ifdef _WIN32 +// Outside a game, the leaderboard list reads each coop map's MP.complete title data bit +// through this helper instead (its only caller). Linux inlines it, so this part is Windows only. +using _TitleDataGetBool = bool(__cdecl *)(void *field, void *titleData); +static _TitleDataGetBool TitleDataGetBool; +static bool g_unlockLeaderboardMapItem = false; + +extern Hook g_TitleDataGetBoolHook; +static bool __cdecl TitleDataGetBool_Hook(void *field, void *titleData) { + if (g_unlockLeaderboardMapItem) + return true; + + g_TitleDataGetBoolHook.Disable(); + auto ret = TitleDataGetBool(field, titleData); + g_TitleDataGetBoolHook.Enable(); + return ret; +} +Hook g_TitleDataGetBoolHook(&TitleDataGetBool_Hook); + +extern Hook g_SetChapterAndMapInfoHook; +DETOUR_T(void, Client::SetChapterAndMapInfo, int chapter, int map, int a4, int chapterProgress) { + g_unlockLeaderboardMapItem = chapter <= sar_unlocked_chapters.GetInt(); + + g_SetChapterAndMapInfoHook.Disable(); + Client::SetChapterAndMapInfo(thisptr, chapter, map, a4, chapterProgress); + g_SetChapterAndMapInfoHook.Enable(); + + g_unlockLeaderboardMapItem = false; +} +Hook g_SetChapterAndMapInfoHook(&Client::SetChapterAndMapInfo_Hook); +#endif + bool Client::Init() { bool readJmp = false; #ifdef _WIN32 @@ -1288,6 +1339,19 @@ bool Client::Init() { Client::GetChapterProgress = (decltype(Client::GetChapterProgress))Memory::Scan(this->Name(), Offsets::GetChapterProgress); g_GetChapterProgressHook.SetFunc(Client::GetChapterProgress); + if (sar.game->Is(SourceGame_Portal2 | SourceGame_Portal2_2011)) { + Client::IsLevelComplete = (decltype(Client::IsLevelComplete))Memory::Scan(this->Name(), Offsets::IsLevelComplete); + g_IsLevelCompleteHook.SetFunc(Client::IsLevelComplete); +#ifdef _WIN32 + Client::SetChapterAndMapInfo = (decltype(Client::SetChapterAndMapInfo))Memory::Scan(this->Name(), Offsets::SetChapterAndMapInfo); + TitleDataGetBool = (_TitleDataGetBool)Memory::Scan(this->Name(), Offsets::TitleDataGetBool); + if (Client::SetChapterAndMapInfo && TitleDataGetBool) { + g_SetChapterAndMapInfoHook.SetFunc(Client::SetChapterAndMapInfo); + g_TitleDataGetBoolHook.SetFunc(TitleDataGetBool); + } +#endif + } + cl_showpos = Variable("cl_showpos"); cl_sidespeed = Variable("cl_sidespeed"); cl_forwardspeed = Variable("cl_forwardspeed"); diff --git a/src/Modules/Client.hpp b/src/Modules/Client.hpp index 289db2668..c19057895 100644 --- a/src/Modules/Client.hpp +++ b/src/Modules/Client.hpp @@ -101,6 +101,14 @@ class Client : public Module { // CBaseModPanel::GetChapterProgress DECL_DETOUR(GetChapterProgress); + // C_PortalMPGameRules::IsLevelComplete + DECL_DETOUR_T(bool, IsLevelComplete, int branch, int level); + +#ifdef _WIN32 + // CLeaderboardMapItem::SetChapterAndMapInfo + DECL_DETOUR_T(void, SetChapterAndMapInfo, int chapter, int map, int a4, int chapterProgress); +#endif + // BaseModUI::CPortalLeaderboardPanel::OnCommand DECL_DETOUR(OnCommand, const char *a2); diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index b7b89ec23..3e4cd674b 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -440,6 +440,12 @@ SIGSCAN_EMPTY(FindElementSig) SIGSCAN_DEFAULT(GetChapterProgress, "56 8B 35 ? ? ? ? 57 8B F9 FF D6 8B 10 8B C8", "55 89 E5 57 56 53 83 EC 0C E8 ? ? ? ? 83 EC 08 8B 10") +SIGSCAN_DEFAULT(IsLevelComplete, "55 8B EC 8B 55 0C 83 FA 0F 77 ? 8B 45 08 83 F8 05 77 ? C1 E0 04 03 C2 80 BC 08 B5 19 00 00 00", + "83 7C 24 0C 0F 8B 54 24 08 0F 97 C0 83 FA 05 0F 97 C1 08 C8 74") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo -> in-game branch -> C_PortalMPGameRules::IsLevelComplete +SIGSCAN_DEFAULT(SetChapterAndMapInfo, "55 8B EC 81 EC 20 02 00 00 53 8B 5D 08 57 8B F9 89 7D F8 85 DB 0F 8E ? ? ? ? 8B 4D 0C 85 C9 0F 8E", + "") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo (Linux: custom calling convention) +SIGSCAN_DEFAULT(TitleDataGetBool, "55 8B EC 8B 45 08 8B 4D 0C 8B 11 8B 52 14 56 8B 70 0C 8B 40 04 57 50 FF D2", + "") // CLeaderboardMapItem::SetChapterAndMapInfo -> "MP.complete.%s" title data bit read (Linux: inlined) SIGSCAN_DEFAULT(LoadingProgress__SetupControlStatesInstruction, "66 C7 86 ? ? ? ? ? ? EB", "66 89 83 ? ? ? ? E9 ? ? ? ? ? ? ? ? ? ? ? 85 F6") // "vgui/loading_screens/loadingscreen_coop" xref -> LoadingProgress::SetupControlStates -> m_bDrawProgress set to 0 OFFSET_DEFAULT(LoadingProgress__SetupControlStatesBoolOffset, 7, 5) From 7700ed8f2de1ebf0406e951afd97b1436d4a7088 Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Wed, 4 Nov 2026 16:04:02 -0600 Subject: [PATCH 4/6] feat: sar_unlocked_chapters also unlocks coop maps in the linux main-menu challenge mode list Linux inlines the MP.complete title data read into CLeaderboardMapItem::SetChapterAndMapInfo, so patch the point where its completion checks meet with a call to a stub that sets the result for maps of courses up to sar_unlocked_chapters. --- src/Modules/Client.cpp | 52 +++++++++++++++++++++++++++++++++- src/Offsets/Portal 2 10090.hpp | 2 ++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/Modules/Client.cpp b/src/Modules/Client.cpp index 5aa021567..640568696 100644 --- a/src/Modules/Client.cpp +++ b/src/Modules/Client.cpp @@ -1035,7 +1035,7 @@ Hook g_IsLevelCompleteHook(&Client::IsLevelComplete_Hook); #ifdef _WIN32 // Outside a game, the leaderboard list reads each coop map's MP.complete title data bit -// through this helper instead (its only caller). Linux inlines it, so this part is Windows only. +// through this helper instead (its only caller). using _TitleDataGetBool = bool(__cdecl *)(void *field, void *titleData); static _TitleDataGetBool TitleDataGetBool; static bool g_unlockLeaderboardMapItem = false; @@ -1063,6 +1063,44 @@ DETOUR_T(void, Client::SetChapterAndMapInfo, int chapter, int map, int a4, int c g_unlockLeaderboardMapItem = false; } Hook g_SetChapterAndMapInfoHook(&Client::SetChapterAndMapInfo_Hook); +#else +// Linux inlines that helper into SetChapterAndMapInfo, which also takes its arguments in registers. +// Both of its completion checks meet at "mov eax, [ebp]; mov ebx, [eax + 0x28]; test dl, dl" with +// the result in dl and the map item in esi, so those first 6 bytes become a call to this stub. It +// redoes them, then sets dl for maps of unlocked courses (the item's chapter is at +0x1A0). +Memory::Patch *g_leaderboardMapItemPatch; + +extern "C" { +__attribute__((used)) static bool LeaderboardMapItemUnlocked(int chapter) { + return chapter <= sar_unlocked_chapters.GetInt(); +} +__attribute__((visibility("hidden"))) void LeaderboardMapItemComplete_Stub(); +} + +asm(R"( + .text + .globl LeaderboardMapItemComplete_Stub + .hidden LeaderboardMapItemComplete_Stub + .p2align 4 +LeaderboardMapItemComplete_Stub: + .intel_syntax noprefix + mov eax, [ebp] + mov ebx, [eax + 0x28] + test dl, dl + jnz 1f + push ebp + mov ebp, esp + and esp, -16 + sub esp, 12 + push dword ptr [esi + 0x1A0] + call LeaderboardMapItemUnlocked + mov esp, ebp + pop ebp + mov edx, eax +1: + ret + .att_syntax prefix +)"); #endif bool Client::Init() { @@ -1349,6 +1387,14 @@ bool Client::Init() { g_SetChapterAndMapInfoHook.SetFunc(Client::SetChapterAndMapInfo); g_TitleDataGetBoolHook.SetFunc(TitleDataGetBool); } +#else + g_leaderboardMapItemPatch = new Memory::Patch(); + auto completeCheck = Memory::Scan(this->Name(), Offsets::LeaderboardMapItemComplete, Offsets::LeaderboardMapItemCompleteOff); + if (completeCheck) { + unsigned char callStub[6] = {0xE8, 0, 0, 0, 0, 0x90}; + *(uint32_t *)(callStub + 1) = (uintptr_t)&LeaderboardMapItemComplete_Stub - (completeCheck + 5); + g_leaderboardMapItemPatch->Execute(completeCheck, callStub); + } #endif } @@ -1406,6 +1452,10 @@ void Client::Shutdown() { g_drawPortalGhostPatch->Restore(); SAFE_DELETE(g_drawPortalPatch); SAFE_DELETE(g_drawPortalGhostPatch); +#ifndef _WIN32 + if (g_leaderboardMapItemPatch) g_leaderboardMapItemPatch->Restore(); + SAFE_DELETE(g_leaderboardMapItemPatch); +#endif } Client *client; diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index 3e4cd674b..f466d21e1 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -446,6 +446,8 @@ SIGSCAN_DEFAULT(SetChapterAndMapInfo, "55 8B EC 81 EC 20 02 00 00 53 8B 5D 08 57 "") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo (Linux: custom calling convention) SIGSCAN_DEFAULT(TitleDataGetBool, "55 8B EC 8B 45 08 8B 4D 0C 8B 11 8B 52 14 56 8B 70 0C 8B 40 04 57 50 FF D2", "") // CLeaderboardMapItem::SetChapterAndMapInfo -> "MP.complete.%s" title data bit read (Linux: inlined) +SIGSCAN_DEFAULT(LeaderboardMapItemComplete, "", "83 E2 01 8B 2D ? ? ? ? 8B 45 00 8B 58 28 84 D2 74 ? FF B6 A8 01 00 00") // CLeaderboardMapItem::SetChapterAndMapInfo -> where its two completion checks meet +OFFSET_DEFAULT(LeaderboardMapItemCompleteOff, 0, 9) SIGSCAN_DEFAULT(LoadingProgress__SetupControlStatesInstruction, "66 C7 86 ? ? ? ? ? ? EB", "66 89 83 ? ? ? ? E9 ? ? ? ? ? ? ? ? ? ? ? 85 F6") // "vgui/loading_screens/loadingscreen_coop" xref -> LoadingProgress::SetupControlStates -> m_bDrawProgress set to 0 OFFSET_DEFAULT(LoadingProgress__SetupControlStatesBoolOffset, 7, 5) From 49c609ae78b6b6f65cbc5c48cf460b6b772ba1d7 Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Wed, 4 Nov 2026 18:13:44 -0600 Subject: [PATCH 5/6] feat: sar_unlocked_chapters also unlocks the hub level select of unlocked coop courses The hub's level select screens and arrows use the IsLevelComplete script function and coop_lobby_select_level, which both read the server's real completion data, so a course that was only unlocked opened on its first map with the arrows off. Treat the maps of unlocked courses as completed in that script function and add coop_lobby_select_level's force argument for them. --- src/Modules/Server.cpp | 49 ++++++++++++++++++++++++++++++++++ src/Modules/Server.hpp | 3 +++ src/Offsets/Portal 2 10090.hpp | 4 +++ 3 files changed, 56 insertions(+) diff --git a/src/Modules/Server.cpp b/src/Modules/Server.cpp index e25d91167..6974be8e8 100644 --- a/src/Modules/Server.cpp +++ b/src/Modules/Server.cpp @@ -85,6 +85,7 @@ REDECL(Server::PlayerRunCommand); REDECL(Server::ViewPunch); REDECL(Server::IsInPVS); REDECL(Server::GetActiveBranches); +REDECL(Server::GameRulesClientCommand); REDECL(Server::ProcessMovement); REDECL(Server::GetPlayerViewOffset); REDECL(Server::StartTouchChallengeNode); @@ -421,6 +422,48 @@ DETOUR(Server::GetActiveBranches) { } Hook g_GetActiveBranches_Hook(&Server::GetActiveBranches_Hook); +// The hub's level select screens (and their arrow buttons) ask the script function +// IsLevelComplete(branch, level), which only scripts call. Treat the maps of courses 1 to N as +// completed there, like the client does for the menus. +using _ScriptIsLevelComplete = bool(__cdecl *)(int branch, int level); +static _ScriptIsLevelComplete ScriptIsLevelComplete; + +extern Hook g_ScriptIsLevelCompleteHook; +static bool __cdecl ScriptIsLevelComplete_Hook(int branch, int level) { + if (branch >= 0 && branch < sar_unlocked_chapters.GetInt()) + return true; + + g_ScriptIsLevelCompleteHook.Disable(); + auto ret = ScriptIsLevelComplete(branch, level); + g_ScriptIsLevelCompleteHook.Enable(); + return ret; +} +Hook g_ScriptIsLevelCompleteHook(&ScriptIsLevelComplete_Hook); + +// The arrows then send "coop_lobby_select_level ", which still won't go past +// the first map neither player has completed unless a third "force" argument is given (the map +// list does that). Add it for unlocked courses. +extern Hook g_GameRulesClientCommand_Hook; +DETOUR_T(bool, Server::GameRulesClientCommand, void *edict, const CCommand &args) { + auto selectLevel = args.ArgC() == 3 && !strcmp(args[0], "coop_lobby_select_level"); + auto branch = selectLevel ? std::atoi(args[1]) : 0; + auto unlocked = branch >= 1 && branch <= sar_unlocked_chapters.GetInt(); + + g_GameRulesClientCommand_Hook.Disable(); + bool ret; + if (unlocked) { + auto forced = args; + forced.m_nArgc = 4; + forced.m_ppArgv[3] = "1"; + ret = Server::GameRulesClientCommand(thisptr, edict, forced); + } else { + ret = Server::GameRulesClientCommand(thisptr, edict, args); + } + g_GameRulesClientCommand_Hook.Enable(); + return ret; +} +Hook g_GameRulesClientCommand_Hook(&Server::GameRulesClientCommand_Hook); + ON_INIT { NetMessage::RegisterHandler( CM_FLAGS_MESSAGE_TYPE, +[](const void *data, size_t size) { @@ -1019,6 +1062,12 @@ bool Server::Init() { Server::GetActiveBranches = (Server::_GetActiveBranches)Memory::Scan(this->Name(), Offsets::GetActiveBranches); g_GetActiveBranches_Hook.SetFunc(GetActiveBranches); + + ScriptIsLevelComplete = (_ScriptIsLevelComplete)Memory::Scan(this->Name(), Offsets::ScriptIsLevelComplete); + g_ScriptIsLevelCompleteHook.SetFunc(ScriptIsLevelComplete); + + Server::GameRulesClientCommand = (Server::_GameRulesClientCommand)Memory::Scan(this->Name(), Offsets::GameRulesClientCommand); + g_GameRulesClientCommand_Hook.SetFunc(GameRulesClientCommand); } NetMessage::RegisterHandler(RESET_COOP_PROGRESS_MESSAGE_TYPE, &netResetCoopProgress); diff --git a/src/Modules/Server.hpp b/src/Modules/Server.hpp index 194021706..8f6c9681d 100644 --- a/src/Modules/Server.hpp +++ b/src/Modules/Server.hpp @@ -91,6 +91,9 @@ class Server : public Module { // CPortalMPGameRules::GetActiveBranches DECL_DETOUR(GetActiveBranches); + // CPortalMPGameRules::ClientCommand + DECL_DETOUR_T(bool, GameRulesClientCommand, void *edict, const CCommand &args); + // CGameMovement::ProcessMovement DECL_DETOUR(ProcessMovement, void *pPlayer, CMoveData *pMove); diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index f466d21e1..aef2b3266 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -567,6 +567,10 @@ SIGSCAN_DEFAULT(FloorReportalBranch, "75 7D 8B 8E C0 04 00 00", SIGSCAN_DEFAULT(GetActiveBranches, "55 8B EC 83 EC 14 53 56 BA 01 00 00 00 8D B1 ? ? ? ? 81 C1 ? ? ? ? 57 C6 45 FE 01", "55 31 ED 57 56 53 83 EC 10 8B 44 24 24 C7 44 24 0C 01 00 00 00 C6 44 24 0B 01") // "Returns which branches should be available in the hub." xref -> GetHighestActiveBranch script binding -> CPortalMPGameRules::GetActiveBranches +SIGSCAN_DEFAULT(ScriptIsLevelComplete, "55 8B EC 8B 0D ? ? ? ? 85 C9 75 04 32 C0 5D C3 8B 55 0C 83 FA 0F 77 ? 8B 45 08 83 F8 05 77 ? C1 E0 04 03 C1 03 C2 80 B8 C1 1B 00 00 00", + "8B 15 ? ? ? ? 85 D2 74 ? 83 7C 24 08 0F 0F 97 C0 83 7C 24 04 05 0F 97 C1 08 C8 74 ? C3 90 8B 44 24 04 C1 E0 04 01 C2 03 54 24 08 0F B6 82 BD 1B 00 00") // "Returns true if the level in the specified branch is completed by either player." xref -> IsLevelComplete script function +SIGSCAN_DEFAULT(GameRulesClientCommand, "55 8B EC 51 53 56 8B 75 0C 83 3E 00 57 8B D9 BF ? ? ? ? 7E 06 8B BE 08 04 00 00 81 FF ? ? ? ? 74 12 68 ? ? ? ? 57 E8 ? ? ? ? 83 C4 08 85 C0 75 47 8B 06 83 F8 02", + "55 57 56 53 83 EC 2C 8B 6C 24 48 8B 5C 24 40 8B 74 24 44 8B 45 00 85 C0 7E 4E 8B BD 08 04 00 00 81 FF ? ? ? ? 75 68 83 F8 01 7E 28") // "coop_lobby_select_level" xref -> CPortalMPGameRules::ClientCommand SIGSCAN_DEFAULT(CPortal_Player__PollForUseEntity_CheckMP, "74 ? ? ? 8B 82 ? ? ? ? FF D0 84 C0 74 ? 8B CE", "74 ? 8B 10 83 EC 0C 50 FF 92 88 00 00 00 83 C4 10 84 C0 ? ? ? ? ? ? ? ? ? ? ? ? ? 00 00") // "OnJump" xref -> CPortal_Player:PreThink -> CBasePlayer::PreThink -> CBasePlayer::ItemPreFrame -> CBasePlayer::PlayerUse -> CPortal_Player vtable offset -> CPortal_Player::PlayerUse -> Second function call from disassembly -> CPortal_Player::PollForUseEntity -> jz instruction From b3166e2014507c1985c2b459cd90e84b5392e37b Mon Sep 17 00:00:00 2001 From: PortalRex <35444194+PortalRex@users.noreply.github.com> Date: Sun, 8 Nov 2026 14:05:21 -0600 Subject: [PATCH 6/6] Cut coop unlock down to the challenge mode list --- docs/cvars.md | 2 +- src/Modules/Client.cpp | 26 ++++++------- src/Modules/Client.hpp | 4 +- src/Modules/Server.cpp | 71 ---------------------------------- src/Modules/Server.hpp | 6 --- src/Offsets/Portal 2 10090.hpp | 9 +---- 6 files changed, 16 insertions(+), 102 deletions(-) diff --git a/docs/cvars.md b/docs/cvars.md index e76766e39..8bb915819 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -702,7 +702,7 @@ |sar_twitch_chat_channel||The Twitch channel to connect to.| |sar_twitch_chat_color|255 255 255|The color of the Twitch chat messages.| |sar_twitch_chat_enabled|0|Enables Twitch chat integration. 2 enables spectator command !spec| -|sar_unlocked_chapters|-1|Max unlocked chapter. Also unlocks coop courses up to this number (hub doors as host, level select and challenge mode maps) without marking them complete.| +|sar_unlocked_chapters|-1|Max unlocked chapter. Also unlocks the maps of coop courses up to this number in the challenge mode list.| |sar_update|cmd|sar_update [release\|pre\|canary] [exit\|restart] [force] - update SAR to the latest version. If exit is given, exit the game upon successful update; if force is given, always re-install, even if it may be a downgrade| |sar_velocitygraph|0|Shows velocity graph.| |sar_velocitygraph_background|0|Background of velocity graph.| diff --git a/src/Modules/Client.cpp b/src/Modules/Client.cpp index 640568696..97a0b63f5 100644 --- a/src/Modules/Client.cpp +++ b/src/Modules/Client.cpp @@ -85,7 +85,7 @@ Variable sar_patch_minor_angle_decay("sar_patch_minor_angle_decay", "0", "Patche #endif ); -Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter. Also unlocks coop courses up to this number (hub doors as host, level select and challenge mode maps) without marking them complete.\n"); +Variable sar_unlocked_chapters("sar_unlocked_chapters", "-1", "Max unlocked chapter. Also unlocks the maps of coop courses up to this number in the challenge mode list.\n"); Variable sar_portalcolor_enable("sar_portalcolor_enable", "0", "Enable custom portal colors.\n"); Variable sar_portalcolor_sp_1("sar_portalcolor_sp_1", "64 160 255", "Portal color for Chell's left portal. r_portal_fastpath 0 required.\n"); @@ -130,8 +130,8 @@ REDECL(Client::ApplyMouse_Mid_Continue); #endif REDECL(Client::DrawPortal); REDECL(Client::GetChapterProgress); -REDECL(Client::IsLevelComplete); #ifdef _WIN32 +REDECL(Client::IsLevelComplete); REDECL(Client::SetChapterAndMapInfo); #endif @@ -1018,12 +1018,16 @@ DETOUR(Client::GetChapterProgress) { } Hook g_GetChapterProgressHook(&Client::GetChapterProgress_Hook); -// The coop menus (hub level select, challenge mode and leaderboard lists) lock every map -// neither player has completed. Treat the maps of courses 1 to N as completed there; the -// real completion data is left alone. +// The coop challenge mode list locks every map neither player has completed. Treat the maps of +// courses 1 to N as completed there; the real completion data is left alone. +#ifdef _WIN32 +// SetChapterAndMapInfo checks completion through IsLevelComplete in game and through a title +// data helper (its only caller) outside one. Both answer true while it runs for an unlocked course. +static bool g_unlockLeaderboardMapItem = false; + extern Hook g_IsLevelCompleteHook; DETOUR_T(bool, Client::IsLevelComplete, int branch, int level) { - if (branch >= 0 && branch < sar_unlocked_chapters.GetInt()) + if (g_unlockLeaderboardMapItem) return true; g_IsLevelCompleteHook.Disable(); @@ -1033,12 +1037,8 @@ DETOUR_T(bool, Client::IsLevelComplete, int branch, int level) { } Hook g_IsLevelCompleteHook(&Client::IsLevelComplete_Hook); -#ifdef _WIN32 -// Outside a game, the leaderboard list reads each coop map's MP.complete title data bit -// through this helper instead (its only caller). using _TitleDataGetBool = bool(__cdecl *)(void *field, void *titleData); static _TitleDataGetBool TitleDataGetBool; -static bool g_unlockLeaderboardMapItem = false; extern Hook g_TitleDataGetBoolHook; static bool __cdecl TitleDataGetBool_Hook(void *field, void *titleData) { @@ -1378,12 +1378,12 @@ bool Client::Init() { g_GetChapterProgressHook.SetFunc(Client::GetChapterProgress); if (sar.game->Is(SourceGame_Portal2 | SourceGame_Portal2_2011)) { - Client::IsLevelComplete = (decltype(Client::IsLevelComplete))Memory::Scan(this->Name(), Offsets::IsLevelComplete); - g_IsLevelCompleteHook.SetFunc(Client::IsLevelComplete); #ifdef _WIN32 + Client::IsLevelComplete = (decltype(Client::IsLevelComplete))Memory::Scan(this->Name(), Offsets::IsLevelComplete); Client::SetChapterAndMapInfo = (decltype(Client::SetChapterAndMapInfo))Memory::Scan(this->Name(), Offsets::SetChapterAndMapInfo); TitleDataGetBool = (_TitleDataGetBool)Memory::Scan(this->Name(), Offsets::TitleDataGetBool); - if (Client::SetChapterAndMapInfo && TitleDataGetBool) { + if (Client::IsLevelComplete && Client::SetChapterAndMapInfo && TitleDataGetBool) { + g_IsLevelCompleteHook.SetFunc(Client::IsLevelComplete); g_SetChapterAndMapInfoHook.SetFunc(Client::SetChapterAndMapInfo); g_TitleDataGetBoolHook.SetFunc(TitleDataGetBool); } diff --git a/src/Modules/Client.hpp b/src/Modules/Client.hpp index c19057895..eb48aafdd 100644 --- a/src/Modules/Client.hpp +++ b/src/Modules/Client.hpp @@ -101,10 +101,10 @@ class Client : public Module { // CBaseModPanel::GetChapterProgress DECL_DETOUR(GetChapterProgress); +#ifdef _WIN32 // C_PortalMPGameRules::IsLevelComplete DECL_DETOUR_T(bool, IsLevelComplete, int branch, int level); -#ifdef _WIN32 // CLeaderboardMapItem::SetChapterAndMapInfo DECL_DETOUR_T(void, SetChapterAndMapInfo, int chapter, int map, int a4, int chapterProgress); #endif @@ -208,8 +208,6 @@ class Client : public Module { extern Client *client; -extern Variable sar_unlocked_chapters; - extern Variable cl_showpos; extern Variable cl_sidespeed; extern Variable cl_backspeed; diff --git a/src/Modules/Server.cpp b/src/Modules/Server.cpp index 6974be8e8..94d9f74ac 100644 --- a/src/Modules/Server.cpp +++ b/src/Modules/Server.cpp @@ -84,8 +84,6 @@ REDECL(Server::OnRemoveEntity); REDECL(Server::PlayerRunCommand); REDECL(Server::ViewPunch); REDECL(Server::IsInPVS); -REDECL(Server::GetActiveBranches); -REDECL(Server::GameRulesClientCommand); REDECL(Server::ProcessMovement); REDECL(Server::GetPlayerViewOffset); REDECL(Server::StartTouchChallengeNode); @@ -404,66 +402,6 @@ DETOUR_T(bool, Server::IsInPVS, void *info) { } Hook g_IsInPVS_Hook(&Server::IsInPVS_Hook); -// The coop hub script opens courses 1 to N for N = GetHighestActiveBranch(), which is this -// function. Raising N only opens the hub doors: the per-player completion data (and the -// achievements the hub awards from it) is left alone. -extern Hook g_GetActiveBranches_Hook; -DETOUR(Server::GetActiveBranches) { - g_GetActiveBranches_Hook.Disable(); - auto ret = Server::GetActiveBranches(thisptr); - g_GetActiveBranches_Hook.Enable(); - - if (sar_unlocked_chapters.GetInt() > -1) { - // 6 already opens every course; 7 means "all completed", don't fake that - ret = (std::max)(ret, (std::min)(sar_unlocked_chapters.GetInt(), 6)); - } - - return ret; -} -Hook g_GetActiveBranches_Hook(&Server::GetActiveBranches_Hook); - -// The hub's level select screens (and their arrow buttons) ask the script function -// IsLevelComplete(branch, level), which only scripts call. Treat the maps of courses 1 to N as -// completed there, like the client does for the menus. -using _ScriptIsLevelComplete = bool(__cdecl *)(int branch, int level); -static _ScriptIsLevelComplete ScriptIsLevelComplete; - -extern Hook g_ScriptIsLevelCompleteHook; -static bool __cdecl ScriptIsLevelComplete_Hook(int branch, int level) { - if (branch >= 0 && branch < sar_unlocked_chapters.GetInt()) - return true; - - g_ScriptIsLevelCompleteHook.Disable(); - auto ret = ScriptIsLevelComplete(branch, level); - g_ScriptIsLevelCompleteHook.Enable(); - return ret; -} -Hook g_ScriptIsLevelCompleteHook(&ScriptIsLevelComplete_Hook); - -// The arrows then send "coop_lobby_select_level ", which still won't go past -// the first map neither player has completed unless a third "force" argument is given (the map -// list does that). Add it for unlocked courses. -extern Hook g_GameRulesClientCommand_Hook; -DETOUR_T(bool, Server::GameRulesClientCommand, void *edict, const CCommand &args) { - auto selectLevel = args.ArgC() == 3 && !strcmp(args[0], "coop_lobby_select_level"); - auto branch = selectLevel ? std::atoi(args[1]) : 0; - auto unlocked = branch >= 1 && branch <= sar_unlocked_chapters.GetInt(); - - g_GameRulesClientCommand_Hook.Disable(); - bool ret; - if (unlocked) { - auto forced = args; - forced.m_nArgc = 4; - forced.m_ppArgv[3] = "1"; - ret = Server::GameRulesClientCommand(thisptr, edict, forced); - } else { - ret = Server::GameRulesClientCommand(thisptr, edict, args); - } - g_GameRulesClientCommand_Hook.Enable(); - return ret; -} -Hook g_GameRulesClientCommand_Hook(&Server::GameRulesClientCommand_Hook); - ON_INIT { NetMessage::RegisterHandler( CM_FLAGS_MESSAGE_TYPE, +[](const void *data, size_t size) { @@ -1059,15 +997,6 @@ bool Server::Init() { if (sar.game->Is(SourceGame_Portal2 | SourceGame_Portal2_2011)) { Server::IsInPVS = (Server::_IsInPVS)Memory::Scan(this->Name(), Offsets::IsInPVS); g_IsInPVS_Hook.SetFunc(IsInPVS); - - Server::GetActiveBranches = (Server::_GetActiveBranches)Memory::Scan(this->Name(), Offsets::GetActiveBranches); - g_GetActiveBranches_Hook.SetFunc(GetActiveBranches); - - ScriptIsLevelComplete = (_ScriptIsLevelComplete)Memory::Scan(this->Name(), Offsets::ScriptIsLevelComplete); - g_ScriptIsLevelCompleteHook.SetFunc(ScriptIsLevelComplete); - - Server::GameRulesClientCommand = (Server::_GameRulesClientCommand)Memory::Scan(this->Name(), Offsets::GameRulesClientCommand); - g_GameRulesClientCommand_Hook.SetFunc(GameRulesClientCommand); } NetMessage::RegisterHandler(RESET_COOP_PROGRESS_MESSAGE_TYPE, &netResetCoopProgress); diff --git a/src/Modules/Server.hpp b/src/Modules/Server.hpp index 8f6c9681d..04f44d00c 100644 --- a/src/Modules/Server.hpp +++ b/src/Modules/Server.hpp @@ -88,12 +88,6 @@ class Server : public Module { // CServerNetworkProperty::IsInPVS DECL_DETOUR_T(bool, IsInPVS, void *info); - // CPortalMPGameRules::GetActiveBranches - DECL_DETOUR(GetActiveBranches); - - // CPortalMPGameRules::ClientCommand - DECL_DETOUR_T(bool, GameRulesClientCommand, void *edict, const CCommand &args); - // CGameMovement::ProcessMovement DECL_DETOUR(ProcessMovement, void *pPlayer, CMoveData *pMove); diff --git a/src/Offsets/Portal 2 10090.hpp b/src/Offsets/Portal 2 10090.hpp index aef2b3266..f6d7ff1cf 100644 --- a/src/Offsets/Portal 2 10090.hpp +++ b/src/Offsets/Portal 2 10090.hpp @@ -441,7 +441,7 @@ SIGSCAN_EMPTY(FindElementSig) SIGSCAN_DEFAULT(GetChapterProgress, "56 8B 35 ? ? ? ? 57 8B F9 FF D6 8B 10 8B C8", "55 89 E5 57 56 53 83 EC 0C E8 ? ? ? ? 83 EC 08 8B 10") SIGSCAN_DEFAULT(IsLevelComplete, "55 8B EC 8B 55 0C 83 FA 0F 77 ? 8B 45 08 83 F8 05 77 ? C1 E0 04 03 C2 80 BC 08 B5 19 00 00 00", - "83 7C 24 0C 0F 8B 54 24 08 0F 97 C0 83 FA 05 0F 97 C1 08 C8 74") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo -> in-game branch -> C_PortalMPGameRules::IsLevelComplete + "") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo -> in-game branch -> C_PortalMPGameRules::IsLevelComplete (Linux: covered by LeaderboardMapItemComplete) SIGSCAN_DEFAULT(SetChapterAndMapInfo, "55 8B EC 81 EC 20 02 00 00 53 8B 5D 08 57 8B F9 89 7D F8 85 DB 0F 8E ? ? ? ? 8B 4D 0C 85 C9 0F 8E", "") // "#COOP_MAP_NAME_TR%d_MAP%d" xref -> CLeaderboardMapItem::SetChapterAndMapInfo (Linux: custom calling convention) SIGSCAN_DEFAULT(TitleDataGetBool, "55 8B EC 8B 45 08 8B 4D 0C 8B 11 8B 52 14 56 8B 70 0C 8B 40 04 57 50 FF D2", @@ -565,13 +565,6 @@ OFFSET_DEFAULT(aircontrol_fling_speedOff, 3, 3) SIGSCAN_DEFAULT(FloorReportalBranch, "75 7D 8B 8E C0 04 00 00", "75 ? 8B 85 ? ? ? ? 8B 0D") // "Portal.open_red" xref(nothing after if) -> CProp_Portal::NewLocation -> first function call CPortal_Base2D::NewLocation -> 4x func call followed by test, [jnz] -SIGSCAN_DEFAULT(GetActiveBranches, "55 8B EC 83 EC 14 53 56 BA 01 00 00 00 8D B1 ? ? ? ? 81 C1 ? ? ? ? 57 C6 45 FE 01", - "55 31 ED 57 56 53 83 EC 10 8B 44 24 24 C7 44 24 0C 01 00 00 00 C6 44 24 0B 01") // "Returns which branches should be available in the hub." xref -> GetHighestActiveBranch script binding -> CPortalMPGameRules::GetActiveBranches -SIGSCAN_DEFAULT(ScriptIsLevelComplete, "55 8B EC 8B 0D ? ? ? ? 85 C9 75 04 32 C0 5D C3 8B 55 0C 83 FA 0F 77 ? 8B 45 08 83 F8 05 77 ? C1 E0 04 03 C1 03 C2 80 B8 C1 1B 00 00 00", - "8B 15 ? ? ? ? 85 D2 74 ? 83 7C 24 08 0F 0F 97 C0 83 7C 24 04 05 0F 97 C1 08 C8 74 ? C3 90 8B 44 24 04 C1 E0 04 01 C2 03 54 24 08 0F B6 82 BD 1B 00 00") // "Returns true if the level in the specified branch is completed by either player." xref -> IsLevelComplete script function -SIGSCAN_DEFAULT(GameRulesClientCommand, "55 8B EC 51 53 56 8B 75 0C 83 3E 00 57 8B D9 BF ? ? ? ? 7E 06 8B BE 08 04 00 00 81 FF ? ? ? ? 74 12 68 ? ? ? ? 57 E8 ? ? ? ? 83 C4 08 85 C0 75 47 8B 06 83 F8 02", - "55 57 56 53 83 EC 2C 8B 6C 24 48 8B 5C 24 40 8B 74 24 44 8B 45 00 85 C0 7E 4E 8B BD 08 04 00 00 81 FF ? ? ? ? 75 68 83 F8 01 7E 28") // "coop_lobby_select_level" xref -> CPortalMPGameRules::ClientCommand - SIGSCAN_DEFAULT(CPortal_Player__PollForUseEntity_CheckMP, "74 ? ? ? 8B 82 ? ? ? ? FF D0 84 C0 74 ? 8B CE", "74 ? 8B 10 83 EC 0C 50 FF 92 88 00 00 00 83 C4 10 84 C0 ? ? ? ? ? ? ? ? ? ? ? ? ? 00 00") // "OnJump" xref -> CPortal_Player:PreThink -> CBasePlayer::PreThink -> CBasePlayer::ItemPreFrame -> CBasePlayer::PlayerUse -> CPortal_Player vtable offset -> CPortal_Player::PlayerUse -> Second function call from disassembly -> CPortal_Player::PollForUseEntity -> jz instruction