Introduce sub-protocols

This commit is contained in:
momo5502 2023-04-22 09:13:03 +02:00
parent ff70b3e1c5
commit 6fecdeb68d
5 changed files with 492 additions and 481 deletions

View File

@ -110,6 +110,7 @@ namespace getinfo
info.set("bots", std::to_string(get_bot_count())); info.set("bots", std::to_string(get_bot_count()));
info.set("sv_maxclients", std::to_string(get_max_client_count())); info.set("sv_maxclients", std::to_string(get_max_client_count()));
info.set("protocol", std::to_string(PROTOCOL)); info.set("protocol", std::to_string(PROTOCOL));
info.set("sub_protocol", std::to_string(SUB_PROTOCOL));
info.set("playmode", std::to_string(game::Com_SessionMode_GetMode())); info.set("playmode", std::to_string(game::Com_SessionMode_GetMode()));
info.set("gamemode", std::to_string(Com_SessionMode_GetGameMode())); info.set("gamemode", std::to_string(Com_SessionMode_GetGameMode()));
info.set("sv_running", std::to_string(game::is_server_running())); info.set("sv_running", std::to_string(game::is_server_running()));

View File

@ -157,6 +157,14 @@ namespace party
return; return;
} }
const auto sub_protocol = atoi(info.get("sub_protocol").data());
if (sub_protocol != SUB_PROTOCOL && sub_protocol != (SUB_PROTOCOL - 1))
{
const auto str = "Invalid sub-protocol.";
printf("%s\n", str);
return;
}
const auto gamename = info.get("gamename"); const auto gamename = info.get("gamename");
if (gamename != "T7"s) if (gamename != "T7"s)
{ {

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#define PROTOCOL 4 #define PROTOCOL 4
#define SUB_PROTOCOL 1
#ifdef __cplusplus #ifdef __cplusplus
namespace game namespace game

View File

@ -31,6 +31,8 @@ namespace steam
gameserveritem_t create_server_item(const game::netadr_t& address, const ::utils::info_string& info, gameserveritem_t create_server_item(const game::netadr_t& address, const ::utils::info_string& info,
const uint32_t ping, const bool success) const uint32_t ping, const bool success)
{ {
const auto sub_protocol = atoi(info.get("sub_protocol").data());
gameserveritem_t server{}; gameserveritem_t server{};
server.m_NetAdr.m_usConnectionPort = address.port; server.m_NetAdr.m_usConnectionPort = address.port;
server.m_NetAdr.m_usQueryPort = address.port; server.m_NetAdr.m_usQueryPort = address.port;
@ -41,7 +43,7 @@ namespace steam
::utils::string::copy(server.m_szGameDir, ""); ::utils::string::copy(server.m_szGameDir, "");
::utils::string::copy(server.m_szMap, info.get("mapname").data()); ::utils::string::copy(server.m_szMap, info.get("mapname").data());
::utils::string::copy(server.m_szGameDescription, info.get("description").data()); ::utils::string::copy(server.m_szGameDescription, info.get("description").data());
server.m_nAppID = 311210; server.m_nAppID = (sub_protocol == SUB_PROTOCOL || sub_protocol == (SUB_PROTOCOL - 1)) ? 311210 : 0;
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());
@ -231,8 +233,7 @@ namespace steam
} }
static thread_local gameserveritem_t server_item{}; static thread_local gameserveritem_t server_item{};
return queried_servers.access<gameserveritem_t*>([iServer](const servers& s) -> gameserveritem_t* return queried_servers.access<gameserveritem_t*>([iServer](const servers& s) -> gameserveritem_t* {
{
if (iServer < 0 || static_cast<size_t>(iServer) >= s.size()) if (iServer < 0 || static_cast<size_t>(iServer) >= s.size())
{ {
return nullptr; return nullptr;