From c218aa89ecca036f324ceddd98a1ea936008a2af Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sat, 9 Apr 2022 14:29:58 +0200 Subject: [PATCH] Better stub for PM_IsAdsAllowed --- src/Game/Functions.cpp | 22 +++++++++++++--------- src/Game/Functions.hpp | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 95a3c7e9..343f2f31 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -1100,19 +1100,23 @@ namespace Game } } - bool PM_IsAdsAllowed(Game::playerState_s* playerState) + __declspec(naked) bool PM_IsAdsAllowed(playerState_s* /*ps*/) { - bool result; - __asm { - mov esi, playerState - mov ebx, 0x5755A0 - call ebx - mov result, al // AL - } + push eax + pushad - return result; + mov esi, [esp + 0x24 + 0x4] // ps + mov ecx, 0x5755A0 + call ecx + + mov [esp + 0x20], eax + popad + pop eax + + ret + } } __declspec(naked) void FS_AddLocalizedGameDirectory(const char* /*path*/, const char* /*dir*/) diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 5ec72a9b..3e10f37a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1069,7 +1069,7 @@ namespace Game void FS_AddLocalizedGameDirectory(const char *path, const char *dir); - bool PM_IsAdsAllowed(Game::playerState_s* playerState); + bool PM_IsAdsAllowed(playerState_s* ps); void ShowMessageBox(const std::string& message, const std::string& title);