[Node] Use Main pipeline

This commit is contained in:
Diavolo 2022-06-25 18:21:12 +02:00
parent d08717f418
commit 1bcd1672ec
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
4 changed files with 14 additions and 13 deletions

View File

@ -283,10 +283,10 @@ namespace Components
bool Network::HandleCommand(Game::netadr_t* address, const char* command, const Game::msg_t* message) bool Network::HandleCommand(Game::netadr_t* address, const char* command, const Game::msg_t* message)
{ {
const auto cmd_string = Utils::String::ToLower(command); const auto command_ = Utils::String::ToLower(command);
const auto handler = Network::Callbacks.find(cmd_string); const auto handler = Network::Callbacks.find(command_);
const auto offset = cmd_string.size() + 5; const auto offset = command_.size() + 5;
if (static_cast<std::size_t>(message->cursize) < offset || handler == Network::Callbacks.end()) if (static_cast<std::size_t>(message->cursize) < offset || handler == Network::Callbacks.end())
{ {
return false; return false;

View File

@ -208,7 +208,7 @@ namespace Components
i = Node::Nodes.erase(i); i = Node::Nodes.erase(i);
continue; continue;
} }
else if (sentRequests < queryLimit.get<int>() && i->requiresRequest()) if (sentRequests < queryLimit.get<int>() && i->requiresRequest())
{ {
++sentRequests; ++sentRequests;
i->sendRequest(); i->sendRequest();
@ -326,7 +326,7 @@ namespace Components
Logger::Debug("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString()); Logger::Debug("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString());
#endif #endif
Session::Send(address, "nodeListResponse", nodeListData); Session::Send(address, "nodeListResponse", nodeListData);
}, Scheduler::Pipeline::SERVER, NODE_SEND_RATE * i++); }, Scheduler::Pipeline::MAIN, NODE_SEND_RATE * i++);
} }
} }
@ -346,10 +346,10 @@ namespace Components
Node::StoreNodes(false); Node::StoreNodes(false);
}, Scheduler::Pipeline::ASYNC); }, Scheduler::Pipeline::ASYNC);
Scheduler::Loop(Node::RunFrame, Scheduler::Pipeline::SERVER); Scheduler::Loop(Node::RunFrame, Scheduler::Pipeline::MAIN);
Session::Handle("nodeListResponse", Node::HandleResponse); Session::Handle("nodeListResponse", Node::HandleResponse);
Session::Handle("nodeListRequest", [](const Network::Address& address, const std::string&) Session::Handle("nodeListRequest", [](const Network::Address& address, [[maybe_unused]] const std::string& data)
{ {
Node::SendList(address); Node::SendList(address);
}); });

View File

@ -27,11 +27,11 @@ namespace Components
{ {
return &ServerList::OnlineList; return &ServerList::OnlineList;
} }
else if (ServerList::IsOfflineList()) if (ServerList::IsOfflineList())
{ {
return &ServerList::OfflineList; return &ServerList::OfflineList;
} }
else if (ServerList::IsFavouriteList()) if (ServerList::IsFavouriteList())
{ {
return &ServerList::FavouriteList; return &ServerList::FavouriteList;
} }
@ -289,6 +289,7 @@ namespace Components
{ {
Logger::Print("Could not resolve address for {}:{}", masterServerName, masterPort); Logger::Print("Could not resolve address for {}:{}", masterServerName, masterPort);
Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%u", masterServerName, masterPort), 5000); Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%u", masterServerName, masterPort), 5000);
useMasterServer = false;
return; return;
} }
@ -828,8 +829,8 @@ namespace Components
// Set default masterServerName + port and save it // Set default masterServerName + port and save it
Utils::Hook::Set<const char*>(0x60AD92, "master.xlabs.dev"); Utils::Hook::Set<const char*>(0x60AD92, "master.xlabs.dev");
Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_NONE); // masterServerName
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_NONE); // masterPort
// 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);

View File

@ -37,7 +37,7 @@ namespace Components
{ {
Network::SendCommand(delayData->target, delayData->command, delayData->data); Network::SendCommand(delayData->target, delayData->command, delayData->data);
delete delayData; delete delayData;
}, Scheduler::Pipeline::SERVER, 500ms + std::chrono::milliseconds(std::rand() % 200)); }, Scheduler::Pipeline::MAIN, 500ms + std::chrono::milliseconds(std::rand() % 200));
#else #else
std::lock_guard _(Session::Mutex); std::lock_guard _(Session::Mutex);