Add dvar to disable elevators entirely

This commit is contained in:
FutureRave 2021-11-29 17:16:18 +00:00
parent ed53211400
commit 79be9e12d5
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
2 changed files with 44 additions and 2 deletions

View File

@ -3,6 +3,7 @@
namespace Components namespace Components
{ {
Game::dvar_t* Elevators::SV_EnableEasyElevators; Game::dvar_t* Elevators::SV_EnableEasyElevators;
Game::dvar_t* Elevators::SV_DisableElevators;
__declspec(naked) void Elevators::PM_CorrectAllSolidStub() __declspec(naked) void Elevators::PM_CorrectAllSolidStub()
{ {
@ -63,6 +64,39 @@ namespace Components
} }
} }
__declspec(naked) void Elevators::PM_GroundTraceStub()
{
__asm
{
push eax
mov eax, Elevators::SV_DisableElevators
cmp byte ptr [eax + 16], 1
pop eax
// Always skip PM_CorrectAllSolid if SV_DisableElevators is set to 1
je noElevators
// Original code
cmp byte ptr [esp + 0x50], 0
rep movsd
mov esi, [esp + 0x58]
// Original code flow
push 0x573694
retn
noElevators:
// Original code
rep movsd
mov esi, [esp + 0x58]
// Jump over call to PM_CorrectAllSolid
push 0x5736AE
retn
}
}
Elevators::Elevators() Elevators::Elevators()
{ {
Dvar::OnInit([] Dvar::OnInit([]
@ -70,14 +104,20 @@ namespace Components
Elevators::SV_EnableEasyElevators = Game::Dvar_RegisterBool("sv_enableEasyElevators", Elevators::SV_EnableEasyElevators = Game::Dvar_RegisterBool("sv_enableEasyElevators",
false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
"Enable easy elevators for trickshotting"); "Enable easy elevators for trickshotting");
Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators",
false, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED,
"Disable elevators");
}); });
// Place hook PM_CorrectAllSolid so we may skip PM_Trace check // Hook PM_CorrectAllSolid so we may skip PM_Trace check
Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5734F9, Elevators::PM_CorrectAllSolidStub, HOOK_JUMP).install()->quick();
Utils::Hook::Nop(0x5734FE, 1); Utils::Hook::Nop(0x5734FE, 1);
// Place hook PM_CheckDuck so we may skip PM_Trace check // Hook PM_CheckDuck so we may skip PM_Trace check
Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x570ECD, Elevators::PM_CheckDuckStub, HOOK_JUMP).install()->quick();
// Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators)
Utils::Hook(0x573689, Elevators::PM_GroundTraceStub, HOOK_JUMP).install()->quick();
} }
Elevators::~Elevators() Elevators::~Elevators()

View File

@ -10,8 +10,10 @@ namespace Components
private: private:
static Game::dvar_t* SV_EnableEasyElevators; static Game::dvar_t* SV_EnableEasyElevators;
static Game::dvar_t* SV_DisableElevators;
static void PM_CorrectAllSolidStub(); static void PM_CorrectAllSolidStub();
static void PM_CheckDuckStub(); static void PM_CheckDuckStub();
static void PM_GroundTraceStub();
}; };
} }