Merge pull request #357 from Brentdevent/dvar_sessionmode

Fix registering sessionmode bool dvars
This commit is contained in:
Maurice Heumann 2023-03-20 21:49:06 +01:00 committed by GitHub
commit 1f70006719
3 changed files with 20 additions and 5 deletions

View File

@ -108,19 +108,22 @@ namespace game
const char* description)> Dvar_RegisterBool{ const char* description)> Dvar_RegisterBool{
0x1422D0900, 0x14057B500 0x1422D0900, 0x14057B500
}; };
WEAK symbol<dvar_t* (dvarStrHash_t hash, const char* dvarName, bool value, dvarFlags_e flags, WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, dvarFlags_e flags,
const char* description)> Dvar_SessionModeRegisterBool{ const char* description)> Dvar_SessionModeRegisterBool{
0x1422D0D40, 0x14057BAA0 0x1422D0D40, 0x14057BAA0
}; };
WEAK symbol<void(dvarStrHash_t hash, bool value, eModes mode)> Dvar_SessionModeSetDefaultBool{
0x1422D0E90, 0x14057BCE0
};
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, const char* value, dvarFlags_e flags, WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, const char* value, dvarFlags_e flags,
const char* description)> Dvar_RegisterString{ const char* description)> Dvar_RegisterString{
0x1422D0B70 0x1422D0B70
}; };
WEAK symbol<void (void (*callback)(const dvar_t*, void*), void* userData)> Dvar_ForEach{0x1422BCD00}; WEAK symbol<void(void (*callback)(const dvar_t*, void*), void* userData)> Dvar_ForEach{0x1422BCD00};
WEAK symbol<void(const char* dvarName, const char* string, bool createIfMissing)> Dvar_SetFromStringByName{ WEAK symbol<void(const char* dvarName, const char* string, bool createIfMissing)> Dvar_SetFromStringByName{
0x1422C7500 0x1422C7500
}; };
WEAK symbol<dvar_t* (dvar_t* dvar, eModes mode)> Dvar_GetSessionModeSpecificDvar{ WEAK symbol<dvar_t*(dvar_t* dvar, eModes mode)> Dvar_GetSessionModeSpecificDvar{
0x1422BF500, 0x140575D90 0x1422BF500, 0x140575D90
}; };

View File

@ -38,7 +38,7 @@ namespace game
return dvar->current.value.enabled; return dvar->current.value.enabled;
} }
dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description) dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode)
{ {
const auto hash = Dvar_GenerateHash(dvar_name); const auto hash = Dvar_GenerateHash(dvar_name);
auto registered_dvar = Dvar_SessionModeRegisterBool(hash, dvar_name, value, flags, description); auto registered_dvar = Dvar_SessionModeRegisterBool(hash, dvar_name, value, flags, description);
@ -46,6 +46,18 @@ namespace game
if (registered_dvar) if (registered_dvar)
{ {
registered_dvar->debugName = dvar_name; registered_dvar->debugName = dvar_name;
if (mode == MODE_COUNT)
{
for (int i = MODE_FIRST; i < MODE_COUNT; ++i)
{
game::Dvar_SessionModeSetDefaultBool.call_safe(hash, value, static_cast<eModes>(i));
}
}
else
{
game::Dvar_SessionModeSetDefaultBool.call_safe(hash, value, mode);
}
} }
return registered_dvar; return registered_dvar;

View File

@ -9,7 +9,7 @@ namespace game
bool get_dvar_bool(const char* dvar_name); bool get_dvar_bool(const char* dvar_name);
dvar_t* register_dvar_bool(const char* dvar_name, bool value, dvarFlags_e flags, const char* description); dvar_t* register_dvar_bool(const char* dvar_name, bool value, dvarFlags_e flags, const char* description);
dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description); dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, const bool value, const dvarFlags_e flags, const char* description, const eModes mode = MODE_COUNT);
void dvar_add_flags(const char* dvar, dvarFlags_e flags); void dvar_add_flags(const char* dvar, dvarFlags_e flags);
void dvar_set_flags(const char* dvar_name, dvarFlags_e flags); void dvar_set_flags(const char* dvar_name, dvarFlags_e flags);
} }