This commit is contained in:
Skull Merlin 2022-03-01 20:03:13 +02:00
parent 9b4316d3e0
commit 7545e78005

View File

@ -18,46 +18,46 @@ namespace dedicated_info
} }
scheduler::loop([]() scheduler::loop([]()
{
auto* sv_running = game::Dvar_FindVar("sv_running");
if (!sv_running || !sv_running->current.enabled)
{ {
auto* sv_running = game::Dvar_FindVar("sv_running"); console::set_title("H1-Mod Dedicated Server");
if (!sv_running || !sv_running->current.enabled) return;
}
auto* const sv_hostname = game::Dvar_FindVar("sv_hostname");
auto* const sv_maxclients = game::Dvar_FindVar("sv_maxclients");
auto* const mapname = game::Dvar_FindVar("mapname");
auto bot_count = 0;
auto client_count = 0;
for (auto i = 0; i < sv_maxclients->current.integer; i++)
{
auto* client = &game::mp::svs_clients[i];
auto* self = &game::mp::g_entities[i];
if (client->header.state >= 1 && self && self->client)
{ {
console::set_title("H1-Mod Dedicated Server"); client_count++;
return; if (game::SV_BotIsBot(i))
}
auto* const sv_hostname = game::Dvar_FindVar("sv_hostname");
auto* const sv_maxclients = game::Dvar_FindVar("sv_maxclients");
auto* const mapname = game::Dvar_FindVar("mapname");
auto bot_count = 0;
auto client_count = 0;
for (auto i = 0; i < sv_maxclients->current.integer; i++)
{
auto* client = &game::mp::svs_clients[i];
auto* self = &game::mp::g_entities[i];
if (client->header.state >= 1 && self && self->client)
{ {
client_count++; ++bot_count;
if (game::SV_BotIsBot(i))
{
++bot_count;
}
} }
} }
}
std::string cleaned_hostname; std::string cleaned_hostname;
cleaned_hostname.resize(static_cast<int>(strlen(sv_hostname->current.string) + 1)); cleaned_hostname.resize(static_cast<int>(strlen(sv_hostname->current.string) + 1));
utils::string::strip(sv_hostname->current.string, cleaned_hostname.data(), utils::string::strip(sv_hostname->current.string, cleaned_hostname.data(),
static_cast<int>(strlen(sv_hostname->current.string)) + 1); static_cast<int>(strlen(sv_hostname->current.string)) + 1);
console::set_title(utils::string::va("%s on %s [%d/%d] (%d)", cleaned_hostname.data(), console::set_title(utils::string::va("%s on %s [%d/%d] (%d)", cleaned_hostname.data(),
mapname->current.string, client_count, mapname->current.string, client_count,
sv_maxclients->current.integer, bot_count)); sv_maxclients->current.integer, bot_count));
}, scheduler::pipeline::main, 1s); }, scheduler::pipeline::main, 1s);
} }
}; };
} }