Using new asm wrapper made by laupetin
This commit is contained in:
parent
133d1b43d8
commit
d948024895
@ -190,6 +190,25 @@ namespace Components
|
||||
Dvar::RegistrationSignal.connect(callback);
|
||||
}
|
||||
|
||||
void Dvar::DvarReset(Game::dvar_t* var, Game::DvarSetSource source)
|
||||
{
|
||||
assert(var != nullptr);
|
||||
|
||||
Game::Dvar_SetVariant(var, var->reset, source);
|
||||
}
|
||||
|
||||
void Dvar::ResetDvarsValue()
|
||||
{
|
||||
auto it = Dvar::ChangedDvars.begin();
|
||||
while (it != Dvar::ChangedDvars.end())
|
||||
{
|
||||
auto var = Dvar::Var(*it).get<Game::dvar_t*>();
|
||||
assert(var != nullptr);
|
||||
Dvar::DvarReset(var, Game::DVAR_SOURCE_INTERNAL);
|
||||
it = Dvar::ChangedDvars.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
Game::dvar_t* Dvar::RegisterName(const char* name, const char* /*default*/, Game::dvar_flag flag, const char* description)
|
||||
{
|
||||
// Run callbacks
|
||||
@ -259,26 +278,13 @@ namespace Components
|
||||
|
||||
Game::dvar_t* Dvar::SetFromStringByNameExternal(const char* dvar, const char* value)
|
||||
{
|
||||
Dvar::ChangedDvars.push_back(dvar);
|
||||
return Game::Dvar_SetFromStringByNameFromSource(dvar, value, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL);
|
||||
}
|
||||
|
||||
void Dvar::Dvar_Reset(Game::dvar_t* var, Game::DvarSetSource source)
|
||||
void Dvar::DvarSetFromStringByNameStub(const char* var, const char* value)
|
||||
{
|
||||
assert(var != nullptr);
|
||||
OutputDebugStringA(Utils::String::VA("Dvar pointer: %p\n"));
|
||||
Game::Dvar_SetVariant(var, var->reset, source);
|
||||
}
|
||||
|
||||
void Dvar::ResetDvarsValue()
|
||||
{
|
||||
auto it = Dvar::ChangedDvars.begin();
|
||||
while (it != Dvar::ChangedDvars.end())
|
||||
{
|
||||
auto var = Dvar::Var(*it).get<Game::dvar_t*>();
|
||||
Dvar::Dvar_Reset(var, Game::DVAR_SOURCE_INTERNAL);
|
||||
it = Dvar::ChangedDvars.erase(it);
|
||||
}
|
||||
Dvar::ChangedDvars.push_back(var);
|
||||
Utils::Hook::Call<void(const char*, const char*)>(0x4F52E0)(var, value);
|
||||
}
|
||||
|
||||
Dvar::Dvar()
|
||||
@ -348,6 +354,9 @@ namespace Components
|
||||
|
||||
// Entirely block setting cheat dvars internally without sv_cheats
|
||||
//Utils::Hook(0x4F52EC, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
|
||||
|
||||
// Hook Dvar_SetFromStringByName inside CG_SetClientDvarFromServer so we can reset dvars when the player leaves the server
|
||||
Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick();
|
||||
}
|
||||
|
||||
Dvar::~Dvar()
|
||||
|
@ -50,17 +50,18 @@ namespace Components
|
||||
template<typename T> static Var Register(const char* name, T value, Flag flag, const char* description);
|
||||
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description);
|
||||
|
||||
static void Dvar_Reset(Game::dvar_t* var, Game::DvarSetSource source);
|
||||
static void DvarReset(Game::dvar_t* var, Game::DvarSetSource source);
|
||||
static void ResetDvarsValue();
|
||||
|
||||
private:
|
||||
static Utils::Signal<Scheduler::Callback> RegistrationSignal;
|
||||
static std::vector<std::string> ChangedDvars;
|
||||
|
||||
static Game::dvar_t* RegisterName(const char* name, const char* defaultVal, Game::dvar_flag flag, const char* description);
|
||||
|
||||
static Game::dvar_t* SetFromStringByNameExternal(const char* dvar, const char* value);
|
||||
static Game::dvar_t* SetFromStringByNameSafeExternal(const char* dvar, const char* value);
|
||||
|
||||
static std::vector<std::string> ChangedDvars;
|
||||
static void DvarSetFromStringByNameStub(const char* var, const char* value);
|
||||
};
|
||||
}
|
||||
|
@ -1055,22 +1055,20 @@ namespace Game
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push eax
|
||||
pushad
|
||||
|
||||
mov edi, [esp + 2Ch] // name
|
||||
push edi
|
||||
mov eax, [esp + 0x4 + 0x20] // dvar
|
||||
push[esp + 0x18 + 0x20] // source
|
||||
push[esp + 0x18 + 0x20] // value
|
||||
push[esp + 0x18 + 0x20] // value
|
||||
push[esp + 0x18 + 0x20] // value
|
||||
push[esp + 0x18 + 0x20] // value
|
||||
|
||||
mov edi, [esp + 2Ch] // type
|
||||
mov ebx, 0x647400
|
||||
call ebx
|
||||
add esp, 0x14
|
||||
|
||||
mov eax, 5BB1B0h
|
||||
call eax
|
||||
|
||||
add esp, 4h
|
||||
|
||||
mov [esp + 20h], eax
|
||||
popad
|
||||
pop eax
|
||||
|
||||
retn
|
||||
}
|
||||
@ -1493,7 +1491,7 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, int)
|
||||
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, DvarSetSource)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
|
@ -1077,6 +1077,6 @@ namespace Game
|
||||
|
||||
void AimAssist_UpdateTweakables(int localClientNum);
|
||||
void AimAssist_UpdateAdsLerp(const AimInput* input);
|
||||
|
||||
void Dvar_SetVariant(dvar_t* var, DvarValue value, int source);
|
||||
|
||||
void Dvar_SetVariant(dvar_t* var, DvarValue value, DvarSetSource source);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user