Correct max player count

This commit is contained in:
momo5502 2023-02-07 18:56:16 +01:00
parent ec11bffbaa
commit 34291fb4d3
3 changed files with 19 additions and 9 deletions

View File

@ -12,8 +12,6 @@
#include <version.hpp> #include <version.hpp>
#include "command.hpp"
namespace getinfo namespace getinfo
{ {
namespace namespace
@ -29,6 +27,16 @@ namespace getinfo
return game::Dvar_GetString(dvar); return game::Dvar_GetString(dvar);
} }
int get_dvar_int(const char* dvar_name)
{
const auto dvar = game::Dvar_FindVar(dvar_name);
if (!dvar)
{
return {};
}
return game::Dvar_GetInt(dvar);
}
int Com_SessionMode_GetGameMode() int Com_SessionMode_GetGameMode()
{ {
@ -52,15 +60,16 @@ namespace getinfo
utils::info_string info{}; utils::info_string info{};
info.set("challenge", std::string(data.begin(), data.end())); info.set("challenge", std::string(data.begin(), data.end()));
info.set("gamename", "T7"); info.set("gamename", "T7");
info.set("hostname", get_dvar_string("sv_hostname")); info.set("hostname", get_dvar_string(game::is_server() ? "live_steam_server_name" : "sv_hostname"));
info.set("gametype", get_dvar_string("g_gametype")); info.set("gametype", get_dvar_string("g_gametype"));
//info.set("sv_motd", get_dvar_string("sv_motd")); //info.set("sv_motd", get_dvar_string("sv_motd"));
info.set("description", game::is_server() ? get_dvar_string("live_steam_server_description") : "");
info.set("xuid", utils::string::va("%llX", steam::SteamUser()->GetSteamID().bits)); info.set("xuid", utils::string::va("%llX", steam::SteamUser()->GetSteamID().bits));
info.set("mapname", get_dvar_string("mapname")); info.set("mapname", get_dvar_string("mapname"));
//info.set("isPrivate", get_dvar_string("g_password").empty() ? "0" : "1"); info.set("isPrivate", get_dvar_string("g_password").empty() ? "0" : "1");
//info.set("clients", utils::string::va("%i", get_client_count())); info.set("clients", utils::string::va("%i", 0));
//info.set("bots", utils::string::va("%i", get_bot_count())); info.set("bots", utils::string::va("%i", /*get_bot_count()*/0));
//info.set("sv_maxclients", utils::string::va("%i", *game::mp::svs_numclients)); info.set("sv_maxclients", utils::string::va("%i", get_dvar_int("com_maxclients")));
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()));

View File

@ -79,6 +79,7 @@ namespace game
WEAK symbol<dvar_t*(unsigned int hash)> Dvar_FindMalleableVar{0x1422BD6A0}; WEAK symbol<dvar_t*(unsigned int hash)> Dvar_FindMalleableVar{0x1422BD6A0};
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetDebugName{0x1422BDCB0}; WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetDebugName{0x1422BDCB0};
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetString{0x1422BFFF0, 0x140575E30}; WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetString{0x1422BFFF0, 0x140575E30};
WEAK symbol<int(const dvar_t* dvar)> Dvar_GetInt{0x1422BF2C0, 0x140575C20};
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{
0x1422C7F60 0x1422C7F60
}; };

View File

@ -40,12 +40,12 @@ namespace steam
server.m_bDoNotRefresh = false; server.m_bDoNotRefresh = false;
strcpy_s(server.m_szGameDir, ""); strcpy_s(server.m_szGameDir, "");
strcpy_s(server.m_szMap, info.get("mapname").data()); strcpy_s(server.m_szMap, info.get("mapname").data());
strcpy_s(server.m_szGameDescription, "Example BO^3I^5I^6I ^7Server"); strcpy_s(server.m_szGameDescription, info.get("description").data());
server.m_nAppID = 311210; server.m_nAppID = 311210;
server.m_nPlayers = atoi(info.get("clients").data()); server.m_nPlayers = atoi(info.get("clients").data());
server.m_nMaxPlayers = atoi(info.get("sv_maxclients").data()); server.m_nMaxPlayers = atoi(info.get("sv_maxclients").data());
server.m_nBotPlayers = atoi(info.get("bots").data()); server.m_nBotPlayers = atoi(info.get("bots").data());
server.m_bPassword = false; server.m_bPassword = info.get("isPrivate") == "1";
server.m_bSecure = true; server.m_bSecure = true;
server.m_ulTimeLastPlayed = 0; server.m_ulTimeLastPlayed = 0;
server.m_nServerVersion = 1000; server.m_nServerVersion = 1000;