Merge pull request #454 from diamante0018/main

getinfo: add sv_running & more utils
This commit is contained in:
Maurice Heumann 2023-04-07 14:31:18 +02:00 committed by GitHub
commit fedcfecc20
4 changed files with 20 additions and 1 deletions

View File

@ -109,7 +109,7 @@ namespace getinfo
info.set("protocol", utils::string::va("%i", PROTOCOL)); info.set("protocol", utils::string::va("%i", PROTOCOL));
info.set("playmode", utils::string::va("%i", game::Com_SessionMode_GetMode())); info.set("playmode", utils::string::va("%i", game::Com_SessionMode_GetMode()));
info.set("gamemode", utils::string::va("%i", Com_SessionMode_GetGameMode())); info.set("gamemode", utils::string::va("%i", Com_SessionMode_GetGameMode()));
//info.set("sv_running", utils::string::va("%i", get_dvar_bool("sv_running"))); info.set("sv_running", utils::string::va("%i", game::get_dvar_bool("sv_running")));
info.set("dedicated", utils::string::va("%i", game::is_server() ? 1 : 0)); info.set("dedicated", utils::string::va("%i", game::is_server() ? 1 : 0));
info.set("shortversion", SHORTVERSION); info.set("shortversion", SHORTVERSION);

View File

@ -105,10 +105,15 @@ namespace game
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_DisplayableValue{0x1422BC080}; WEAK symbol<const char*(const dvar_t* dvar)> Dvar_DisplayableValue{0x1422BC080};
WEAK symbol<bool(const dvar_t* dvar)> Dvar_GetBool{0x1422BCED0}; WEAK symbol<bool(const dvar_t* dvar)> Dvar_GetBool{0x1422BCED0};
WEAK symbol<int(const dvar_t* dvar)> Dvar_GetInt{0x0, 0x140575C20}; WEAK symbol<int(const dvar_t* dvar)> Dvar_GetInt{0x0, 0x140575C20};
WEAK symbol<float(const dvar_t* dvar)> Dvar_GetFLoat{0x0, 0x140575B20};
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags, WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags,
const char* description)> Dvar_RegisterBool{ const char* description)> Dvar_RegisterBool{
0x1422D0900, 0x14057B500 0x1422D0900, 0x14057B500
}; };
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, float value, float min, float max, unsigned int flags,
const char* description)> Dvar_RegisterFloat{
0x0, 0x14057B6B0
};
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags, WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, int flags,
const char* description)> Dvar_SessionModeRegisterBool{ const char* description)> Dvar_SessionModeRegisterBool{
0x1422D0D40, 0x14057BAA0 0x1422D0D40, 0x14057BAA0

View File

@ -83,6 +83,19 @@ namespace game
return registered_dvar; return registered_dvar;
} }
const dvar_t* register_dvar_float(const char* dvar_name, float value, float min, float max, const int flags, const char* description)
{
const auto hash = Dvar_GenerateHash(dvar_name);
auto* registered_dvar = Dvar_RegisterFloat(hash, dvar_name, value, min, max, flags, description);
if (registered_dvar)
{
registered_dvar->debugName = dvar_name;
}
return registered_dvar;
}
const dvar_t* register_dvar_string(const char* dvar_name, const char* value, const int flags, const char* description) const dvar_t* register_dvar_string(const char* dvar_name, const char* value, const int flags, const char* description)
{ {
const auto hash = Dvar_GenerateHash(dvar_name); const auto hash = Dvar_GenerateHash(dvar_name);

View File

@ -9,6 +9,7 @@ namespace game
bool get_dvar_bool(const char* dvar_name); bool get_dvar_bool(const char* dvar_name);
const dvar_t* register_dvar_bool(const char* dvar_name, bool value, int flags, const char* description); const dvar_t* register_dvar_bool(const char* dvar_name, bool value, int flags, const char* description);
const dvar_t* register_dvar_float(const char* dvar_name, float value, float min, float max, const int flags, const char* description);
const dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, bool value, int flags, const char* description, eModes mode = MODE_COUNT); const dvar_t* register_sessionmode_dvar_bool(const char* dvar_name, bool value, int flags, const char* description, eModes mode = MODE_COUNT);
const dvar_t* register_dvar_string(const char* dvar_name, const char* value, int flags, const char* description); const dvar_t* register_dvar_string(const char* dvar_name, const char* value, int flags, const char* description);
void dvar_add_flags(const char* dvar, dvarFlags_e flags); void dvar_add_flags(const char* dvar, dvarFlags_e flags);