Merge pull request #331 from diamante0018/investigate
[Node] Use Main pipeline
This commit is contained in:
commit
c2558ba031
@ -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;
|
||||||
|
@ -21,7 +21,7 @@ namespace Components
|
|||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -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);
|
||||||
});
|
});
|
||||||
|
@ -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);
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user