set variant wrapper
This commit is contained in:
parent
3cbe6e820c
commit
7e92887ad9
@ -3,6 +3,7 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Utils::Signal<Scheduler::Callback> Dvar::RegistrationSignal;
|
Utils::Signal<Scheduler::Callback> Dvar::RegistrationSignal;
|
||||||
|
std::vector<std::string> Dvar::ChangedDvars;
|
||||||
|
|
||||||
Dvar::Var::Var(const std::string& dvarName) : Var()
|
Dvar::Var::Var(const std::string& dvarName) : Var()
|
||||||
{
|
{
|
||||||
@ -258,9 +259,21 @@ namespace Components
|
|||||||
|
|
||||||
Game::dvar_t* Dvar::SetFromStringByNameExternal(const char* dvar, const char* value)
|
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);
|
return Game::Dvar_SetFromStringByNameFromSource(dvar, value, Game::DvarSetSource::DVAR_SOURCE_EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Dvar::ResetDvarsValue()
|
||||||
|
{
|
||||||
|
for (auto it = Dvar::ChangedDvars.begin(); it != Dvar::ChangedDvars.end(); ++it)
|
||||||
|
{
|
||||||
|
auto var = Dvar::Var(*it).get<Game::dvar_t*>();
|
||||||
|
Game::Dvar_SetVariant(var, var->reset, Game::DVAR_SOURCE_INTERNAL);
|
||||||
|
it = Dvar::ChangedDvars.erase(it);
|
||||||
|
--it; // Go back one step because of erase
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dvar::Dvar()
|
Dvar::Dvar()
|
||||||
{
|
{
|
||||||
// set flags of cg_drawFPS to archive
|
// set flags of cg_drawFPS to archive
|
||||||
@ -333,5 +346,6 @@ namespace Components
|
|||||||
Dvar::~Dvar()
|
Dvar::~Dvar()
|
||||||
{
|
{
|
||||||
Dvar::RegistrationSignal.clear();
|
Dvar::RegistrationSignal.clear();
|
||||||
|
Dvar::ChangedDvars.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ 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, 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);
|
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description);
|
||||||
|
|
||||||
|
static void ResetDvarsValue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Utils::Signal<Scheduler::Callback> RegistrationSignal;
|
static Utils::Signal<Scheduler::Callback> RegistrationSignal;
|
||||||
|
|
||||||
@ -57,5 +59,7 @@ namespace Components
|
|||||||
|
|
||||||
static Game::dvar_t* SetFromStringByNameExternal(const char* dvar, const char* value);
|
static Game::dvar_t* SetFromStringByNameExternal(const char* dvar, const char* value);
|
||||||
static Game::dvar_t* SetFromStringByNameSafeExternal(const char* dvar, const char* value);
|
static Game::dvar_t* SetFromStringByNameSafeExternal(const char* dvar, const char* value);
|
||||||
|
|
||||||
|
static std::vector<std::string> ChangedDvars;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,10 @@ namespace Components
|
|||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
call Friends::ClearServer
|
call Friends::ClearServer
|
||||||
|
call Dvar::ResetDvarsValue
|
||||||
|
|
||||||
popad
|
popad
|
||||||
|
|
||||||
push 467CC0h
|
push 467CC0h
|
||||||
|
@ -122,6 +122,7 @@ namespace Game
|
|||||||
Field_Clear_t Field_Clear = Field_Clear_t(0x437EB0);
|
Field_Clear_t Field_Clear = Field_Clear_t(0x437EB0);
|
||||||
|
|
||||||
FreeMemory_t FreeMemory = FreeMemory_t(0x4D6640);
|
FreeMemory_t FreeMemory = FreeMemory_t(0x4D6640);
|
||||||
|
Free_String_t Free_String = Free_String_t(0x470E80);
|
||||||
|
|
||||||
FS_FileExists_t FS_FileExists = FS_FileExists_t(0x4DEFA0);
|
FS_FileExists_t FS_FileExists = FS_FileExists_t(0x4DEFA0);
|
||||||
FS_FreeFile_t FS_FreeFile = FS_FreeFile_t(0x4416B0);
|
FS_FreeFile_t FS_FreeFile = FS_FreeFile_t(0x4416B0);
|
||||||
@ -1492,5 +1493,39 @@ namespace Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__declspec(naked) void Dvar_SetVariant(dvar_t*, DvarValue, DvarSetSource)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
pushad
|
||||||
|
|
||||||
|
mov ecx, [esp + 20h + 20h]
|
||||||
|
mov edx, [esp + 24h + 20h] // source
|
||||||
|
push edx
|
||||||
|
|
||||||
|
mov edx, [esp + 8h + 20h] // dvar pointer
|
||||||
|
|
||||||
|
sub esp, 10h // What does this mean for the offsets ? Copy paste
|
||||||
|
mov eax, esp
|
||||||
|
|
||||||
|
mov [eax], ecx // DvarValue ?? Legit have no clue
|
||||||
|
|
||||||
|
mov ecx, [esp + 0Ch+ 20h]
|
||||||
|
mov [eax + 4], edx // First arg is dvar pointer
|
||||||
|
mov edx, [esp + 10h + 20h]
|
||||||
|
mov [eax + 8], ecx
|
||||||
|
mov [eax + 0Ch], edx
|
||||||
|
mov eax, [esp + 8h + 20h] // var pointer
|
||||||
|
|
||||||
|
mov ebx, 0x647400
|
||||||
|
call ebx
|
||||||
|
add esp, 14h
|
||||||
|
|
||||||
|
popad
|
||||||
|
|
||||||
|
retn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma optimize("", on)
|
#pragma optimize("", on)
|
||||||
}
|
}
|
||||||
|
@ -298,6 +298,9 @@ namespace Game
|
|||||||
typedef void(__cdecl * FreeMemory_t)(void* buffer);
|
typedef void(__cdecl * FreeMemory_t)(void* buffer);
|
||||||
extern FreeMemory_t FreeMemory;
|
extern FreeMemory_t FreeMemory;
|
||||||
|
|
||||||
|
typedef void (__cdecl * Free_String_t)(const char* string);
|
||||||
|
extern Free_String_t Free_String;
|
||||||
|
|
||||||
typedef void(__cdecl * FS_FreeFile_t)(void* buffer);
|
typedef void(__cdecl * FS_FreeFile_t)(void* buffer);
|
||||||
extern FS_FreeFile_t FS_FreeFile;
|
extern FS_FreeFile_t FS_FreeFile;
|
||||||
|
|
||||||
@ -1074,4 +1077,6 @@ namespace Game
|
|||||||
|
|
||||||
void AimAssist_UpdateTweakables(int localClientNum);
|
void AimAssist_UpdateTweakables(int localClientNum);
|
||||||
void AimAssist_UpdateAdsLerp(const AimInput* input);
|
void AimAssist_UpdateAdsLerp(const AimInput* input);
|
||||||
|
|
||||||
|
void Dvar_SetVariant(dvar_t* var, DvarValue value, DvarSetSource source);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user