From 7fce274915fb52f22ea1f808c41e0eabf96da4f9 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sun, 8 Nov 2020 21:46:02 +0100 Subject: [PATCH] Fix printing, make CI into unique_ptr (more) --- include/Client.hpp | 2 +- src/Console.cpp | 2 ++ src/Init/Startup.cpp | 2 +- src/Network/Auth.cpp | 2 +- src/Network/NetMain.cpp | 3 ++- src/Network/TCPHandler.cpp | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/Client.hpp b/include/Client.hpp index bc20c33..c46153d 100644 --- a/include/Client.hpp +++ b/include/Client.hpp @@ -82,4 +82,4 @@ struct ClientInterface{ } }; -extern ClientInterface* CI; +extern std::unique_ptr CI; diff --git a/src/Console.cpp b/src/Console.cpp index d1407be..385e30b 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -132,6 +132,7 @@ static bool CompositeInputExpected { false }; static void ProcessCompositeInput() { if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array { 91, 65 }.data(), 2) == 0) { // UP ARROW + info(std::to_string(ConsoleHistoryReadIndex)); if (!ConsoleHistory.empty()) { if (ConsoleHistoryReadIndex != 0) { ConsoleHistoryReadIndex -= 1; @@ -140,6 +141,7 @@ static void ProcessCompositeInput() { } } else if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array { 91, 66 }.data(), 2) == 0) { // DOWN ARROW + info(std::to_string(ConsoleHistoryReadIndex)); if (!ConsoleHistory.empty()) { if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) { ConsoleHistoryReadIndex += 1; diff --git a/src/Init/Startup.cpp b/src/Init/Startup.cpp index a23c5cd..5c90778 100644 --- a/src/Init/Startup.cpp +++ b/src/Init/Startup.cpp @@ -31,5 +31,5 @@ void Args(int argc, char* argv[]){ void InitServer(int argc, char* argv[]){ InitLog(); Args(argc,argv); - CI = new ClientInterface; + CI = std::make_unique(); } diff --git a/src/Network/Auth.cpp b/src/Network/Auth.cpp index 5d3c637..38255ac 100644 --- a/src/Network/Auth.cpp +++ b/src/Network/Auth.cpp @@ -174,7 +174,7 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){ closesocket(TCPSock); return; } - DebugPrintTIDInternal(std::string("Client(") + Name + ")"); + // DebugPrintTIDInternal(std::string("Client(") + Name + ")"); debug(Sec("Name -> ") + Name + Sec(", Role -> ") + Role + Sec(", ID -> ") + DID); for(auto& c : CI->Clients){ if(c != nullptr){ diff --git a/src/Network/NetMain.cpp b/src/Network/NetMain.cpp index 8df428c..040db77 100644 --- a/src/Network/NetMain.cpp +++ b/src/Network/NetMain.cpp @@ -1,6 +1,7 @@ #include "Network.h" #include -ClientInterface* CI; +#include +std::unique_ptr CI; void NetMain(){ std::thread TCP(TCPServerMain); TCP.detach(); diff --git a/src/Network/TCPHandler.cpp b/src/Network/TCPHandler.cpp index 34ad714..b17acca 100644 --- a/src/Network/TCPHandler.cpp +++ b/src/Network/TCPHandler.cpp @@ -113,7 +113,7 @@ void TCPRcv(Client*c){ } void TCPClient(Client*c){ - DebugPrintTID(); + DebugPrintTIDInternal(c->GetName(), true); Assert(c); if(c->GetTCPSock() == -1){ CI->RemoveClient(c);