From 308500c01f95766e180ea8072a512402f10dfc5a Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Wed, 11 Nov 2020 11:24:36 +0100 Subject: [PATCH] Fix multiple small issues :) --- include/Client.hpp | 2 +- include/Logger.h | 1 + src/Console.cpp | 17 +++++++++-------- src/Network/Auth.cpp | 2 +- src/Network/GParser.cpp | 1 - src/Network/TCPHandler.cpp | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/Client.hpp b/include/Client.hpp index c46153d..818ec31 100644 --- a/include/Client.hpp +++ b/include/Client.hpp @@ -24,7 +24,7 @@ struct VData{ class Client { private: std::set> VehicleData; //ID and Data; - std::string Name = "Unknown Client"; + std::string Name = Sec("Unknown Client"); sockaddr_in UDPADDR; std::string Role; std::string DID; diff --git a/include/Logger.h b/include/Logger.h index f1037af..9652db6 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -5,6 +5,7 @@ #include #include #include +#include "Security/Xor.h" void InitLog(); #define DebugPrintTID() DebugPrintTIDInternal(__func__, false) void DebugPrintTIDInternal(const std::string& func, bool overwrite = true); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier diff --git a/src/Console.cpp b/src/Console.cpp index f434880..13419d5 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -12,12 +12,12 @@ typedef unsigned long DWORD, *PDWORD, *LPDWORD; #include #endif // WIN32 #include "Logger.h" +#include #include #include #include #include #include -#include std::vector QConsoleOut; std::string CInputBuff; @@ -25,11 +25,11 @@ std::mutex MLock; std::unique_ptr LuaConsole; void HandleInput(const std::string& cmd) { std::cout << std::endl; - if (cmd == "exit") { + if (cmd == Sec("exit")) { _Exit(0); - } else if (cmd == "clear" || cmd == "cls") { + } else if (cmd == Sec("clear") || cmd == Sec("cls")) { // 2J is clearscreen, H is reset position to top-left - ConsoleOut("\x1b[2J\x1b[H"); + ConsoleOut(Sec("\x1b[2J\x1b[H")); } else { LuaConsole->Execute(cmd); } @@ -99,6 +99,7 @@ char _getch(void) { #endif // WIN32 void SetupConsole() { + error(__func__); #if defined(WIN32) && !defined(DEBUG) DWORD outMode = 0; HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -139,8 +140,8 @@ static void ProcessCompositeInput() { #else // unix if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array { 91, 65 }.data(), 2) == 0) { #endif // WIN32 - // UP ARROW - // info(std::to_string(ConsoleHistoryReadIndex)); + // UP ARROW + // info(std::to_string(ConsoleHistoryReadIndex)); if (!ConsoleHistory.empty()) { if (ConsoleHistoryReadIndex != 0) { ConsoleHistoryReadIndex -= 1; @@ -152,7 +153,7 @@ static void ProcessCompositeInput() { #else // unix } else if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array { 91, 66 }.data(), 2) == 0) { #endif // WIN32 - // DOWN ARROW + // DOWN ARROW if (!ConsoleHistory.empty()) { if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) { ConsoleHistoryReadIndex += 1; @@ -213,7 +214,7 @@ static void ProcessCompositeInput() { #else // unix } else if (In == 27) { #endif // WIN32 - // escape char, assume stuff follows + // escape char, assume stuff follows CompositeInputExpected = true; CompositeInput.clear(); } else if (!isprint(In)) { diff --git a/src/Network/Auth.cpp b/src/Network/Auth.cpp index d561c73..0ff1250 100644 --- a/src/Network/Auth.cpp +++ b/src/Network/Auth.cpp @@ -264,7 +264,7 @@ void TCPServerMain(){ #else // unix // wondering why we need slightly different implementations of this? // ask ms. - SOCKET client, Listener = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); + SOCKET client = -1, Listener = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); sockaddr_in addr{}; addr.sin_addr.s_addr = INADDR_ANY; addr.sin_family = AF_INET; diff --git a/src/Network/GParser.cpp b/src/Network/GParser.cpp index a642e9f..3be069c 100644 --- a/src/Network/GParser.cpp +++ b/src/Network/GParser.cpp @@ -184,7 +184,6 @@ void GlobalParser(Client*c, const std::string& Pack){ SendToAll(c,Packet,false,false); return; } - switch (Code) { case 'P': // initial connection #ifdef DEBUG diff --git a/src/Network/TCPHandler.cpp b/src/Network/TCPHandler.cpp index b17acca..1313cc0 100644 --- a/src/Network/TCPHandler.cpp +++ b/src/Network/TCPHandler.cpp @@ -70,7 +70,7 @@ void TCPRcv(Client*c){ return; } BytesRcv += Temp; - }while(BytesRcv < sizeof(Header)); + }while(size_t(BytesRcv) < sizeof(Header)); memcpy(&Header,&Data[0],sizeof(Header)); #ifdef DEBUG