tiny cleanup of find dvar
This commit is contained in:
parent
7ab8f9d891
commit
95715fb819
@ -669,7 +669,6 @@ namespace command
|
||||
|
||||
const auto name = params.get(1);
|
||||
const auto dvar = game::Dvar_FindVar(name);
|
||||
|
||||
if (dvar == nullptr)
|
||||
{
|
||||
console::info("%s doesn't exist\n", name);
|
||||
|
@ -21,7 +21,7 @@ namespace dedicated_info
|
||||
|
||||
scheduler::loop([]
|
||||
{
|
||||
auto* sv_running = game::Dvar_FindVar("sv_running");
|
||||
const auto sv_running = game::Dvar_FindVar("sv_running");
|
||||
if (!sv_running || !sv_running->current.enabled || (*game::mp::svs_clients) == nullptr)
|
||||
{
|
||||
SetConsoleTitle("H1-Mod Dedicated Server");
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "fastfiles.hpp"
|
||||
#include "mods.hpp"
|
||||
|
||||
#include "game/dvars.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "game/ui_scripting/execution.hpp"
|
||||
|
||||
@ -57,6 +58,8 @@ namespace party
|
||||
utils::info_string info_string{};
|
||||
} saved_info_response;
|
||||
|
||||
const game::dvar_t* sv_say_name = nullptr;
|
||||
|
||||
void perform_game_initialization()
|
||||
{
|
||||
command::execute("onlinegame 1", true);
|
||||
@ -908,8 +911,7 @@ namespace party
|
||||
|
||||
scheduler::once([]()
|
||||
{
|
||||
const auto hash = game::generateHashValue("sv_sayName");
|
||||
game::Dvar_RegisterString(hash, "sv_sayName", "console", game::DvarFlags::DVAR_FLAG_NONE);
|
||||
sv_say_name = dvars::register_string("sv_sayName", "console", game::DvarFlags::DVAR_FLAG_NONE);
|
||||
}, scheduler::pipeline::main);
|
||||
|
||||
command::add("tell", [](const command::params& params)
|
||||
@ -921,7 +923,7 @@ namespace party
|
||||
|
||||
const auto client_num = atoi(params.get(1));
|
||||
const auto message = params.join(2);
|
||||
const auto* const name = game::Dvar_FindVar("sv_sayName")->current.string;
|
||||
const auto* const name = sv_say_name->current.string;
|
||||
|
||||
game::SV_GameSendServerCommand(client_num, game::SV_CMD_CAN_IGNORE,
|
||||
utils::string::va("%c \"%s: %s\"", 84, name, message.data()));
|
||||
@ -951,7 +953,7 @@ namespace party
|
||||
}
|
||||
|
||||
const auto message = params.join(1);
|
||||
const auto* const name = game::Dvar_FindVar("sv_sayName")->current.string;
|
||||
const auto* const name = sv_say_name->current.string;
|
||||
|
||||
game::SV_GameSendServerCommand(
|
||||
-1, game::SV_CMD_CAN_IGNORE, utils::string::va("%c \"%s: %s\"", 84, name, message.data()));
|
||||
|
Loading…
Reference in New Issue
Block a user