unnecessary use of Dvar_FindVar

This commit is contained in:
m 2022-10-10 13:10:40 -05:00
parent 4e348abaf1
commit 3dde666c15

View File

@ -20,6 +20,8 @@ namespace dedicated
utils::hook::detour gscr_set_dynamic_dvar_hook; utils::hook::detour gscr_set_dynamic_dvar_hook;
utils::hook::detour com_quit_f_hook; utils::hook::detour com_quit_f_hook;
const game::dvar_t* sv_lanOnly;
void init_dedicated_server() void init_dedicated_server()
{ {
static bool initialized = false; static bool initialized = false;
@ -32,8 +34,7 @@ namespace dedicated
void send_heartbeat() void send_heartbeat()
{ {
auto* const dvar = game::Dvar_FindVar("sv_lanOnly"); if (sv_lanOnly->current.enabled)
if (dvar && dvar->current.enabled)
{ {
return; return;
} }
@ -194,7 +195,7 @@ namespace dedicated
dvars::register_bool("dedicated", true, game::DVAR_FLAG_READ, "Dedicated server"); dvars::register_bool("dedicated", true, game::DVAR_FLAG_READ, "Dedicated server");
// Add lanonly mode // Add lanonly mode
dvars::register_bool("sv_lanOnly", false, game::DVAR_FLAG_NONE, "Don't send heartbeat"); sv_lanOnly = dvars::register_bool("sv_lanOnly", false, game::DVAR_FLAG_NONE, "Don't send heartbeat");
// Disable VirtualLobby // Disable VirtualLobby
dvars::override::register_bool("virtualLobbyEnabled", false, game::DVAR_FLAG_READ); dvars::override::register_bool("virtualLobbyEnabled", false, game::DVAR_FLAG_READ);