use X Labs master server, node fallback
This commit is contained in:
parent
77bfed804c
commit
44090244bc
@ -374,7 +374,6 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef USE_LEGACY_SERVER_LIST
|
|
||||||
// Heartbeats
|
// Heartbeats
|
||||||
Scheduler::Once(Dedicated::Heartbeat);
|
Scheduler::Once(Dedicated::Heartbeat);
|
||||||
Scheduler::OnFrame([]()
|
Scheduler::OnFrame([]()
|
||||||
@ -387,7 +386,6 @@ namespace Components
|
|||||||
Dedicated::Heartbeat();
|
Dedicated::Heartbeat();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
|
|
||||||
Dvar::OnInit([]()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
|
@ -114,6 +114,7 @@ namespace Components
|
|||||||
|
|
||||||
void Node::StoreNodes(bool force)
|
void Node::StoreNodes(bool force)
|
||||||
{
|
{
|
||||||
|
if (ServerList::useMasterServer) return;
|
||||||
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
static Utils::Time::Interval interval;
|
static Utils::Time::Interval interval;
|
||||||
@ -167,6 +168,7 @@ namespace Components
|
|||||||
|
|
||||||
void Node::RunFrame()
|
void Node::RunFrame()
|
||||||
{
|
{
|
||||||
|
if (ServerList::useMasterServer) return;
|
||||||
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
|
if (Dedicated::IsEnabled() && Dvar::Var("sv_lanOnly").get<bool>()) return;
|
||||||
|
|
||||||
if (!Dedicated::IsEnabled() && *Game::clcState > 0)
|
if (!Dedicated::IsEnabled() && *Game::clcState > 0)
|
||||||
|
@ -19,6 +19,8 @@ namespace Components
|
|||||||
Dvar::Var ServerList::NETServerQueryLimit;
|
Dvar::Var ServerList::NETServerQueryLimit;
|
||||||
Dvar::Var ServerList::NETServerFrames;
|
Dvar::Var ServerList::NETServerFrames;
|
||||||
|
|
||||||
|
bool ServerList::useMasterServer = true;
|
||||||
|
|
||||||
std::vector<ServerList::ServerInfo>* ServerList::GetList()
|
std::vector<ServerList::ServerInfo>* ServerList::GetList()
|
||||||
{
|
{
|
||||||
if (ServerList::IsOnlineList())
|
if (ServerList::IsOnlineList())
|
||||||
@ -274,22 +276,31 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else if (ServerList::IsOnlineList())
|
else if (ServerList::IsOnlineList())
|
||||||
{
|
{
|
||||||
#ifdef USE_LEGACY_SERVER_LIST
|
const auto masterPort = Dvar::Var("masterPort").get<int>();
|
||||||
|
const auto masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
||||||
|
|
||||||
|
Game::netadr_t masterServerAddr;
|
||||||
|
if (ServerList::GetMasterServer(masterServerAddr))
|
||||||
|
{
|
||||||
|
Logger::Print("A valid master server was found at %s:%u\n", masterServerName, masterPort);
|
||||||
|
|
||||||
ServerList::RefreshContainer.awatingList = true;
|
ServerList::RefreshContainer.awatingList = true;
|
||||||
ServerList::RefreshContainer.awaitTime = Game::Sys_Milliseconds();
|
ServerList::RefreshContainer.awaitTime = Game::Sys_Milliseconds();
|
||||||
|
|
||||||
int masterPort = Dvar::Var("masterPort").get<int>();
|
|
||||||
const char* masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
|
||||||
|
|
||||||
ServerList::RefreshContainer.host = Network::Address(Utils::String::VA("%s:%u", masterServerName, masterPort));
|
ServerList::RefreshContainer.host = Network::Address(Utils::String::VA("%s:%u", masterServerName, masterPort));
|
||||||
|
|
||||||
Logger::Print("Sending serverlist request to master: %s:%u\n", masterServerName, masterPort);
|
Logger::Print("Sending serverlist request to master\n");
|
||||||
|
|
||||||
Network::SendCommand(ServerList::RefreshContainer.host, "getservers", Utils::String::VA("IW4 %i full empty", PROTOCOL));
|
Network::SendCommand(ServerList::RefreshContainer.host, "getservers", Utils::String::VA("IW4 %i full empty", PROTOCOL));
|
||||||
//Network::SendCommand(ServerList::RefreshContainer.Host, "getservers", "0 full empty");
|
}
|
||||||
#else
|
else
|
||||||
|
{
|
||||||
|
// this should only be getting called if no master server is found or reached
|
||||||
|
Logger::Print("No valid master server was found, using node as fallback\n");
|
||||||
|
|
||||||
|
useMasterServer = false;
|
||||||
|
|
||||||
Node::Synchronize();
|
Node::Synchronize();
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
else if (ServerList::IsFavouriteList())
|
else if (ServerList::IsFavouriteList())
|
||||||
{
|
{
|
||||||
@ -733,6 +744,14 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServerList::GetMasterServer(Game::netadr_t& address)
|
||||||
|
{
|
||||||
|
auto masterPort = Dvar::Var("masterPort").get<int>();
|
||||||
|
auto masterServerName = Dvar::Var("masterServerName").get<const char*>();
|
||||||
|
|
||||||
|
return Game::NET_StringToAdr(Utils::String::VA("%s:%u"), &address);
|
||||||
|
}
|
||||||
|
|
||||||
ServerList::ServerList()
|
ServerList::ServerList()
|
||||||
{
|
{
|
||||||
ServerList::OnlineList.clear();
|
ServerList::OnlineList.clear();
|
||||||
@ -792,11 +811,9 @@ namespace Components
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Set default masterServerName + port and save it
|
// Set default masterServerName + port and save it
|
||||||
#ifdef USE_LEGACY_SERVER_LIST
|
Utils::Hook::Set<char*>(0x60AD92, "master.xlabs.dev");
|
||||||
Utils::Hook::Set<char*>(0x60AD92, "127.0.0.1");
|
|
||||||
Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName
|
Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName
|
||||||
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort
|
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort
|
||||||
#endif
|
|
||||||
|
|
||||||
// Add server list feeder
|
// Add server list feeder
|
||||||
UIFeeder::Add(2.0f, ServerList::GetServerCount, ServerList::GetServerText, ServerList::SelectServer);
|
UIFeeder::Add(2.0f, ServerList::GetServerCount, ServerList::GetServerText, ServerList::SelectServer);
|
||||||
|
@ -50,6 +50,9 @@ namespace Components
|
|||||||
|
|
||||||
static void UpdateVisibleInfo();
|
static void UpdateVisibleInfo();
|
||||||
|
|
||||||
|
static bool GetMasterServer(Game::netadr_t& address);
|
||||||
|
static bool useMasterServer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Column
|
enum Column
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user