From 1bcd1672ece7511564f0846b8132ceabb349f0e7 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sat, 25 Jun 2022 18:21:12 +0200 Subject: [PATCH] [Node] Use Main pipeline --- src/Components/Modules/Network.cpp | 6 +++--- src/Components/Modules/Node.cpp | 10 +++++----- src/Components/Modules/ServerList.cpp | 9 +++++---- src/Components/Modules/Session.cpp | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index b4dbf17a..b30cc5c6 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -283,10 +283,10 @@ namespace Components 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 handler = Network::Callbacks.find(cmd_string); + const auto command_ = Utils::String::ToLower(command); + const auto handler = Network::Callbacks.find(command_); - const auto offset = cmd_string.size() + 5; + const auto offset = command_.size() + 5; if (static_cast(message->cursize) < offset || handler == Network::Callbacks.end()) { return false; diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index bd6554fd..0b2918bc 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -21,7 +21,7 @@ namespace Components return true; } } - else if(this->lastResponse->elapsed(NODE_HALFLIFE * 2) && this->lastRequest.has_value() && this->lastRequest->after(*this->lastResponse)) + else if (this->lastResponse->elapsed(NODE_HALFLIFE * 2) && this->lastRequest.has_value() && this->lastRequest->after(*this->lastResponse)) { return true; } @@ -208,7 +208,7 @@ namespace Components i = Node::Nodes.erase(i); continue; } - else if (sentRequests < queryLimit.get() && i->requiresRequest()) + if (sentRequests < queryLimit.get() && i->requiresRequest()) { ++sentRequests; i->sendRequest(); @@ -326,7 +326,7 @@ namespace Components Logger::Debug("Sending {} nodeListResponse length to {}\n", nodeListData.length(), address.getCString()); #endif 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); }, Scheduler::Pipeline::ASYNC); - Scheduler::Loop(Node::RunFrame, Scheduler::Pipeline::SERVER); + Scheduler::Loop(Node::RunFrame, Scheduler::Pipeline::MAIN); 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); }); diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 5e1aebae..691f64e1 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -27,11 +27,11 @@ namespace Components { return &ServerList::OnlineList; } - else if (ServerList::IsOfflineList()) + if (ServerList::IsOfflineList()) { return &ServerList::OfflineList; } - else if (ServerList::IsFavouriteList()) + if (ServerList::IsFavouriteList()) { return &ServerList::FavouriteList; } @@ -289,6 +289,7 @@ namespace Components { 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); + useMasterServer = false; return; } @@ -828,8 +829,8 @@ namespace Components // Set default masterServerName + port and save it Utils::Hook::Set(0x60AD92, "master.xlabs.dev"); - Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName - Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort + Utils::Hook::Set(0x60AD90, Game::dvar_flag::DVAR_NONE); // masterServerName + Utils::Hook::Set(0x60ADC6, Game::dvar_flag::DVAR_NONE); // masterPort // Add server list feeder UIFeeder::Add(2.0f, ServerList::GetServerCount, ServerList::GetServerText, ServerList::SelectServer); diff --git a/src/Components/Modules/Session.cpp b/src/Components/Modules/Session.cpp index 1f575184..cbbe42be 100644 --- a/src/Components/Modules/Session.cpp +++ b/src/Components/Modules/Session.cpp @@ -37,7 +37,7 @@ namespace Components { Network::SendCommand(delayData->target, delayData->command, delayData->data); delete delayData; - }, Scheduler::Pipeline::SERVER, 500ms + std::chrono::milliseconds(std::rand() % 200)); + }, Scheduler::Pipeline::MAIN, 500ms + std::chrono::milliseconds(std::rand() % 200)); #else std::lock_guard _(Session::Mutex);