[Monitor] Correctly load stored nodes

This commit is contained in:
momo5502 2017-02-25 15:58:43 +01:00
parent bc544748cc
commit 89ef10b789
4 changed files with 20 additions and 8 deletions

View File

@ -257,7 +257,7 @@ namespace Components
void Auth::StoreKey() void Auth::StoreKey()
{ {
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && Auth::GuidKey.isValid()) if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Monitor::IsEnabled() && Auth::GuidKey.isValid())
{ {
Proto::Auth::Certificate cert; Proto::Auth::Certificate cert;
cert.set_token(Auth::GuidToken.toString()); cert.set_token(Auth::GuidToken.toString());

View File

@ -534,7 +534,7 @@ namespace Components
{ {
Friends::LoggedOn = false; Friends::LoggedOn = false;
if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return; if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_FLAG_SAVED, "");
Dvar::Register<int>("cl_notifyFriendState", 1, -1, 1, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<int>("cl_notifyFriendState", 1, -1, 1, Game::DVAR_FLAG_SAVED, "");
@ -691,7 +691,7 @@ namespace Components
Friends::~Friends() Friends::~Friends()
{ {
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
Friends::StoreFriendsList(); Friends::StoreFriendsList();

View File

@ -30,7 +30,7 @@ namespace Components
Utils::Time::Interval interval; Utils::Time::Interval interval;
while(!interval.elapsed(15s)) while(!interval.elapsed(15s))
{ {
Utils::Hook::Call<void()>(0x49F0B0)(); // Com_EventLoop Utils::Hook::Call<void()>(0x49F0B0)(); // Com_ClientPacketEvent
Node::FrameHandler(); Node::FrameHandler();
ServerList::Frame(); ServerList::Frame();

View File

@ -25,8 +25,17 @@ namespace Components
void Node::LoadNodePreset() void Node::LoadNodePreset()
{ {
Proto::Node::List list; Proto::Node::List list;
FileSystem::File defaultNodes("nodes_default.dat");
if (!defaultNodes.exists() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(defaultNodes.getBuffer()))) return; if (Monitor::IsEnabled())
{
std::string nodes = Utils::IO::ReadFile("players/nodes_default.dat");
if (nodes.empty() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(nodes))) return;
}
else
{
FileSystem::File defaultNodes("nodes_default.dat");
if (!defaultNodes.exists() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(defaultNodes.getBuffer()))) return;
}
for (int i = 0; i < list.address_size(); ++i) for (int i = 0; i < list.address_size(); ++i)
{ {
@ -384,11 +393,14 @@ namespace Components
Node::SignatureKey = Utils::Cryptography::ECC::GenerateKey(512); Node::SignatureKey = Utils::Cryptography::ECC::GenerateKey(512);
// Load stored nodes // Load stored nodes
Dvar::OnInit([] () auto loadNodes = []()
{ {
Node::LoadNodePreset(); Node::LoadNodePreset();
Node::LoadNodes(); Node::LoadNodes();
}); };
if (Monitor::IsEnabled()) Network::OnStart(loadNodes);
else Dvar::OnInit(loadNodes);
// Send deadline when shutting down // Send deadline when shutting down
if (Dedicated::IsEnabled()) if (Dedicated::IsEnabled())