Merge pull request #148 from diamante0018/feature/elevators
[Feature] Add options to disable elevators
This commit is contained in:
commit
bdfc7f562c
@ -105,6 +105,7 @@ namespace Components
|
||||
Loader::Register(new Chat());
|
||||
Loader::Register(new TextRenderer());
|
||||
Loader::Register(new Movement());
|
||||
Loader::Register(new Elevators());
|
||||
|
||||
Loader::Register(new Client());
|
||||
|
||||
|
@ -133,6 +133,7 @@ namespace Components
|
||||
#include "Modules/Chat.hpp"
|
||||
#include "Modules/TextRenderer.hpp"
|
||||
#include "Modules/Movement.hpp"
|
||||
#include "Modules/Elevators.hpp"
|
||||
|
||||
#include "Modules/Gamepad.hpp"
|
||||
#include "Modules/Client.hpp"
|
||||
|
55
src/Components/Modules/Elevators.cpp
Normal file
55
src/Components/Modules/Elevators.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Game::dvar_t* Elevators::SV_DisableElevators;
|
||||
|
||||
__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()
|
||||
{
|
||||
Dvar::OnInit([]
|
||||
{
|
||||
Elevators::SV_DisableElevators = Game::Dvar_RegisterBool("sv_disableElevators",
|
||||
false, Game::DVAR_FLAG_REPLICATED, "Disable elevators");
|
||||
});
|
||||
|
||||
// Hook PM_GroundTrace so me way skip PM_CorrectAllSolid (disable elevators)
|
||||
Utils::Hook(0x573689, Elevators::PM_GroundTraceStub, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
|
||||
Elevators::~Elevators()
|
||||
{
|
||||
}
|
||||
}
|
16
src/Components/Modules/Elevators.hpp
Normal file
16
src/Components/Modules/Elevators.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Elevators : public Component
|
||||
{
|
||||
public:
|
||||
Elevators();
|
||||
~Elevators();
|
||||
|
||||
private:
|
||||
static Game::dvar_t* SV_DisableElevators;
|
||||
|
||||
static void PM_GroundTraceStub();
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user