New asm wrapper
This commit is contained in:
parent
7e92887ad9
commit
133d1b43d8
@ -263,14 +263,21 @@ namespace Components
|
||||
return Game::Dvar_SetFromStringByNameFromSource(dvar, value, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL);
|
||||
}
|
||||
|
||||
void Dvar::Dvar_Reset(Game::dvar_t* var, Game::DvarSetSource source)
|
||||
{
|
||||
assert(var != nullptr);
|
||||
OutputDebugStringA(Utils::String::VA("Dvar pointer: %p\n"));
|
||||
Game::Dvar_SetVariant(var, var->reset, source);
|
||||
}
|
||||
|
||||
void Dvar::ResetDvarsValue()
|
||||
{
|
||||
for (auto it = Dvar::ChangedDvars.begin(); it != Dvar::ChangedDvars.end(); ++it)
|
||||
auto it = Dvar::ChangedDvars.begin();
|
||||
while (it != Dvar::ChangedDvars.end())
|
||||
{
|
||||
auto var = Dvar::Var(*it).get<Game::dvar_t*>();
|
||||
Game::Dvar_SetVariant(var, var->reset, Game::DVAR_SOURCE_INTERNAL);
|
||||
Dvar::Dvar_Reset(var, Game::DVAR_SOURCE_INTERNAL);
|
||||
it = Dvar::ChangedDvars.erase(it);
|
||||
--it; // Go back one step because of erase
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ 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 ResetDvarsValue();
|
||||
|
||||
private:
|
||||
|
@ -1493,29 +1493,31 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, DvarSetSource)
|
||||
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, int)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
|
||||
mov ecx, [esp + 20h + 20h]
|
||||
mov edx, [esp + 24h + 20h] // source
|
||||
push edx
|
||||
mov edx, [esp + 8h + 20h] // First 4 bytes of DvarValue
|
||||
mov ecx, [esp + 18h + 20h] // Source
|
||||
push ecx // Push from right to left
|
||||
|
||||
mov edx, [esp + 8h + 20h] // dvar pointer
|
||||
mov ecx, [esp + 8h + 20h] // dvar_t pointer, because of last push it's not at esp + 4 anymore
|
||||
|
||||
sub esp, 10h // What does this mean for the offsets ? Copy paste
|
||||
sub esp, 10h // Reserve space for DvarValue
|
||||
mov eax, esp
|
||||
|
||||
mov [eax], ecx // DvarValue ?? Legit have no clue
|
||||
mov [eax], edx // DvarValue
|
||||
|
||||
mov ecx, [esp + 0Ch+ 20h]
|
||||
mov [eax + 4], edx // First arg is dvar pointer
|
||||
mov edx, [esp + 10h + 20h]
|
||||
mov [eax + 8], ecx
|
||||
// 20h + 10h because of sub esp, 10h
|
||||
mov edx, [esp + 10h + 30h] // Second 4 bytes of DvarValue
|
||||
mov [eax + 4], edx
|
||||
mov edx, [esp + 16h + 30h] // Third 4 bytes of DvarValue
|
||||
mov [eax + 8], edx
|
||||
mov edx, [esp + 1Ah + 30h] // Fourth 4 bytes of DvarValue
|
||||
mov [eax + 0Ch], edx
|
||||
mov eax, [esp + 8h + 20h] // var pointer
|
||||
mov eax, [ecx] // dvar_t pointer
|
||||
|
||||
mov ebx, 0x647400
|
||||
call ebx
|
||||
|
@ -1078,5 +1078,5 @@ namespace Game
|
||||
void AimAssist_UpdateTweakables(int localClientNum);
|
||||
void AimAssist_UpdateAdsLerp(const AimInput* input);
|
||||
|
||||
void Dvar_SetVariant(dvar_t* var, DvarValue value, DvarSetSource source);
|
||||
void Dvar_SetVariant(dvar_t* var, DvarValue value, int source);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user