diff --git a/iw4/Components/ServerList.cpp b/iw4/Components/ServerList.cpp index 66141775..a4423c95 100644 --- a/iw4/Components/ServerList.cpp +++ b/iw4/Components/ServerList.cpp @@ -74,11 +74,16 @@ namespace Components ServerList::RefreshContainer.SendCount = 0; ServerList::RefreshContainer.SentCount = 0; + ServerList::RefreshContainer.AwatingList = true; + ServerList::RefreshContainer.AwaitTime = Game::Com_Milliseconds(); + int masterPort = Dvar::Var("masterPort").Get(); const char* masterServerName = Dvar::Var("masterServerName").Get(); ServerList::RefreshContainer.Host = Network::Address(Utils::VA("%s:%u", masterServerName, masterPort)); + Logger::Print("Sending serverlist request to master: %s:%u\n", masterServerName, masterPort); + //Network::Send(ServerList::RefreshContainer.Host, "getservers IW4 145 full empty"); Network::Send(ServerList::RefreshContainer.Host, "getservers 0 full empty\n"); } @@ -132,8 +137,6 @@ namespace Components } } - Logger::Print("Current server count: %d\n", ServerList::OnlineList.size()); - ServerList::RefreshContainer.Mutex.unlock(); } @@ -141,6 +144,17 @@ namespace Components { ServerList::RefreshContainer.Mutex.lock(); + if (ServerList::RefreshContainer.AwatingList) + { + // Check if we haven't got a response within 10 seconds + if (Game::Com_Milliseconds() - ServerList::RefreshContainer.AwaitTime > 5000) + { + ServerList::RefreshContainer.AwatingList = false; + + Logger::Print("We haven't received a response from the master within %d seconds!\n", (Game::Com_Milliseconds() - ServerList::RefreshContainer.AwaitTime) / 1000); + } + } + // Send requests to 10 servers each frame int SendServers = 10; @@ -177,9 +191,12 @@ namespace Components { if (ServerList::RefreshContainer.Host != address) return; // Only parse from host we sent to + ServerList::RefreshContainer.AwatingList = false; + ServerList::RefreshContainer.Mutex.lock(); int offset = 0; + int count = ServerList::RefreshContainer.Servers.size(); ServerList::MasterEntry* entry = nullptr; // Find first entry @@ -217,13 +234,13 @@ namespace Components } } - Logger::Print("Parsed %d servers from master\n", ServerList::RefreshContainer.Servers.size()); + Logger::Print("Parsed %d servers from master\n", ServerList::RefreshContainer.Servers.size() - count); ServerList::RefreshContainer.Mutex.unlock(); }); // Set default masterServerName + port and save it - //Utils::Hook::Set(0x60AD92, "localhost"); + Utils::Hook::Set(0x60AD92, "localhost"); Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_FLAG_SAVED); // masterServerName Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_FLAG_SAVED); // masterPort diff --git a/iw4/Components/ServerList.hpp b/iw4/Components/ServerList.hpp index 04dc0f1c..027959cc 100644 --- a/iw4/Components/ServerList.hpp +++ b/iw4/Components/ServerList.hpp @@ -70,8 +70,12 @@ namespace Components Network::Address Target; }; + bool AwatingList; + int AwaitTime; + int SentCount; int SendCount; + Network::Address Host; std::vector Servers; std::mutex Mutex; diff --git a/iw4/Components/UIFeeder.cpp b/iw4/Components/UIFeeder.cpp index 824d1960..3f4bfb02 100644 --- a/iw4/Components/UIFeeder.cpp +++ b/iw4/Components/UIFeeder.cpp @@ -59,7 +59,7 @@ namespace Components call UIFeeder::SetItemSelection - test eax, eax + test al, al jz continue retn @@ -142,7 +142,7 @@ namespace Components call UIFeeder::CheckFeeder pop ebx - test eax, eax + test al, al jz continueOriginal // Get current milliseconds @@ -200,7 +200,7 @@ namespace Components call UIFeeder::CheckFeeder - test eax, eax + test al, al jnz continue mov[edi + 130h], esi @@ -220,7 +220,7 @@ namespace Components call UIFeeder::CheckFeeder - test eax, eax + test al, al jnz continue mov eax, 4C25D0h @@ -240,7 +240,7 @@ namespace Components call UIFeeder::CheckFeeder - test eax, eax + test al, al jnz continue mov eax, 685E10h diff --git a/iw4/Components/UIScript.cpp b/iw4/Components/UIScript.cpp index 218640f3..11bfb9bc 100644 --- a/iw4/Components/UIScript.cpp +++ b/iw4/Components/UIScript.cpp @@ -82,7 +82,7 @@ namespace Components call UIScript::RunMenuScript add esp, 8h - test eax, eax + test al, al jz continue // if returned