Fix multiple small issues :)

This commit is contained in:
Lion Kortlepel 2020-11-11 11:24:36 +01:00
parent 8f05cdcc61
commit 308500c01f
6 changed files with 13 additions and 12 deletions

View File

@ -24,7 +24,7 @@ struct VData{
class Client { class Client {
private: private:
std::set<std::unique_ptr<VData>> VehicleData; //ID and Data; std::set<std::unique_ptr<VData>> VehicleData; //ID and Data;
std::string Name = "Unknown Client"; std::string Name = Sec("Unknown Client");
sockaddr_in UDPADDR; sockaddr_in UDPADDR;
std::string Role; std::string Role;
std::string DID; std::string DID;

View File

@ -5,6 +5,7 @@
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include "Security/Xor.h"
void InitLog(); void InitLog();
#define DebugPrintTID() DebugPrintTIDInternal(__func__, false) #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 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

View File

@ -12,12 +12,12 @@ typedef unsigned long DWORD, *PDWORD, *LPDWORD;
#include <unistd.h> #include <unistd.h>
#endif // WIN32 #endif // WIN32
#include "Logger.h" #include "Logger.h"
#include <array>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <thread> #include <thread>
#include <array>
std::vector<std::string> QConsoleOut; std::vector<std::string> QConsoleOut;
std::string CInputBuff; std::string CInputBuff;
@ -25,11 +25,11 @@ std::mutex MLock;
std::unique_ptr<Lua> LuaConsole; std::unique_ptr<Lua> LuaConsole;
void HandleInput(const std::string& cmd) { void HandleInput(const std::string& cmd) {
std::cout << std::endl; std::cout << std::endl;
if (cmd == "exit") { if (cmd == Sec("exit")) {
_Exit(0); _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 // 2J is clearscreen, H is reset position to top-left
ConsoleOut("\x1b[2J\x1b[H"); ConsoleOut(Sec("\x1b[2J\x1b[H"));
} else { } else {
LuaConsole->Execute(cmd); LuaConsole->Execute(cmd);
} }
@ -99,6 +99,7 @@ char _getch(void) {
#endif // WIN32 #endif // WIN32
void SetupConsole() { void SetupConsole() {
error(__func__);
#if defined(WIN32) && !defined(DEBUG) #if defined(WIN32) && !defined(DEBUG)
DWORD outMode = 0; DWORD outMode = 0;
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);

View File

@ -264,7 +264,7 @@ void TCPServerMain(){
#else // unix #else // unix
// wondering why we need slightly different implementations of this? // wondering why we need slightly different implementations of this?
// ask ms. // 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{}; sockaddr_in addr{};
addr.sin_addr.s_addr = INADDR_ANY; addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;

View File

@ -184,7 +184,6 @@ void GlobalParser(Client*c, const std::string& Pack){
SendToAll(c,Packet,false,false); SendToAll(c,Packet,false,false);
return; return;
} }
switch (Code) { switch (Code) {
case 'P': // initial connection case 'P': // initial connection
#ifdef DEBUG #ifdef DEBUG

View File

@ -70,7 +70,7 @@ void TCPRcv(Client*c){
return; return;
} }
BytesRcv += Temp; BytesRcv += Temp;
}while(BytesRcv < sizeof(Header)); }while(size_t(BytesRcv) < sizeof(Header));
memcpy(&Header,&Data[0],sizeof(Header)); memcpy(&Header,&Data[0],sizeof(Header));
#ifdef DEBUG #ifdef DEBUG