Important fixes for zonebuilder & filter servers on protocol

This commit is contained in:
Louvenarde 2024-01-31 20:53:41 +01:00
parent 197fe51a64
commit 0d222e30cf
3 changed files with 54 additions and 34 deletions

View File

@ -397,6 +397,11 @@ namespace Components
Node::Node()
{
if (ZoneBuilder::IsEnabled())
{
return;
}
net_natFix = Game::Dvar_RegisterBool("net_natFix", false, 0, "Fix node registration for certain firewalls/routers");
Scheduler::Loop([]
@ -406,14 +411,15 @@ namespace Components
Scheduler::Loop(RunFrame, Scheduler::Pipeline::MAIN);
Scheduler::OnGameInitialized([]
{
Session::Handle("nodeListResponse", HandleResponse);
Session::Handle("nodeListRequest", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
{
SendList(address);
});
Scheduler::OnGameInitialized([]
{
Migrate();
LoadNodePreset();
LoadNodes();

View File

@ -322,6 +322,19 @@ namespace Components
continue;
}
if (!entry.HasMember("ip") || !entry["protocol"].IsInt())
{
continue;
}
const auto protocol = entry["protocol"].GetInt();
if (protocol != PROTOCOL)
{
// We can't connect to it anyway
continue;
}
// Using VA because it's faster
Network::Address server(Utils::String::VA("%s:%u", entry["ip"].GetString(), entry["port"].GetInt()));
server.setType(Game::NA_IP); // Just making sure...
@ -371,7 +384,7 @@ namespace Components
Toast::Show("cardicon_headshot", "Server Browser", "Fetching servers...", 3000);
const auto* url = "http://iw4x.plutools.pw/v1/servers/iw4x";
const auto url = std::format("http://iw4x.plutools.pw/v1/servers/iw4x?protocol={}", PROTOCOL);
const auto reply = Utils::WebIO("IW4x", url).setTimeout(5000)->get();
if (reply.empty())
{

View File

@ -23,6 +23,7 @@ namespace Components
int ping;
int matchType;
int securityLevel;
int protocol;
bool hardcore;
bool svRunning;
bool aimassist;