Merge pull request #331 from diamante0018/investigate

[Node] Use Main pipeline
This commit is contained in:
Dss0 2022-06-26 13:27:43 +02:00 committed by GitHub
commit c2558ba031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
{
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<std::size_t>(message->cursize) < offset || handler == Network::Callbacks.end())
{
return false;

View File

@ -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<int>() && i->requiresRequest())
if (sentRequests < queryLimit.get<int>() && 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);
});

View File

@ -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<const char*>(0x60AD92, "master.xlabs.dev");
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>(0x60AD90, Game::dvar_flag::DVAR_NONE); // masterServerName
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_NONE); // masterPort
// Add server list feeder
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);
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);