From de882dee07fd9d788015beb2538c28449102e123 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 5 Mar 2016 23:33:33 +0100 Subject: [PATCH] Remove some node debug output --- deps/protobuf | 2 +- src/Components/Modules/Node.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/deps/protobuf b/deps/protobuf index e70f9256..9242d9b7 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit e70f9256af79af6092eae4ce22a61b1b6651f37d +Subproject commit 9242d9b7f431e40d119faef8b583d945362ef04c diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index d9f34114..62f2c191 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -219,7 +219,9 @@ namespace Components } else { +#ifdef DEBUG Logger::Print("Sending session request to %s\n", entry->address.GetString()); +#endif Network::SendCommand(entry->address, "sessionRequest"); } } @@ -438,7 +440,9 @@ namespace Components Node::NodeEntry* entry = Node::FindNode(address); if (!entry || entry->state != Node::STATE_NEGOTIATING) return; +#ifdef DEBUG Logger::Print("Received acknowledgment from %s\n", address.GetString()); +#endif Proto::Node::Packet packet; if (!packet.ParseFromString(data)) return; @@ -456,8 +460,10 @@ namespace Components entry->state = Node::STATE_VALID; entry->registered = true; +#ifdef DEBUG Logger::Print("Signature from %s for challenge '%s' is valid!\n", address.GetString(), entry->challenge.data()); Logger::Print("Node %s registered\n", address.GetString()); +#endif } else { @@ -519,7 +525,9 @@ namespace Components entry->registered = false; entry->state = Node::STATE_INVALID; +#ifdef DEBUG Logger::Print("Node %s unregistered\n", address.GetString()); +#endif } else { @@ -541,7 +549,9 @@ namespace Components Node::ClientSession* session = Node::FindSession(address); if (!session) return; // Registering template session failed, odd... +#ifdef DEBUG Logger::Print("Client %s is requesting a new session\n", address.GetString()); +#endif // Initialize session data session->challenge = Utils::VA("%X", Utils::Cryptography::Rand::GenerateInt()); @@ -559,7 +569,9 @@ namespace Components if (session->challenge == data) { +#ifdef DEBUG Logger::Print("Session for %s validated.\n", address.GetString()); +#endif session->valid = true; Network::SendCommand(address, "sessionAcknowledge"); } @@ -577,7 +589,9 @@ namespace Components Node::NodeEntry* entry = Node::FindNode(address); if (!entry) return; +#ifdef DEBUG Logger::Print("Session initialization received. Synchronizing...\n", address.GetString()); +#endif entry->lastTime = Game::Com_Milliseconds(); Network::SendCommand(address, "sessionSynchronize", data); @@ -592,7 +606,9 @@ namespace Components entry->registered = true; entry->lastTime = Game::Com_Milliseconds(); +#ifdef DEBUG Logger::Print("Session acknowledged, synchronizing node list...\n", address.GetString()); +#endif Network::SendCommand(address, "nodeListRequest"); Node::SendNodeList(address); }); @@ -699,6 +715,17 @@ namespace Components } }); + Command::Add("syncnodes", [] (Command::Params params) + { + Logger::Print("Resetting node states...\n"); + + for (auto &node : Node::Nodes) + { + node.state = Node::STATE_UNKNOWN; + node.registered = false; + } + }); + // Install frame handlers QuickPatch::OnFrame(Node::FrameHandler); }