diff --git a/r5dev/core/logdef.cpp b/r5dev/core/logdef.cpp index 97766a62..ffb4b158 100644 --- a/r5dev/core/logdef.cpp +++ b/r5dev/core/logdef.cpp @@ -1,6 +1,9 @@ #include "core/stdafx.h" #include "core/logdef.h" +std::shared_ptr g_TermLogger; +std::shared_ptr g_ImGuiLogger; + //############################################################################# // SPDLOG INIT //############################################################################# @@ -14,80 +17,91 @@ void SpdLog_Init(void) return; } +#ifndef NETCONSOLE g_svLogSessionDirectory = fmt::format("platform\\logs\\{:s}\\", CreateTimedFileName()); /************************ * IMGUI LOGGER SETUP * ************************/ { - auto iconsole = std::make_shared("game_console", g_LogSink); - spdlog::register_logger(iconsole); // in-game console logger. - iconsole->set_pattern("[0.000] %v"); - iconsole->set_level(spdlog::level::trace); + g_ImGuiLogger = std::make_shared("game_console", g_LogSink); + spdlog::register_logger(g_ImGuiLogger); // in-game console logger. + g_ImGuiLogger->set_pattern("[0.000] %v"); + g_ImGuiLogger->set_level(spdlog::level::trace); } - +#endif // !NETCONSOLE /************************ * WINDOWS LOGGER SETUP * ************************/ { - auto wconsole = spdlog::stdout_logger_mt("win_console"); +#ifdef NETCONSOLE + g_TermLogger = spdlog::default_logger(); +#else + g_TermLogger = spdlog::stdout_logger_mt("win_console"); +#endif // NETCONSOLE // Determine if user wants ansi-color logging in the terminal. - if (g_svCmdLine.find("-ansiclr") != string::npos) + if (g_svCmdLine.find("-ansicolor") != string::npos) { - wconsole->set_pattern("[0.000] %v\u001b[0m"); + g_TermLogger->set_pattern("[0.000] %v\u001b[0m"); g_bSpdLog_UseAnsiClr = true; } - else { wconsole->set_pattern("[0.000] %v"); } - wconsole->set_level(spdlog::level::trace); - spdlog::set_default_logger(wconsole); // Set as default. + else + { + g_TermLogger->set_pattern("[0.000] %v"); + } + //g_TermLogger->set_level(spdlog::level::trace); } - /************************ - * ROTATE LOGGER SETUP * - ************************/ - { - spdlog::rotating_logger_mt("squirrel_re(warning)" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "script_warning.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - spdlog::rotating_logger_mt("squirrel_re" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "script.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - spdlog::rotating_logger_mt("sdk(message)" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "message.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - spdlog::rotating_logger_mt("sdk(warning)" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "warning.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - spdlog::rotating_logger_mt("sdk(error)" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "error.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - spdlog::rotating_logger_mt("net_trace" - , fmt::format("{:s}{:s}" , g_svLogSessionDirectory, "net_trace.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); -#ifndef DEDICATED - spdlog::rotating_logger_mt("netconsole" - , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "netconsole.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); -#endif // !DEDICATED - spdlog::rotating_logger_mt("filesystem" - , fmt::format("{:s}{:s}" ,g_svLogSessionDirectory, "filesystem.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); - } +#ifndef NETCONSOLE + spdlog::set_default_logger(g_TermLogger); // Set as default. + SpdLog_Create(); +#endif // !NETCONSOLE spdlog::set_level(spdlog::level::trace); bInitialized = true; } +void SpdLog_Create() +{ + /************************ + * ROTATE LOGGER SETUP * + ************************/ + spdlog::rotating_logger_mt("squirrel_re(warning)" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "script_warning.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); + spdlog::rotating_logger_mt("squirrel_re" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "script.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); + spdlog::rotating_logger_mt("sdk(message)" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "message.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); + spdlog::rotating_logger_mt("sdk(warning)" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "warning.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); + spdlog::rotating_logger_mt("sdk(error)" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "error.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); + spdlog::rotating_logger_mt("net_trace" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "net_trace.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); +#ifndef DEDICATED + spdlog::rotating_logger_mt("netconsole" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "netconsole.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); +#endif // !DEDICATED + spdlog::rotating_logger_mt("filesystem" + , fmt::format("{:s}{:s}", g_svLogSessionDirectory, "filesystem.log"), SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v"); +} + //############################################################################# // SPDLOG POST INIT //############################################################################# void SpdLog_PostInit() { +#ifndef NETCONSOLE spdlog::flush_every(std::chrono::seconds(5)); // Flush buffers every 5 seconds for every logger. + g_ImGuiLogger->set_pattern("%v"); +#endif // !NETCONSOLE - std::shared_ptr iconsole = spdlog::get("game_console"); - std::shared_ptr wconsole = spdlog::get("win_console"); - - iconsole->set_pattern("%v"); - - if (g_svCmdLine.find("-ansiclr") != string::npos) + if (g_svCmdLine.find("-ansicolor") != string::npos) { - wconsole->set_pattern("%v\u001b[0m"); + g_TermLogger->set_pattern("%v\u001b[0m"); g_bSpdLog_UseAnsiClr = true; } - else { wconsole->set_pattern("%v"); } + else { g_TermLogger->set_pattern("%v"); } g_bSpdLog_PostInit = true; } diff --git a/r5dev/core/logdef.h b/r5dev/core/logdef.h index 049e0ddd..b1a88f3c 100644 --- a/r5dev/core/logdef.h +++ b/r5dev/core/logdef.h @@ -8,11 +8,15 @@ inline bool g_bSpdLog_PostInit = false; inline string g_svLogSessionDirectory; +extern std::shared_ptr g_TermLogger; +extern std::shared_ptr g_ImGuiLogger; + //------------------------------------------------------------------------- // IMGUI CONSOLE SINK | inline std::ostringstream g_LogStream; inline auto g_LogSink = std::make_shared(g_LogStream); void SpdLog_Init(void); +void SpdLog_Create(void); void SpdLog_PostInit(void); void SpdLog_Shutdown(void); diff --git a/r5dev/core/termutil.cpp b/r5dev/core/termutil.cpp index 2793ffdf..f1b181d3 100644 --- a/r5dev/core/termutil.cpp +++ b/r5dev/core/termutil.cpp @@ -19,7 +19,7 @@ std::string g_svCmdLine; //----------------------------------------------------------------------------- // Purpose: sets the global ansi escape sequences. -// If '-ansiclr' has not been passed to the sdk the char will be empty. +// If '-ansicolor' has not been passed to the sdk the char will be empty. //----------------------------------------------------------------------------- void AnsiColors_Init() { diff --git a/r5dev/engine/client/cl_rcon.cpp b/r5dev/engine/client/cl_rcon.cpp index 0a6e431a..80f8f0c7 100644 --- a/r5dev/engine/client/cl_rcon.cpp +++ b/r5dev/engine/client/cl_rcon.cpp @@ -89,7 +89,7 @@ bool CRConClient::Connect(const char* szInAdr) char szHostName[512]; if (!gethostname(szHostName, sizeof(szHostName))) { - svLocalHost = fmt::format("[{:s}]:{:s}", szHostName, hostport->GetString()); + svLocalHost = Format("[%s]:%s", szHostName, hostport->GetString()); szInAdr = svLocalHost.c_str(); } } @@ -264,12 +264,14 @@ void CRConClient::ProcessMessage(const sv_rcon::response& sv_response) const } } - DevMsg(eDLL_T::NETCON, "%s", PrintPercentageEscape(sv_response.responsebuf()).c_str()); + DevMsg(eDLL_T::NETCON, "%s", PrintPercentageEscape(sv_response.responsemsg()).c_str()); break; } case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: { - NetMsg(static_cast(sv_response.responseid()), PrintPercentageEscape(sv_response.responsebuf()).c_str()); + NetMsg(static_cast(sv_response.messagetype()), + static_cast(sv_response.messageid()), sv_response.responseval().c_str(), + PrintPercentageEscape(sv_response.responsemsg()).c_str()); break; } default: @@ -290,7 +292,7 @@ string CRConClient::Serialize(const string& svReqBuf, const string& svReqVal, co { cl_rcon::request cl_request; - cl_request.set_requestid(-1); + cl_request.set_messageid(-1); cl_request.set_requesttype(request_t); switch (request_t) @@ -298,13 +300,13 @@ string CRConClient::Serialize(const string& svReqBuf, const string& svReqVal, co case cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE: case cl_rcon::request_t::SERVERDATA_REQUEST_AUTH: { - cl_request.set_requestbuf(svReqBuf); + cl_request.set_requestmsg(svReqBuf); cl_request.set_requestval(svReqVal); break; } case cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND: { - cl_request.set_requestbuf(svReqBuf); + cl_request.set_requestmsg(svReqBuf); break; } } diff --git a/r5dev/engine/net.cpp b/r5dev/engine/net.cpp index 839b1d4a..c4addbb2 100644 --- a/r5dev/engine/net.cpp +++ b/r5dev/engine/net.cpp @@ -118,21 +118,25 @@ void NET_GenerateKey() //----------------------------------------------------------------------------- void NET_PrintFunc(const char* fmt, ...) { - static char buf[2048]; #ifndef DEDICATED const static eDLL_T context = eDLL_T::CLIENT; #else // !DEDICATED const static eDLL_T context = eDLL_T::SERVER; #endif + + string result; + va_list args; va_start(args, fmt); - - vsnprintf(buf, sizeof(buf), fmt, args); - - buf[sizeof(buf) - 1] = '\0'; + result = FormatV(fmt, args); va_end(args); - DevMsg(context, "%s", buf); + if (result.back() != '\n') + { + result.push_back('\n'); + } + + DevMsg(context, "%s", result.c_str()); } //----------------------------------------------------------------------------- diff --git a/r5dev/engine/server/sv_rcon.cpp b/r5dev/engine/server/sv_rcon.cpp index f9f0f9ce..c10117b3 100644 --- a/r5dev/engine/server/sv_rcon.cpp +++ b/r5dev/engine/server/sv_rcon.cpp @@ -186,32 +186,36 @@ void CRConServer::Send(const SocketHandle_t hSocket, const std::string& svMessag //----------------------------------------------------------------------------- // Purpose: send serialized message to all connected sockets -// Input : *svRspBuf - -// *svRspVal - +// Input : *responseMsg - +// *responseVal - // responseType - -// nResponseId - +// nMessageId - +// nMessageType - //----------------------------------------------------------------------------- -void CRConServer::Send(const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId) +void CRConServer::Send(const std::string& responseMsg, const std::string& responseVal, + const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) { if (this->ShouldSend(responseType)) { - this->Send(this->Serialize(svRspBuf, svRspVal, responseType, nResponseId)); + this->Send(this->Serialize(responseMsg, responseVal, responseType, nMessageId, nMessageType)); } } //----------------------------------------------------------------------------- // Purpose: send serialized message to specific connected socket // Input : hSocket - -// *svRspBuf - -// *svRspVal - +// *responseMsg - +// *responseVal - // responseType - -// nResponseId - +// nMessageId - +// nMessageType - //----------------------------------------------------------------------------- -void CRConServer::Send(const SocketHandle_t hSocket, const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId) +void CRConServer::Send(const SocketHandle_t hSocket, const std::string& responseMsg, + const std::string& responseVal, const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) { if (this->ShouldSend(responseType)) { - this->Send(hSocket, this->Serialize(svRspBuf, svRspVal, responseType, nResponseId)); + this->Send(hSocket, this->Serialize(responseMsg, responseVal, responseType, nMessageId, nMessageType)); } } @@ -271,30 +275,29 @@ void CRConServer::Recv(void) //----------------------------------------------------------------------------- // Purpose: serializes input -// Input : *svRspBuf - -// *svRspVal - +// Input : *responseMsg - +// *responseVal - // responseType - +// nMessageId - +// nMessageType - // Output : serialized results as string //----------------------------------------------------------------------------- -std::string CRConServer::Serialize(const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId) const +std::string CRConServer::Serialize(const std::string& responseMsg, const std::string& responseVal, + const sv_rcon::response_t responseType, const int nMessageId, const int nMessageType) const { sv_rcon::response sv_response; - sv_response.set_responseid(nResponseId); + sv_response.set_messageid(nMessageId); + sv_response.set_messagetype(nMessageType); sv_response.set_responsetype(responseType); switch (responseType) { case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH: - { - sv_response.set_responsebuf(svRspBuf); - sv_response.set_responseval(svRspVal); - break; - } case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: { - sv_response.set_responsebuf(svRspBuf); - sv_response.set_responseval(svRspVal); + sv_response.set_responsemsg(responseMsg); + sv_response.set_responseval(responseVal); break; } default: @@ -331,7 +334,7 @@ void CRConServer::Authenticate(const cl_rcon::request& cl_request, CConnectedNet } else // Authorize. { - if (this->Comparator(cl_request.requestbuf())) + if (this->Comparator(cl_request.requestmsg())) { pData->m_bAuthorized = true; m_Socket.CloseListenSocket(); @@ -508,7 +511,7 @@ void CRConServer::Execute(const cl_rcon::request& cl_request, const bool bConVar { if (bConVar) { - ConVar* pConVar = g_pCVar->FindVar(cl_request.requestbuf().c_str()); + ConVar* pConVar = g_pCVar->FindVar(cl_request.requestmsg().c_str()); if (pConVar) // Only run if this is a ConVar. { pConVar->SetValue(cl_request.requestval().c_str()); @@ -516,7 +519,7 @@ void CRConServer::Execute(const cl_rcon::request& cl_request, const bool bConVar } else // Execute command with "". { - Cbuf_AddText(Cbuf_GetCurrentPlayer(), cl_request.requestbuf().c_str(), cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), cl_request.requestmsg().c_str(), cmd_source_t::kCommandSrcCode); } } diff --git a/r5dev/engine/server/sv_rcon.h b/r5dev/engine/server/sv_rcon.h index 7f57ed9f..6c09d4c5 100644 --- a/r5dev/engine/server/sv_rcon.h +++ b/r5dev/engine/server/sv_rcon.h @@ -22,11 +22,14 @@ public: void Think(void); void RunFrame(void); - void Send(const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId = -4); - void Send(const SocketHandle_t hSocket, const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId = -4); + void Send(const std::string& responseMsg, const std::string& responseVal, const sv_rcon::response_t responseType, + const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(LogType_t::LOG_NET)); + void Send(const SocketHandle_t hSocket, const std::string& responseMsg, const std::string& responseVal, + const sv_rcon::response_t responseType, const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(LogType_t::LOG_NET)); void Recv(void); - std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, const sv_rcon::response_t responseType, const int nResponseId = -4) const; + std::string Serialize(const std::string& responseMsg, const std::string& responseVal, const sv_rcon::response_t responseType, + const int nMessageId = static_cast(eDLL_T::NETCON), const int nMessageType = static_cast(LogType_t::LOG_NET)) const; cl_rcon::request Deserialize(const std::string& svBuf) const; void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData); diff --git a/r5dev/netconsole/dbg_stub.cpp b/r5dev/netconsole/dbg_stub.cpp deleted file mode 100644 index 02dc02eb..00000000 --- a/r5dev/netconsole/dbg_stub.cpp +++ /dev/null @@ -1,120 +0,0 @@ -//===========================================================================// -// -// Purpose: stub implementation of 'tier0/dbg.cpp' -// -//===========================================================================// - -#include "core/stdafx.h" - -void LogStub(const char* fmt, ...) -{ - static char szBuf[4096] = {}; - - {///////////////////////////// - va_list args{}; - va_start(args, fmt); - - vsnprintf(szBuf, sizeof(szBuf), fmt, args); - - szBuf[sizeof(szBuf) - 1] = '\0'; - va_end(args); - }///////////////////////////// - - printf("%s", szBuf); -} - -//----------------------------------------------------------------------------- -// Purpose: Netconsole log -// Input : context - -// *fmt - ... - -//----------------------------------------------------------------------------- -void NetMsg(eDLL_T context, const char* fmt, ...) -{ - static char szBuf[4096] = {}; - - {///////////////////////////// - va_list args{}; - va_start(args, fmt); - - vsnprintf(szBuf, sizeof(szBuf), fmt, args); - - szBuf[sizeof(szBuf) - 1] = '\0'; - va_end(args); - }///////////////////////////// - - printf("%s", szBuf); -} - -//----------------------------------------------------------------------------- -// Purpose: Show logs to all console interfaces -// Input : context - -// *fmt - ... - -//----------------------------------------------------------------------------- -void DevMsg(eDLL_T context, const char* fmt, ...) -{ - static char szBuf[4096] = {}; - - {///////////////////////////// - va_list args{}; - va_start(args, fmt); - - vsnprintf(szBuf, sizeof(szBuf), fmt, args); - - szBuf[sizeof(szBuf) - 1] = '\0'; - va_end(args); - }///////////////////////////// - - printf("%s", szBuf); -} - -//----------------------------------------------------------------------------- -// Purpose: Print engine and SDK errors -// Input : context - -// *fmt - ... - -//----------------------------------------------------------------------------- -void Warning(eDLL_T context, const char* fmt, ...) -{ - static char szBuf[4096] = {}; - - {///////////////////////////// - va_list args{}; - va_start(args, fmt); - - vsnprintf(szBuf, sizeof(szBuf), fmt, args); - - szBuf[sizeof(szBuf) - 1] = '\0'; - va_end(args); - }///////////////////////////// - - printf("%s", szBuf); -} - -//----------------------------------------------------------------------------- -// Purpose: Print engine and SDK errors -// Input : context - -// code - -// *fmt - ... - -//----------------------------------------------------------------------------- -void Error(eDLL_T context, const UINT code, const char* fmt, ...) -{ - static char szBuf[4096] = {}; - - {///////////////////////////// - va_list args{}; - va_start(args, fmt); - - vsnprintf(szBuf, sizeof(szBuf), fmt, args); - - szBuf[sizeof(szBuf) - 1] = '\0'; - va_end(args); - }///////////////////////////// - - printf("%s", szBuf); - if (code) // Terminate the process if an exit code was passed. - { - if (MessageBoxA(NULL, szBuf, "SDK Error", MB_ICONERROR | MB_OK)) - { - TerminateProcess(GetCurrentProcess(), code); - } - } -} diff --git a/r5dev/netconsole/netconsole.cpp b/r5dev/netconsole/netconsole.cpp index d6d77a60..2df15ed7 100644 --- a/r5dev/netconsole/netconsole.cpp +++ b/r5dev/netconsole/netconsole.cpp @@ -6,8 +6,10 @@ #include "core/stdafx.h" #include "core/termutil.h" +#include "core/logdef.h" #include "tier1/NetAdr.h" #include "tier2/socketcreator.h" +#include "windows/console.h" #include "protoc/sv_rcon.pb.h" #include "protoc/cl_rcon.pb.h" #include "public/utility/utility.h" @@ -19,10 +21,9 @@ //----------------------------------------------------------------------------- CNetCon::CNetCon(void) : m_bInitialized(false) - , m_bNoColor(false) , m_bQuitApplication(false) - , m_abPromptConnect(true) - , m_abConnEstablished(false) + , m_bPromptConnect(true) + , m_bConnEstablished(false) { } @@ -44,11 +45,12 @@ bool CNetCon::Init(void) if (nError != 0) { - Error(eDLL_T::NETCON, NO_ERROR, "%s - Failed to start Winsock: (%s)\n", __FUNCTION__, NET_ErrorString(WSAGetLastError())); + Error(eDLL_T::NONE, NO_ERROR, "%s - Failed to start Winsock: (%s)\n", __FUNCTION__, NET_ErrorString(WSAGetLastError())); return false; } this->TermSetup(); + DevMsg(eDLL_T::NONE, "R5 TCP net console [Version %s]\n", NETCON_VERSION); static std::thread frame([this]() { @@ -68,16 +70,25 @@ bool CNetCon::Init(void) //----------------------------------------------------------------------------- bool CNetCon::Shutdown(void) { + bool bResult = false; + m_Socket.CloseAllAcceptedSockets(); - m_abConnEstablished = false; + m_bConnEstablished = false; const int nError = ::WSACleanup(); - if (nError != 0) + if (nError == 0) { - Error(eDLL_T::NETCON, NO_ERROR, "%s - Failed to stop Winsock: (%s)\n", __FUNCTION__, NET_ErrorString(WSAGetLastError())); - return false; + bResult = true; } - return true; + else // WSACleanup() failed. + { + Error(eDLL_T::NONE, NO_ERROR, "%s - Failed to stop Winsock: (%s)\n", __FUNCTION__, NET_ErrorString(WSAGetLastError())); + } + + SpdLog_Shutdown(); + Console_Shutdown(); + + return bResult; } //----------------------------------------------------------------------------- @@ -85,36 +96,11 @@ bool CNetCon::Shutdown(void) //----------------------------------------------------------------------------- void CNetCon::TermSetup(void) { - DWORD dwMode = NULL; - HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); - HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE); + g_svCmdLine = GetCommandLineA(); - if (!strstr(GetCommandLineA(), "-nocolor")) - { - GetConsoleMode(hOutput, &dwMode); - dwMode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; - - if (!SetConsoleMode(hOutput, dwMode)) // Some editions of Windows have 'VirtualTerminalLevel' disabled by default. - { - // Warn the user if 'VirtualTerminalLevel' could not be set on users environment. - MessageBoxA(NULL, "Failed to set console mode 'VirtualTerminalLevel'.\n" - "Restart the net console with the '-nocolor'\n" - "parameter if output logging appears distorted.", "SDK Warning", - MB_ICONEXCLAMATION | MB_OK); - } - AnsiColors_Init(); - } - else - { - m_bNoColor = true; - } - - CONSOLE_SCREEN_BUFFER_INFOEX sbInfoEx{}; - sbInfoEx.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX); - - GetConsoleScreenBufferInfoEx(hOutput, &sbInfoEx); - sbInfoEx.ColorTable[0] = 0x0000; - SetConsoleScreenBufferInfoEx(hOutput, &sbInfoEx); + SpdLog_Init(); + SpdLog_PostInit(); + Console_Init(); } //----------------------------------------------------------------------------- @@ -122,26 +108,24 @@ void CNetCon::TermSetup(void) //----------------------------------------------------------------------------- void CNetCon::UserInput(void) { - std::string svInput; - - if (std::getline(std::cin, svInput)) + if (std::getline(std::cin, m_Input)) { - if (svInput.compare("nquit") == 0) + if (m_Input.compare("nquit") == 0) { m_bQuitApplication = true; return; } std::lock_guard l(m_Mutex); - if (m_abConnEstablished) + if (m_bConnEstablished) { - if (svInput.compare("disconnect") == 0) + if (m_Input.compare("disconnect") == 0) { this->Disconnect(); return; } - const std::vector vSubStrings = StringSplit(svInput, ' ', 2); + const std::vector vSubStrings = StringSplit(m_Input, ' ', 2); if (vSubStrings.size() > 1) { if (vSubStrings[0].compare("PASS") == 0) // Auth with RCON server. @@ -159,41 +143,41 @@ void CNetCon::UserInput(void) } else // Execute command query. { - std::string svSerialized = this->Serialize(svInput, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); + std::string svSerialized = this->Serialize(m_Input, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); this->Send(svSerialized); } } - else if (!svInput.empty()) // Single arg command query. + else if (!m_Input.empty()) // Single arg command query. { - std::string svSerialized = this->Serialize(svInput, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); + std::string svSerialized = this->Serialize(m_Input, "", cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND); this->Send(svSerialized); } } else // Setup connection from input. { - const std::vector vSubStrings = StringSplit(svInput, ' ', 2); + const std::vector vSubStrings = StringSplit(m_Input, ' ', 2); if (vSubStrings.size() > 1) { - const string::size_type nPos = svInput.find(' '); + const string::size_type nPos = m_Input.find(' '); if (nPos > 0 - && nPos < svInput.size() - && nPos != svInput.size()) + && nPos < m_Input.size() + && nPos != m_Input.size()) { - std::string svInPort = svInput.substr(nPos + 1); - std::string svInAdr = svInput.erase(svInput.find(' ')); + std::string svInPort = m_Input.substr(nPos + 1); + std::string svInAdr = m_Input.erase(m_Input.find(' ')); if (!this->Connect(svInAdr, svInPort)) { - m_abPromptConnect = true; + m_bPromptConnect = true; return; } } } else // Initialize as [ip]:port. { - if (!this->Connect(svInput, "")) + if (!this->Connect(m_Input, "")) { - m_abPromptConnect = true; + m_bPromptConnect = true; return; } } @@ -201,22 +185,30 @@ void CNetCon::UserInput(void) } } +//----------------------------------------------------------------------------- +// Purpose: clears the input buffer +//----------------------------------------------------------------------------- +void CNetCon::ClearInput(void) +{ + m_Input.clear(); +} + //----------------------------------------------------------------------------- // Purpose: client's main processing loop //----------------------------------------------------------------------------- void CNetCon::RunFrame(void) { - if (m_abConnEstablished) + if (m_bConnEstablished) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::lock_guard l(m_Mutex); this->Recv(); } - else if (m_abPromptConnect) + else if (m_bPromptConnect) { - DevMsg(eDLL_T::NETCON, "Enter []: or : "); - m_abPromptConnect = false; + DevMsg(eDLL_T::NONE, "Enter []: or : "); + m_bPromptConnect = false; } } @@ -249,7 +241,7 @@ bool CNetCon::Connect(const std::string& svInAdr, const std::string& svInPort) } } - const string svFull = fmt::format("[{:s}]:{:s}", svLocalHost.empty() ? svInAdr : svLocalHost, svInPort); + const string svFull = Format("[%s]:%s", svLocalHost.empty() ? svInAdr.c_str() : svLocalHost.c_str(), svInPort.c_str()); if (!m_Address.SetFromString(svFull.c_str(), true)) { Warning(eDLL_T::CLIENT, "Failed to set RCON address: %s\n", svFull.c_str()); @@ -264,18 +256,18 @@ bool CNetCon::Connect(const std::string& svInAdr, const std::string& svInPort) } else { - Warning(eDLL_T::NETCON, "No IP address provided\n"); + Warning(eDLL_T::NONE, "No IP address provided\n"); return false; } if (m_Socket.ConnectSocket(m_Address, true) == SOCKET_ERROR) { - Error(eDLL_T::NETCON, NO_ERROR, "Failed to connect: error(%s); verify IP and PORT\n", "SOCKET_ERROR"); + Error(eDLL_T::NONE, NO_ERROR, "Failed to connect: error(%s); verify IP and PORT\n", "SOCKET_ERROR"); return false; } - DevMsg(eDLL_T::NETCON, "Connected to: %s\n", m_Address.ToString()); + DevMsg(eDLL_T::NONE, "Connected to: %s\n", m_Address.ToString()); - m_abConnEstablished = true; + m_bConnEstablished = true; return true; } @@ -285,8 +277,8 @@ bool CNetCon::Connect(const std::string& svInAdr, const std::string& svInPort) void CNetCon::Disconnect(void) { m_Socket.CloseAcceptedSocket(0); - m_abPromptConnect = true; - m_abConnEstablished = false; + m_bPromptConnect = true; + m_bConnEstablished = false; } //----------------------------------------------------------------------------- @@ -305,7 +297,7 @@ void CNetCon::Send(const std::string& svMessage) const ssSendBuf.str().data(), static_cast(ssSendBuf.str().size()), MSG_NOSIGNAL); if (nSendResult == SOCKET_ERROR) { - Error(eDLL_T::NETCON, NO_ERROR, "Failed to send message (%s)\n", "SOCKET_ERROR"); + Error(eDLL_T::NONE, NO_ERROR, "Failed to send message (%s)\n", "SOCKET_ERROR"); } } @@ -323,10 +315,10 @@ void CNetCon::Recv(void) { return; } - if (nPendingLen <= 0 && m_abConnEstablished) // EOF or error. + if (nPendingLen <= 0 && m_bConnEstablished) // EOF or error. { this->Disconnect(); - DevMsg(eDLL_T::NETCON, "Server closed connection\n"); + DevMsg(eDLL_T::NONE, "Server closed connection\n"); return; } }////////////////////////////////////////////// @@ -337,15 +329,15 @@ void CNetCon::Recv(void) while (nReadLen > 0) { const int nRecvLen = ::recv(pData->m_hSocket, szRecvBuf, MIN(sizeof(szRecvBuf), nReadLen), MSG_NOSIGNAL); - if (nRecvLen == 0 && m_abConnEstablished) // Socket was closed. + if (nRecvLen == 0 && m_bConnEstablished) // Socket was closed. { this->Disconnect(); - DevMsg(eDLL_T::NETCON, "Server closed connection\n"); + DevMsg(eDLL_T::NONE, "Server closed connection\n"); break; } if (nRecvLen < 0 && !m_Socket.IsSocketBlocking()) { - Error(eDLL_T::NETCON, NO_ERROR, "RCON Cmd: recv error (%s)\n", NET_ErrorString(WSAGetLastError())); + Error(eDLL_T::NONE, NO_ERROR, "RCON Cmd: recv error (%s)\n", NET_ErrorString(WSAGetLastError())); break; } @@ -397,7 +389,7 @@ void CNetCon::ProcessBuffer(const char* pRecvBuf, int nRecvLen, CConnectedNetCon if (pData->m_nPayloadLen < 0 || pData->m_nPayloadLen > pData->m_RecvBuffer.max_size()) { - Error(eDLL_T::NETCON, NO_ERROR, "RCON Cmd: sync error (%zu)\n", pData->m_nPayloadLen); + Error(eDLL_T::NONE, NO_ERROR, "RCON Cmd: sync error (%zu)\n", pData->m_nPayloadLen); this->Disconnect(); // Out of sync (irrecoverable). break; @@ -429,20 +421,15 @@ void CNetCon::ProcessMessage(const sv_rcon::response& sv_response) const this->Send(svLogQuery); } } - [[fallthrough]]; + + DevMsg(eDLL_T::NETCON, "%s", PrintPercentageEscape(sv_response.responsemsg()).c_str()); + break; } case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: { - std::string svOut = sv_response.responsebuf(); - if (m_bNoColor) - { - svOut = std::regex_replace(svOut, std::regex("\\\033\\[.*?m"), ""); - } - else - { - svOut.append(g_svReset); - } - NetMsg(eDLL_T::NONE, svOut.c_str()); + NetMsg(static_cast(sv_response.messagetype()), + static_cast(sv_response.messageid()), sv_response.responseval().c_str(), + PrintPercentageEscape(sv_response.responsemsg()).c_str()); break; } default: @@ -463,7 +450,7 @@ std::string CNetCon::Serialize(const std::string& svReqBuf, const std::string& s { cl_rcon::request cl_request; - cl_request.set_requestid(-1); + cl_request.set_messageid(-1); cl_request.set_requesttype(request_t); switch (request_t) @@ -471,13 +458,13 @@ std::string CNetCon::Serialize(const std::string& svReqBuf, const std::string& s case cl_rcon::request_t::SERVERDATA_REQUEST_SETVALUE: case cl_rcon::request_t::SERVERDATA_REQUEST_AUTH: { - cl_request.set_requestbuf(svReqBuf); + cl_request.set_requestmsg(svReqBuf); cl_request.set_requestval(svReqVal); break; } case cl_rcon::request_t::SERVERDATA_REQUEST_EXECCOMMAND: { - cl_request.set_requestbuf(svReqBuf); + cl_request.set_requestmsg(svReqBuf); break; } } @@ -504,8 +491,6 @@ sv_rcon::response CNetCon::Deserialize(const std::string& svBuf) const //----------------------------------------------------------------------------- int main(int argc, char* argv[]) { - DevMsg(eDLL_T::NETCON, "R5Reloaded TCP net console [Version %s]\n", NETCON_VERSION); - if (!NetConsole()->Init()) { return EXIT_FAILURE; @@ -522,6 +507,7 @@ int main(int argc, char* argv[]) while (!NetConsole()->ShouldQuit()) { NetConsole()->UserInput(); + NetConsole()->ClearInput(); } if (!NetConsole()->Shutdown()) diff --git a/r5dev/netconsole/netconsole.h b/r5dev/netconsole/netconsole.h index e88777fb..92807322 100644 --- a/r5dev/netconsole/netconsole.h +++ b/r5dev/netconsole/netconsole.h @@ -20,6 +20,7 @@ public: void TermSetup(void); void UserInput(void); + void ClearInput(void); void RunFrame(void); bool ShouldQuit(void) const; @@ -38,13 +39,13 @@ public: private: bool m_bInitialized; - bool m_bNoColor; bool m_bQuitApplication; - std::atomic m_abPromptConnect; - std::atomic m_abConnEstablished; + bool m_bPromptConnect; + bool m_bConnEstablished; CNetAdr m_Address; CSocketCreator m_Socket; + std::string m_Input; mutable std::mutex m_Mutex; }; @@ -52,4 +53,4 @@ private: //----------------------------------------------------------------------------- // singleton //----------------------------------------------------------------------------- -extern CNetCon* NetConsole(); \ No newline at end of file +extern CNetCon* NetConsole(); diff --git a/r5dev/netconsole/plat_time.cpp b/r5dev/netconsole/plat_time.cpp new file mode 100644 index 00000000..523baeb3 --- /dev/null +++ b/r5dev/netconsole/plat_time.cpp @@ -0,0 +1,87 @@ +#include "core/stdafx.h" + +static LARGE_INTEGER g_PerformanceFrequency; +static double g_PerformanceCounterToS; +static double g_PerformanceCounterToMS; +static double g_PerformanceCounterToUS; +static LARGE_INTEGER g_ClockStart; +static bool s_bTimeInitted = false; + +// Benchmark mode uses this heavy-handed method +static bool g_bBenchmarkMode = false; +static double g_FakeBenchmarkTime = 0; +static double g_FakeBenchmarkTimeInc = 1.0 / 66.0; + +static void InitTime() +{ + if (!s_bTimeInitted) + { + s_bTimeInitted = true; + QueryPerformanceFrequency(&g_PerformanceFrequency); + g_PerformanceCounterToS = 1.0 / g_PerformanceFrequency.QuadPart; + g_PerformanceCounterToMS = 1e3 / g_PerformanceFrequency.QuadPart; + g_PerformanceCounterToUS = 1e6 / g_PerformanceFrequency.QuadPart; + QueryPerformanceCounter(&g_ClockStart); + } +} + +double Plat_FloatTime() +{ + if (!s_bTimeInitted) + InitTime(); + if (g_bBenchmarkMode) + { + g_FakeBenchmarkTime += g_FakeBenchmarkTimeInc; + return g_FakeBenchmarkTime; + } + + LARGE_INTEGER CurrentTime; + + QueryPerformanceCounter(&CurrentTime); + + double fRawSeconds = (double)(CurrentTime.QuadPart - g_ClockStart.QuadPart) * g_PerformanceCounterToS; + + return fRawSeconds; +} + +uint64_t Plat_MSTime() +{ + if (!s_bTimeInitted) + InitTime(); + if (g_bBenchmarkMode) + { + g_FakeBenchmarkTime += g_FakeBenchmarkTimeInc; + return (uint64_t)(g_FakeBenchmarkTime * 1000.0); + } + + LARGE_INTEGER CurrentTime; + + QueryPerformanceCounter(&CurrentTime); + + return (uint64_t)((CurrentTime.QuadPart - g_ClockStart.QuadPart) * g_PerformanceCounterToMS); +} + +uint64 Plat_USTime() +{ + if (!s_bTimeInitted) + InitTime(); + if (g_bBenchmarkMode) + { + g_FakeBenchmarkTime += g_FakeBenchmarkTimeInc; + return (uint64)(g_FakeBenchmarkTime * 1e6); + } + + LARGE_INTEGER CurrentTime; + + QueryPerformanceCounter(&CurrentTime); + + return (uint64)((CurrentTime.QuadPart - g_ClockStart.QuadPart) * g_PerformanceCounterToUS); +} + +const char* Plat_GetProcessUpTime() +{ + static char szBuf[4096]; + sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", Plat_FloatTime()); + + return szBuf; +} diff --git a/r5dev/protoc/cl_rcon.pb.cc b/r5dev/protoc/cl_rcon.pb.cc index db33d890..9855f349 100644 --- a/r5dev/protoc/cl_rcon.pb.cc +++ b/r5dev/protoc/cl_rcon.pb.cc @@ -22,9 +22,10 @@ PROTOBUF_CONSTEXPR request::request( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.requestbuf_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.requestmsg_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.requestval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.requestid_)*/0 + , /*decltype(_impl_.messageid_)*/0 + , /*decltype(_impl_.messagetype_)*/0 , /*decltype(_impl_.requesttype_)*/0} {} struct requestDefaultTypeInternal { PROTOBUF_CONSTEXPR requestDefaultTypeInternal() @@ -110,13 +111,16 @@ bool request_t_Parse( class request::_Internal { public: using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_requestid(HasBits* has_bits) { + static void set_has_messageid(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static void set_has_requesttype(HasBits* has_bits) { + static void set_has_messagetype(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_requestbuf(HasBits* has_bits) { + static void set_has_requesttype(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_requestmsg(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_requestval(HasBits* has_bits) { @@ -136,18 +140,19 @@ request::request(const request& from) new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.requestbuf_){} + , decltype(_impl_.requestmsg_){} , decltype(_impl_.requestval_){} - , decltype(_impl_.requestid_){} + , decltype(_impl_.messageid_){} + , decltype(_impl_.messagetype_){} , decltype(_impl_.requesttype_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.requestbuf_.InitDefault(); + _impl_.requestmsg_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.requestbuf_.Set("", GetArenaForAllocation()); + _impl_.requestmsg_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_requestbuf()) { - _this->_impl_.requestbuf_.Set(from._internal_requestbuf(), + if (from._internal_has_requestmsg()) { + _this->_impl_.requestmsg_.Set(from._internal_requestmsg(), _this->GetArenaForAllocation()); } _impl_.requestval_.InitDefault(); @@ -158,9 +163,9 @@ request::request(const request& from) _this->_impl_.requestval_.Set(from._internal_requestval(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.requestid_, &from._impl_.requestid_, + ::memcpy(&_impl_.messageid_, &from._impl_.messageid_, static_cast(reinterpret_cast(&_impl_.requesttype_) - - reinterpret_cast(&_impl_.requestid_)) + sizeof(_impl_.requesttype_)); + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.requesttype_)); // @@protoc_insertion_point(copy_constructor:cl_rcon.request) } @@ -171,14 +176,15 @@ inline void request::SharedCtor( new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.requestbuf_){} + , decltype(_impl_.requestmsg_){} , decltype(_impl_.requestval_){} - , decltype(_impl_.requestid_){0} + , decltype(_impl_.messageid_){0} + , decltype(_impl_.messagetype_){0} , decltype(_impl_.requesttype_){0} }; - _impl_.requestbuf_.InitDefault(); + _impl_.requestmsg_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.requestbuf_.Set("", GetArenaForAllocation()); + _impl_.requestmsg_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.requestval_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -197,7 +203,7 @@ request::~request() { inline void request::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.requestbuf_.Destroy(); + _impl_.requestmsg_.Destroy(); _impl_.requestval_.Destroy(); } @@ -214,16 +220,16 @@ void request::Clear() { cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.requestbuf_.ClearNonDefaultToEmpty(); + _impl_.requestmsg_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { _impl_.requestval_.ClearNonDefaultToEmpty(); } } - if (cached_has_bits & 0x0000000cu) { - ::memset(&_impl_.requestid_, 0, static_cast( + if (cached_has_bits & 0x0000001cu) { + ::memset(&_impl_.messageid_, 0, static_cast( reinterpret_cast(&_impl_.requesttype_) - - reinterpret_cast(&_impl_.requestid_)) + sizeof(_impl_.requesttype_)); + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.requesttype_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); @@ -236,37 +242,46 @@ const char* request::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional int32 requestID = 1; + // optional int32 messageID = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_requestid(&has_bits); - _impl_.requestid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _Internal::set_has_messageid(&has_bits); + _impl_.messageid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional .cl_rcon.request_t requestType = 2; + // optional int32 messageType = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_messagetype(&has_bits); + _impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .cl_rcon.request_t requestType = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); _internal_set_requesttype(static_cast<::cl_rcon::request_t>(val)); } else goto handle_unusual; continue; - // optional string requestBuf = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_requestbuf(); + // optional string requestMsg = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_requestmsg(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; - // optional string requestVal = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + // optional string requestVal = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { auto str = _internal_mutable_requestval(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); @@ -304,37 +319,43 @@ uint8_t* request::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - // optional int32 requestID = 1; - if (_internal_has_requestid()) { + // optional int32 messageID = 1; + if (_internal_has_messageid()) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_requestid(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_messageid(), target); } - // optional .cl_rcon.request_t requestType = 2; + // optional int32 messageType = 2; + if (_internal_has_messagetype()) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_messagetype(), target); + } + + // optional .cl_rcon.request_t requestType = 3; if (_internal_has_requesttype()) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( - 2, this->_internal_requesttype(), target); + 3, this->_internal_requesttype(), target); } - // optional string requestBuf = 3; - if (_internal_has_requestbuf()) { + // optional string requestMsg = 4; + if (_internal_has_requestmsg()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_requestbuf().data(), static_cast(this->_internal_requestbuf().length()), + this->_internal_requestmsg().data(), static_cast(this->_internal_requestmsg().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "cl_rcon.request.requestBuf"); + "cl_rcon.request.requestMsg"); target = stream->WriteStringMaybeAliased( - 3, this->_internal_requestbuf(), target); + 4, this->_internal_requestmsg(), target); } - // optional string requestVal = 4; + // optional string requestVal = 5; if (_internal_has_requestval()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_requestval().data(), static_cast(this->_internal_requestval().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "cl_rcon.request.requestVal"); target = stream->WriteStringMaybeAliased( - 4, this->_internal_requestval(), target); + 5, this->_internal_requestval(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -354,28 +375,33 @@ size_t request::ByteSizeLong() const { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional string requestBuf = 3; + if (cached_has_bits & 0x0000001fu) { + // optional string requestMsg = 4; if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_requestbuf()); + this->_internal_requestmsg()); } - // optional string requestVal = 4; + // optional string requestVal = 5; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_requestval()); } - // optional int32 requestID = 1; + // optional int32 messageID = 1; if (cached_has_bits & 0x00000004u) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_requestid()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messageid()); } - // optional .cl_rcon.request_t requestType = 2; + // optional int32 messageType = 2; if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messagetype()); + } + + // optional .cl_rcon.request_t requestType = 3; + if (cached_has_bits & 0x00000010u) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_requesttype()); } @@ -403,17 +429,20 @@ void request::MergeFrom(const request& from) { (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_requestbuf(from._internal_requestbuf()); + _this->_internal_set_requestmsg(from._internal_requestmsg()); } if (cached_has_bits & 0x00000002u) { _this->_internal_set_requestval(from._internal_requestval()); } if (cached_has_bits & 0x00000004u) { - _this->_impl_.requestid_ = from._impl_.requestid_; + _this->_impl_.messageid_ = from._impl_.messageid_; } if (cached_has_bits & 0x00000008u) { + _this->_impl_.messagetype_ = from._impl_.messagetype_; + } + if (cached_has_bits & 0x00000010u) { _this->_impl_.requesttype_ = from._impl_.requesttype_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -439,8 +468,8 @@ void request::InternalSwap(request* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.requestbuf_, lhs_arena, - &other->_impl_.requestbuf_, rhs_arena + &_impl_.requestmsg_, lhs_arena, + &other->_impl_.requestmsg_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.requestval_, lhs_arena, @@ -449,9 +478,9 @@ void request::InternalSwap(request* other) { ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(request, _impl_.requesttype_) + sizeof(request::_impl_.requesttype_) - - PROTOBUF_FIELD_OFFSET(request, _impl_.requestid_)>( - reinterpret_cast(&_impl_.requestid_), - reinterpret_cast(&other->_impl_.requestid_)); + - PROTOBUF_FIELD_OFFSET(request, _impl_.messageid_)>( + reinterpret_cast(&_impl_.messageid_), + reinterpret_cast(&other->_impl_.messageid_)); } std::string request::GetTypeName() const { diff --git a/r5dev/protoc/cl_rcon.pb.h b/r5dev/protoc/cl_rcon.pb.h index 19c5f1f4..a1c4982b 100644 --- a/r5dev/protoc/cl_rcon.pb.h +++ b/r5dev/protoc/cl_rcon.pb.h @@ -182,30 +182,31 @@ class request final : // accessors ------------------------------------------------------- enum : int { - kRequestBufFieldNumber = 3, - kRequestValFieldNumber = 4, - kRequestIDFieldNumber = 1, - kRequestTypeFieldNumber = 2, + kRequestMsgFieldNumber = 4, + kRequestValFieldNumber = 5, + kMessageIDFieldNumber = 1, + kMessageTypeFieldNumber = 2, + kRequestTypeFieldNumber = 3, }; - // optional string requestBuf = 3; - bool has_requestbuf() const; + // optional string requestMsg = 4; + bool has_requestmsg() const; private: - bool _internal_has_requestbuf() const; + bool _internal_has_requestmsg() const; public: - void clear_requestbuf(); - const std::string& requestbuf() const; + void clear_requestmsg(); + const std::string& requestmsg() const; template - void set_requestbuf(ArgT0&& arg0, ArgT... args); - std::string* mutable_requestbuf(); - PROTOBUF_NODISCARD std::string* release_requestbuf(); - void set_allocated_requestbuf(std::string* requestbuf); + void set_requestmsg(ArgT0&& arg0, ArgT... args); + std::string* mutable_requestmsg(); + PROTOBUF_NODISCARD std::string* release_requestmsg(); + void set_allocated_requestmsg(std::string* requestmsg); private: - const std::string& _internal_requestbuf() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestbuf(const std::string& value); - std::string* _internal_mutable_requestbuf(); + const std::string& _internal_requestmsg() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_requestmsg(const std::string& value); + std::string* _internal_mutable_requestmsg(); public: - // optional string requestVal = 4; + // optional string requestVal = 5; bool has_requestval() const; private: bool _internal_has_requestval() const; @@ -223,20 +224,33 @@ class request final : std::string* _internal_mutable_requestval(); public: - // optional int32 requestID = 1; - bool has_requestid() const; + // optional int32 messageID = 1; + bool has_messageid() const; private: - bool _internal_has_requestid() const; + bool _internal_has_messageid() const; public: - void clear_requestid(); - int32_t requestid() const; - void set_requestid(int32_t value); + void clear_messageid(); + int32_t messageid() const; + void set_messageid(int32_t value); private: - int32_t _internal_requestid() const; - void _internal_set_requestid(int32_t value); + int32_t _internal_messageid() const; + void _internal_set_messageid(int32_t value); public: - // optional .cl_rcon.request_t requestType = 2; + // optional int32 messageType = 2; + bool has_messagetype() const; + private: + bool _internal_has_messagetype() const; + public: + void clear_messagetype(); + int32_t messagetype() const; + void set_messagetype(int32_t value); + private: + int32_t _internal_messagetype() const; + void _internal_set_messagetype(int32_t value); + public: + + // optional .cl_rcon.request_t requestType = 3; bool has_requesttype() const; private: bool _internal_has_requesttype() const; @@ -259,9 +273,10 @@ class request final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestbuf_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestmsg_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr requestval_; - int32_t requestid_; + int32_t messageid_; + int32_t messagetype_; int requesttype_; }; union { Impl_ _impl_; }; @@ -278,45 +293,73 @@ class request final : #endif // __GNUC__ // request -// optional int32 requestID = 1; -inline bool request::_internal_has_requestid() const { +// optional int32 messageID = 1; +inline bool request::_internal_has_messageid() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool request::has_requestid() const { - return _internal_has_requestid(); +inline bool request::has_messageid() const { + return _internal_has_messageid(); } -inline void request::clear_requestid() { - _impl_.requestid_ = 0; +inline void request::clear_messageid() { + _impl_.messageid_ = 0; _impl_._has_bits_[0] &= ~0x00000004u; } -inline int32_t request::_internal_requestid() const { - return _impl_.requestid_; +inline int32_t request::_internal_messageid() const { + return _impl_.messageid_; } -inline int32_t request::requestid() const { - // @@protoc_insertion_point(field_get:cl_rcon.request.requestID) - return _internal_requestid(); +inline int32_t request::messageid() const { + // @@protoc_insertion_point(field_get:cl_rcon.request.messageID) + return _internal_messageid(); } -inline void request::_internal_set_requestid(int32_t value) { +inline void request::_internal_set_messageid(int32_t value) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.requestid_ = value; + _impl_.messageid_ = value; } -inline void request::set_requestid(int32_t value) { - _internal_set_requestid(value); - // @@protoc_insertion_point(field_set:cl_rcon.request.requestID) +inline void request::set_messageid(int32_t value) { + _internal_set_messageid(value); + // @@protoc_insertion_point(field_set:cl_rcon.request.messageID) } -// optional .cl_rcon.request_t requestType = 2; -inline bool request::_internal_has_requesttype() const { +// optional int32 messageType = 2; +inline bool request::_internal_has_messagetype() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } +inline bool request::has_messagetype() const { + return _internal_has_messagetype(); +} +inline void request::clear_messagetype() { + _impl_.messagetype_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline int32_t request::_internal_messagetype() const { + return _impl_.messagetype_; +} +inline int32_t request::messagetype() const { + // @@protoc_insertion_point(field_get:cl_rcon.request.messageType) + return _internal_messagetype(); +} +inline void request::_internal_set_messagetype(int32_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.messagetype_ = value; +} +inline void request::set_messagetype(int32_t value) { + _internal_set_messagetype(value); + // @@protoc_insertion_point(field_set:cl_rcon.request.messageType) +} + +// optional .cl_rcon.request_t requestType = 3; +inline bool request::_internal_has_requesttype() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} inline bool request::has_requesttype() const { return _internal_has_requesttype(); } inline void request::clear_requesttype() { _impl_.requesttype_ = 0; - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } inline ::cl_rcon::request_t request::_internal_requesttype() const { return static_cast< ::cl_rcon::request_t >(_impl_.requesttype_); @@ -326,7 +369,7 @@ inline ::cl_rcon::request_t request::requesttype() const { return _internal_requesttype(); } inline void request::_internal_set_requesttype(::cl_rcon::request_t value) { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; _impl_.requesttype_ = value; } inline void request::set_requesttype(::cl_rcon::request_t value) { @@ -334,75 +377,75 @@ inline void request::set_requesttype(::cl_rcon::request_t value) { // @@protoc_insertion_point(field_set:cl_rcon.request.requestType) } -// optional string requestBuf = 3; -inline bool request::_internal_has_requestbuf() const { +// optional string requestMsg = 4; +inline bool request::_internal_has_requestmsg() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool request::has_requestbuf() const { - return _internal_has_requestbuf(); +inline bool request::has_requestmsg() const { + return _internal_has_requestmsg(); } -inline void request::clear_requestbuf() { - _impl_.requestbuf_.ClearToEmpty(); +inline void request::clear_requestmsg() { + _impl_.requestmsg_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& request::requestbuf() const { - // @@protoc_insertion_point(field_get:cl_rcon.request.requestBuf) - return _internal_requestbuf(); +inline const std::string& request::requestmsg() const { + // @@protoc_insertion_point(field_get:cl_rcon.request.requestMsg) + return _internal_requestmsg(); } template inline PROTOBUF_ALWAYS_INLINE -void request::set_requestbuf(ArgT0&& arg0, ArgT... args) { +void request::set_requestmsg(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.requestbuf_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:cl_rcon.request.requestBuf) + _impl_.requestmsg_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:cl_rcon.request.requestMsg) } -inline std::string* request::mutable_requestbuf() { - std::string* _s = _internal_mutable_requestbuf(); - // @@protoc_insertion_point(field_mutable:cl_rcon.request.requestBuf) +inline std::string* request::mutable_requestmsg() { + std::string* _s = _internal_mutable_requestmsg(); + // @@protoc_insertion_point(field_mutable:cl_rcon.request.requestMsg) return _s; } -inline const std::string& request::_internal_requestbuf() const { - return _impl_.requestbuf_.Get(); +inline const std::string& request::_internal_requestmsg() const { + return _impl_.requestmsg_.Get(); } -inline void request::_internal_set_requestbuf(const std::string& value) { +inline void request::_internal_set_requestmsg(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.requestbuf_.Set(value, GetArenaForAllocation()); + _impl_.requestmsg_.Set(value, GetArenaForAllocation()); } -inline std::string* request::_internal_mutable_requestbuf() { +inline std::string* request::_internal_mutable_requestmsg() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.requestbuf_.Mutable(GetArenaForAllocation()); + return _impl_.requestmsg_.Mutable(GetArenaForAllocation()); } -inline std::string* request::release_requestbuf() { - // @@protoc_insertion_point(field_release:cl_rcon.request.requestBuf) - if (!_internal_has_requestbuf()) { +inline std::string* request::release_requestmsg() { + // @@protoc_insertion_point(field_release:cl_rcon.request.requestMsg) + if (!_internal_has_requestmsg()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.requestbuf_.Release(); + auto* p = _impl_.requestmsg_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.requestbuf_.IsDefault()) { - _impl_.requestbuf_.Set("", GetArenaForAllocation()); + if (_impl_.requestmsg_.IsDefault()) { + _impl_.requestmsg_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void request::set_allocated_requestbuf(std::string* requestbuf) { - if (requestbuf != nullptr) { +inline void request::set_allocated_requestmsg(std::string* requestmsg) { + if (requestmsg != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.requestbuf_.SetAllocated(requestbuf, GetArenaForAllocation()); + _impl_.requestmsg_.SetAllocated(requestmsg, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.requestbuf_.IsDefault()) { - _impl_.requestbuf_.Set("", GetArenaForAllocation()); + if (_impl_.requestmsg_.IsDefault()) { + _impl_.requestmsg_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestBuf) + // @@protoc_insertion_point(field_set_allocated:cl_rcon.request.requestMsg) } -// optional string requestVal = 4; +// optional string requestVal = 5; inline bool request::_internal_has_requestval() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; diff --git a/r5dev/protoc/sv_rcon.pb.cc b/r5dev/protoc/sv_rcon.pb.cc index 147717db..f983f6ce 100644 --- a/r5dev/protoc/sv_rcon.pb.cc +++ b/r5dev/protoc/sv_rcon.pb.cc @@ -22,9 +22,10 @@ PROTOBUF_CONSTEXPR response::response( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} , /*decltype(_impl_._cached_size_)*/{} - , /*decltype(_impl_.responsebuf_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.responsemsg_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.responseval_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} - , /*decltype(_impl_.responseid_)*/0 + , /*decltype(_impl_.messageid_)*/0 + , /*decltype(_impl_.messagetype_)*/0 , /*decltype(_impl_.responsetype_)*/0} {} struct responseDefaultTypeInternal { PROTOBUF_CONSTEXPR responseDefaultTypeInternal() @@ -110,13 +111,16 @@ bool response_t_Parse( class response::_Internal { public: using HasBits = decltype(std::declval()._impl_._has_bits_); - static void set_has_responseid(HasBits* has_bits) { + static void set_has_messageid(HasBits* has_bits) { (*has_bits)[0] |= 4u; } - static void set_has_responsetype(HasBits* has_bits) { + static void set_has_messagetype(HasBits* has_bits) { (*has_bits)[0] |= 8u; } - static void set_has_responsebuf(HasBits* has_bits) { + static void set_has_responsetype(HasBits* has_bits) { + (*has_bits)[0] |= 16u; + } + static void set_has_responsemsg(HasBits* has_bits) { (*has_bits)[0] |= 1u; } static void set_has_responseval(HasBits* has_bits) { @@ -136,18 +140,19 @@ response::response(const response& from) new (&_impl_) Impl_{ decltype(_impl_._has_bits_){from._impl_._has_bits_} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.responsebuf_){} + , decltype(_impl_.responsemsg_){} , decltype(_impl_.responseval_){} - , decltype(_impl_.responseid_){} + , decltype(_impl_.messageid_){} + , decltype(_impl_.messagetype_){} , decltype(_impl_.responsetype_){}}; _internal_metadata_.MergeFrom(from._internal_metadata_); - _impl_.responsebuf_.InitDefault(); + _impl_.responsemsg_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.responsebuf_.Set("", GetArenaForAllocation()); + _impl_.responsemsg_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (from._internal_has_responsebuf()) { - _this->_impl_.responsebuf_.Set(from._internal_responsebuf(), + if (from._internal_has_responsemsg()) { + _this->_impl_.responsemsg_.Set(from._internal_responsemsg(), _this->GetArenaForAllocation()); } _impl_.responseval_.InitDefault(); @@ -158,9 +163,9 @@ response::response(const response& from) _this->_impl_.responseval_.Set(from._internal_responseval(), _this->GetArenaForAllocation()); } - ::memcpy(&_impl_.responseid_, &from._impl_.responseid_, + ::memcpy(&_impl_.messageid_, &from._impl_.messageid_, static_cast(reinterpret_cast(&_impl_.responsetype_) - - reinterpret_cast(&_impl_.responseid_)) + sizeof(_impl_.responsetype_)); + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.responsetype_)); // @@protoc_insertion_point(copy_constructor:sv_rcon.response) } @@ -171,14 +176,15 @@ inline void response::SharedCtor( new (&_impl_) Impl_{ decltype(_impl_._has_bits_){} , /*decltype(_impl_._cached_size_)*/{} - , decltype(_impl_.responsebuf_){} + , decltype(_impl_.responsemsg_){} , decltype(_impl_.responseval_){} - , decltype(_impl_.responseid_){0} + , decltype(_impl_.messageid_){0} + , decltype(_impl_.messagetype_){0} , decltype(_impl_.responsetype_){0} }; - _impl_.responsebuf_.InitDefault(); + _impl_.responsemsg_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - _impl_.responsebuf_.Set("", GetArenaForAllocation()); + _impl_.responsemsg_.Set("", GetArenaForAllocation()); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING _impl_.responseval_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -197,7 +203,7 @@ response::~response() { inline void response::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); - _impl_.responsebuf_.Destroy(); + _impl_.responsemsg_.Destroy(); _impl_.responseval_.Destroy(); } @@ -214,16 +220,16 @@ void response::Clear() { cached_has_bits = _impl_._has_bits_[0]; if (cached_has_bits & 0x00000003u) { if (cached_has_bits & 0x00000001u) { - _impl_.responsebuf_.ClearNonDefaultToEmpty(); + _impl_.responsemsg_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000002u) { _impl_.responseval_.ClearNonDefaultToEmpty(); } } - if (cached_has_bits & 0x0000000cu) { - ::memset(&_impl_.responseid_, 0, static_cast( + if (cached_has_bits & 0x0000001cu) { + ::memset(&_impl_.messageid_, 0, static_cast( reinterpret_cast(&_impl_.responsetype_) - - reinterpret_cast(&_impl_.responseid_)) + sizeof(_impl_.responsetype_)); + reinterpret_cast(&_impl_.messageid_)) + sizeof(_impl_.responsetype_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear(); @@ -236,37 +242,46 @@ const char* response::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional int32 responseID = 1; + // optional int32 messageID = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _Internal::set_has_responseid(&has_bits); - _impl_.responseid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _Internal::set_has_messageid(&has_bits); + _impl_.messageid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // optional .sv_rcon.response_t responseType = 2; + // optional int32 messageType = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _Internal::set_has_messagetype(&has_bits); + _impl_.messagetype_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // optional .sv_rcon.response_t responseType = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); _internal_set_responsetype(static_cast<::sv_rcon::response_t>(val)); } else goto handle_unusual; continue; - // optional string responseBuf = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - auto str = _internal_mutable_responsebuf(); + // optional string responseMsg = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_responsemsg(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); CHK_(::_pbi::VerifyUTF8(str, nullptr)); } else goto handle_unusual; continue; - // optional string responseVal = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + // optional string responseVal = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 42)) { auto str = _internal_mutable_responseval(); ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); CHK_(ptr); @@ -304,37 +319,43 @@ uint8_t* response::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - // optional int32 responseID = 1; - if (_internal_has_responseid()) { + // optional int32 messageID = 1; + if (_internal_has_messageid()) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_responseid(), target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_messageid(), target); } - // optional .sv_rcon.response_t responseType = 2; + // optional int32 messageType = 2; + if (_internal_has_messagetype()) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_messagetype(), target); + } + + // optional .sv_rcon.response_t responseType = 3; if (_internal_has_responsetype()) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( - 2, this->_internal_responsetype(), target); + 3, this->_internal_responsetype(), target); } - // optional string responseBuf = 3; - if (_internal_has_responsebuf()) { + // optional string responseMsg = 4; + if (_internal_has_responsemsg()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( - this->_internal_responsebuf().data(), static_cast(this->_internal_responsebuf().length()), + this->_internal_responsemsg().data(), static_cast(this->_internal_responsemsg().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, - "sv_rcon.response.responseBuf"); + "sv_rcon.response.responseMsg"); target = stream->WriteStringMaybeAliased( - 3, this->_internal_responsebuf(), target); + 4, this->_internal_responsemsg(), target); } - // optional string responseVal = 4; + // optional string responseVal = 5; if (_internal_has_responseval()) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( this->_internal_responseval().data(), static_cast(this->_internal_responseval().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "sv_rcon.response.responseVal"); target = stream->WriteStringMaybeAliased( - 4, this->_internal_responseval(), target); + 5, this->_internal_responseval(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { @@ -354,28 +375,33 @@ size_t response::ByteSizeLong() const { (void) cached_has_bits; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { - // optional string responseBuf = 3; + if (cached_has_bits & 0x0000001fu) { + // optional string responseMsg = 4; if (cached_has_bits & 0x00000001u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( - this->_internal_responsebuf()); + this->_internal_responsemsg()); } - // optional string responseVal = 4; + // optional string responseVal = 5; if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_responseval()); } - // optional int32 responseID = 1; + // optional int32 messageID = 1; if (cached_has_bits & 0x00000004u) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_responseid()); + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messageid()); } - // optional .sv_rcon.response_t responseType = 2; + // optional int32 messageType = 2; if (cached_has_bits & 0x00000008u) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_messagetype()); + } + + // optional .sv_rcon.response_t responseType = 3; + if (cached_has_bits & 0x00000010u) { total_size += 1 + ::_pbi::WireFormatLite::EnumSize(this->_internal_responsetype()); } @@ -403,17 +429,20 @@ void response::MergeFrom(const response& from) { (void) cached_has_bits; cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x0000000fu) { + if (cached_has_bits & 0x0000001fu) { if (cached_has_bits & 0x00000001u) { - _this->_internal_set_responsebuf(from._internal_responsebuf()); + _this->_internal_set_responsemsg(from._internal_responsemsg()); } if (cached_has_bits & 0x00000002u) { _this->_internal_set_responseval(from._internal_responseval()); } if (cached_has_bits & 0x00000004u) { - _this->_impl_.responseid_ = from._impl_.responseid_; + _this->_impl_.messageid_ = from._impl_.messageid_; } if (cached_has_bits & 0x00000008u) { + _this->_impl_.messagetype_ = from._impl_.messagetype_; + } + if (cached_has_bits & 0x00000010u) { _this->_impl_.responsetype_ = from._impl_.responsetype_; } _this->_impl_._has_bits_[0] |= cached_has_bits; @@ -439,8 +468,8 @@ void response::InternalSwap(response* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( - &_impl_.responsebuf_, lhs_arena, - &other->_impl_.responsebuf_, rhs_arena + &_impl_.responsemsg_, lhs_arena, + &other->_impl_.responsemsg_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &_impl_.responseval_, lhs_arena, @@ -449,9 +478,9 @@ void response::InternalSwap(response* other) { ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(response, _impl_.responsetype_) + sizeof(response::_impl_.responsetype_) - - PROTOBUF_FIELD_OFFSET(response, _impl_.responseid_)>( - reinterpret_cast(&_impl_.responseid_), - reinterpret_cast(&other->_impl_.responseid_)); + - PROTOBUF_FIELD_OFFSET(response, _impl_.messageid_)>( + reinterpret_cast(&_impl_.messageid_), + reinterpret_cast(&other->_impl_.messageid_)); } std::string response::GetTypeName() const { diff --git a/r5dev/protoc/sv_rcon.pb.h b/r5dev/protoc/sv_rcon.pb.h index b8bcd8c6..06e6e38d 100644 --- a/r5dev/protoc/sv_rcon.pb.h +++ b/r5dev/protoc/sv_rcon.pb.h @@ -182,30 +182,31 @@ class response final : // accessors ------------------------------------------------------- enum : int { - kResponseBufFieldNumber = 3, - kResponseValFieldNumber = 4, - kResponseIDFieldNumber = 1, - kResponseTypeFieldNumber = 2, + kResponseMsgFieldNumber = 4, + kResponseValFieldNumber = 5, + kMessageIDFieldNumber = 1, + kMessageTypeFieldNumber = 2, + kResponseTypeFieldNumber = 3, }; - // optional string responseBuf = 3; - bool has_responsebuf() const; + // optional string responseMsg = 4; + bool has_responsemsg() const; private: - bool _internal_has_responsebuf() const; + bool _internal_has_responsemsg() const; public: - void clear_responsebuf(); - const std::string& responsebuf() const; + void clear_responsemsg(); + const std::string& responsemsg() const; template - void set_responsebuf(ArgT0&& arg0, ArgT... args); - std::string* mutable_responsebuf(); - PROTOBUF_NODISCARD std::string* release_responsebuf(); - void set_allocated_responsebuf(std::string* responsebuf); + void set_responsemsg(ArgT0&& arg0, ArgT... args); + std::string* mutable_responsemsg(); + PROTOBUF_NODISCARD std::string* release_responsemsg(); + void set_allocated_responsemsg(std::string* responsemsg); private: - const std::string& _internal_responsebuf() const; - inline PROTOBUF_ALWAYS_INLINE void _internal_set_responsebuf(const std::string& value); - std::string* _internal_mutable_responsebuf(); + const std::string& _internal_responsemsg() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_responsemsg(const std::string& value); + std::string* _internal_mutable_responsemsg(); public: - // optional string responseVal = 4; + // optional string responseVal = 5; bool has_responseval() const; private: bool _internal_has_responseval() const; @@ -223,20 +224,33 @@ class response final : std::string* _internal_mutable_responseval(); public: - // optional int32 responseID = 1; - bool has_responseid() const; + // optional int32 messageID = 1; + bool has_messageid() const; private: - bool _internal_has_responseid() const; + bool _internal_has_messageid() const; public: - void clear_responseid(); - int32_t responseid() const; - void set_responseid(int32_t value); + void clear_messageid(); + int32_t messageid() const; + void set_messageid(int32_t value); private: - int32_t _internal_responseid() const; - void _internal_set_responseid(int32_t value); + int32_t _internal_messageid() const; + void _internal_set_messageid(int32_t value); public: - // optional .sv_rcon.response_t responseType = 2; + // optional int32 messageType = 2; + bool has_messagetype() const; + private: + bool _internal_has_messagetype() const; + public: + void clear_messagetype(); + int32_t messagetype() const; + void set_messagetype(int32_t value); + private: + int32_t _internal_messagetype() const; + void _internal_set_messagetype(int32_t value); + public: + + // optional .sv_rcon.response_t responseType = 3; bool has_responsetype() const; private: bool _internal_has_responsetype() const; @@ -259,9 +273,10 @@ class response final : struct Impl_ { ::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; - ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responsebuf_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responsemsg_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr responseval_; - int32_t responseid_; + int32_t messageid_; + int32_t messagetype_; int responsetype_; }; union { Impl_ _impl_; }; @@ -278,45 +293,73 @@ class response final : #endif // __GNUC__ // response -// optional int32 responseID = 1; -inline bool response::_internal_has_responseid() const { +// optional int32 messageID = 1; +inline bool response::_internal_has_messageid() const { bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool response::has_responseid() const { - return _internal_has_responseid(); +inline bool response::has_messageid() const { + return _internal_has_messageid(); } -inline void response::clear_responseid() { - _impl_.responseid_ = 0; +inline void response::clear_messageid() { + _impl_.messageid_ = 0; _impl_._has_bits_[0] &= ~0x00000004u; } -inline int32_t response::_internal_responseid() const { - return _impl_.responseid_; +inline int32_t response::_internal_messageid() const { + return _impl_.messageid_; } -inline int32_t response::responseid() const { - // @@protoc_insertion_point(field_get:sv_rcon.response.responseID) - return _internal_responseid(); +inline int32_t response::messageid() const { + // @@protoc_insertion_point(field_get:sv_rcon.response.messageID) + return _internal_messageid(); } -inline void response::_internal_set_responseid(int32_t value) { +inline void response::_internal_set_messageid(int32_t value) { _impl_._has_bits_[0] |= 0x00000004u; - _impl_.responseid_ = value; + _impl_.messageid_ = value; } -inline void response::set_responseid(int32_t value) { - _internal_set_responseid(value); - // @@protoc_insertion_point(field_set:sv_rcon.response.responseID) +inline void response::set_messageid(int32_t value) { + _internal_set_messageid(value); + // @@protoc_insertion_point(field_set:sv_rcon.response.messageID) } -// optional .sv_rcon.response_t responseType = 2; -inline bool response::_internal_has_responsetype() const { +// optional int32 messageType = 2; +inline bool response::_internal_has_messagetype() const { bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; return value; } +inline bool response::has_messagetype() const { + return _internal_has_messagetype(); +} +inline void response::clear_messagetype() { + _impl_.messagetype_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline int32_t response::_internal_messagetype() const { + return _impl_.messagetype_; +} +inline int32_t response::messagetype() const { + // @@protoc_insertion_point(field_get:sv_rcon.response.messageType) + return _internal_messagetype(); +} +inline void response::_internal_set_messagetype(int32_t value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.messagetype_ = value; +} +inline void response::set_messagetype(int32_t value) { + _internal_set_messagetype(value); + // @@protoc_insertion_point(field_set:sv_rcon.response.messageType) +} + +// optional .sv_rcon.response_t responseType = 3; +inline bool response::_internal_has_responsetype() const { + bool value = (_impl_._has_bits_[0] & 0x00000010u) != 0; + return value; +} inline bool response::has_responsetype() const { return _internal_has_responsetype(); } inline void response::clear_responsetype() { _impl_.responsetype_ = 0; - _impl_._has_bits_[0] &= ~0x00000008u; + _impl_._has_bits_[0] &= ~0x00000010u; } inline ::sv_rcon::response_t response::_internal_responsetype() const { return static_cast< ::sv_rcon::response_t >(_impl_.responsetype_); @@ -326,7 +369,7 @@ inline ::sv_rcon::response_t response::responsetype() const { return _internal_responsetype(); } inline void response::_internal_set_responsetype(::sv_rcon::response_t value) { - _impl_._has_bits_[0] |= 0x00000008u; + _impl_._has_bits_[0] |= 0x00000010u; _impl_.responsetype_ = value; } inline void response::set_responsetype(::sv_rcon::response_t value) { @@ -334,75 +377,75 @@ inline void response::set_responsetype(::sv_rcon::response_t value) { // @@protoc_insertion_point(field_set:sv_rcon.response.responseType) } -// optional string responseBuf = 3; -inline bool response::_internal_has_responsebuf() const { +// optional string responseMsg = 4; +inline bool response::_internal_has_responsemsg() const { bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool response::has_responsebuf() const { - return _internal_has_responsebuf(); +inline bool response::has_responsemsg() const { + return _internal_has_responsemsg(); } -inline void response::clear_responsebuf() { - _impl_.responsebuf_.ClearToEmpty(); +inline void response::clear_responsemsg() { + _impl_.responsemsg_.ClearToEmpty(); _impl_._has_bits_[0] &= ~0x00000001u; } -inline const std::string& response::responsebuf() const { - // @@protoc_insertion_point(field_get:sv_rcon.response.responseBuf) - return _internal_responsebuf(); +inline const std::string& response::responsemsg() const { + // @@protoc_insertion_point(field_get:sv_rcon.response.responseMsg) + return _internal_responsemsg(); } template inline PROTOBUF_ALWAYS_INLINE -void response::set_responsebuf(ArgT0&& arg0, ArgT... args) { +void response::set_responsemsg(ArgT0&& arg0, ArgT... args) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.responsebuf_.Set(static_cast(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:sv_rcon.response.responseBuf) + _impl_.responsemsg_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:sv_rcon.response.responseMsg) } -inline std::string* response::mutable_responsebuf() { - std::string* _s = _internal_mutable_responsebuf(); - // @@protoc_insertion_point(field_mutable:sv_rcon.response.responseBuf) +inline std::string* response::mutable_responsemsg() { + std::string* _s = _internal_mutable_responsemsg(); + // @@protoc_insertion_point(field_mutable:sv_rcon.response.responseMsg) return _s; } -inline const std::string& response::_internal_responsebuf() const { - return _impl_.responsebuf_.Get(); +inline const std::string& response::_internal_responsemsg() const { + return _impl_.responsemsg_.Get(); } -inline void response::_internal_set_responsebuf(const std::string& value) { +inline void response::_internal_set_responsemsg(const std::string& value) { _impl_._has_bits_[0] |= 0x00000001u; - _impl_.responsebuf_.Set(value, GetArenaForAllocation()); + _impl_.responsemsg_.Set(value, GetArenaForAllocation()); } -inline std::string* response::_internal_mutable_responsebuf() { +inline std::string* response::_internal_mutable_responsemsg() { _impl_._has_bits_[0] |= 0x00000001u; - return _impl_.responsebuf_.Mutable(GetArenaForAllocation()); + return _impl_.responsemsg_.Mutable(GetArenaForAllocation()); } -inline std::string* response::release_responsebuf() { - // @@protoc_insertion_point(field_release:sv_rcon.response.responseBuf) - if (!_internal_has_responsebuf()) { +inline std::string* response::release_responsemsg() { + // @@protoc_insertion_point(field_release:sv_rcon.response.responseMsg) + if (!_internal_has_responsemsg()) { return nullptr; } _impl_._has_bits_[0] &= ~0x00000001u; - auto* p = _impl_.responsebuf_.Release(); + auto* p = _impl_.responsemsg_.Release(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.responsebuf_.IsDefault()) { - _impl_.responsebuf_.Set("", GetArenaForAllocation()); + if (_impl_.responsemsg_.IsDefault()) { + _impl_.responsemsg_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING return p; } -inline void response::set_allocated_responsebuf(std::string* responsebuf) { - if (responsebuf != nullptr) { +inline void response::set_allocated_responsemsg(std::string* responsemsg) { + if (responsemsg != nullptr) { _impl_._has_bits_[0] |= 0x00000001u; } else { _impl_._has_bits_[0] &= ~0x00000001u; } - _impl_.responsebuf_.SetAllocated(responsebuf, GetArenaForAllocation()); + _impl_.responsemsg_.SetAllocated(responsemsg, GetArenaForAllocation()); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING - if (_impl_.responsebuf_.IsDefault()) { - _impl_.responsebuf_.Set("", GetArenaForAllocation()); + if (_impl_.responsemsg_.IsDefault()) { + _impl_.responsemsg_.Set("", GetArenaForAllocation()); } #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING - // @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseBuf) + // @@protoc_insertion_point(field_set_allocated:sv_rcon.response.responseMsg) } -// optional string responseVal = 4; +// optional string responseVal = 5; inline bool response::_internal_has_responseval() const { bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; return value; diff --git a/r5dev/sdklauncher/basepanel.cpp b/r5dev/sdklauncher/basepanel.cpp index c12c7ea1..8b8a68df 100644 --- a/r5dev/sdklauncher/basepanel.cpp +++ b/r5dev/sdklauncher/basepanel.cpp @@ -946,7 +946,7 @@ void CSurface::AppendConsoleParameters(string& svParameters) AppendParameterInternal(svParameters, "-wconsole"); if (this->m_ColorConsoleToggle->Checked()) - AppendParameterInternal(svParameters, "-ansiclr"); + AppendParameterInternal(svParameters, "-ansicolor"); if (!String::IsNullOrEmpty(this->m_PlaylistFileTextBox->Text())) AppendParameterInternal(svParameters, "-playlistfile", diff --git a/r5dev/tier0/dbg.cpp b/r5dev/tier0/dbg.cpp index f825c121..4d6cfbb0 100644 --- a/r5dev/tier0/dbg.cpp +++ b/r5dev/tier0/dbg.cpp @@ -10,6 +10,7 @@ #include "core/logdef.h" #include "tier0/dbg.h" #include "tier0/platform.h" +#ifndef NETCONSOLE #include "tier0/threadtools.h" #include "tier0/commandline.h" #ifndef DEDICATED @@ -24,6 +25,7 @@ #include "xbox/xbox_console.h" #endif #include "squirrel/sqstdaux.h" +#endif // !NETCONSOLE std::mutex g_LogMutex; //----------------------------------------------------------------------------- @@ -31,7 +33,7 @@ std::mutex g_LogMutex; //----------------------------------------------------------------------------- bool HushAsserts() { -#ifdef DBGFLAG_ASSERT +#if defined (DBGFLAG_ASSERT) && !defined (NETCONSOLE) static bool s_bHushAsserts = !!CommandLine()->FindParm("-hushasserts"); return s_bHushAsserts; #else @@ -91,7 +93,7 @@ PLATFORM_INTERFACE void AssertValidWStringPtr(const wchar_t* ptr, int maxchar/* #endif } -#ifndef DEDICATED +#if !defined (DEDICATED) && !defined (NETCONSOLE) ImVec4 CheckForWarnings(LogType_t type, eDLL_T context, const ImVec4& defaultCol) { ImVec4 color = defaultCol; @@ -143,7 +145,7 @@ ImVec4 GetColorForContext(LogType_t type, eDLL_T context) return CheckForWarnings(type, context, ImVec4(0.81f, 0.81f, 0.81f, 1.00f)); } } -#endif // !DEDICATED +#endif // !DEDICATED && !NETCONSOLE const char* GetContextNameByIndex(eDLL_T context, const bool ansiColor = false) { @@ -199,15 +201,13 @@ const char* GetContextNameByIndex(eDLL_T context, const bool ansiColor = false) // *pszFormat - // args - // exitCode - +// *pszUptimeOverride - //----------------------------------------------------------------------------- -void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char* pszLogger, - const char* pszFormat, va_list args, const UINT exitCode /*= NO_ERROR*/) +void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, + const char* pszLogger, const char* pszFormat, va_list args, + const UINT exitCode /*= NO_ERROR*/, const char* pszUptimeOverride /*= nullptr*/) { - static std::shared_ptr iconsole = spdlog::get("game_console"); - static std::shared_ptr wconsole = spdlog::get("win_console"); - std::shared_ptr ntlogger = spdlog::get(pszLogger); // <-- Obtain by 'pszLogger'. - - const char* pszUpTime = Plat_GetProcessUpTime(); + const char* pszUpTime = pszUptimeOverride ? pszUptimeOverride : Plat_GetProcessUpTime(); string message = g_bSpdLog_PostInit ? pszUpTime : ""; const bool bToConsole = (logLevel >= LogLevel_t::LEVEL_CONSOLE); @@ -216,14 +216,16 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char const char* pszContext = GetContextNameByIndex(context, bUseColor); message.append(pszContext); -#ifndef DEDICATED +#if !defined (DEDICATED) && !defined (NETCONSOLE) ImVec4 overlayColor = GetColorForContext(logType, context); eDLL_T overlayContext = context; -#endif // !DEDICATED +#endif // !DEDICATED && !NETCONSOLE bool bSquirrel = false; +#if !defined (NETCONSOLE) bool bWarning = false; bool bError = false; +#endif // !NETCONSOLE //------------------------------------------------------------------------- // Setup logger and context @@ -231,23 +233,24 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char switch (logType) { case LogType_t::LOG_WARNING: -#ifndef DEDICATED +#if !defined (DEDICATED) && !defined (NETCONSOLE) overlayContext = eDLL_T::SYSTEM_WARNING; -#endif // !DEDICATED +#endif // !DEDICATED && !NETCONSOLE if (bUseColor) { message.append(g_svYellowF); } break; case LogType_t::LOG_ERROR: -#ifndef DEDICATED +#if !defined (DEDICATED) && !defined (NETCONSOLE) overlayContext = eDLL_T::SYSTEM_ERROR; -#endif // !DEDICATED +#endif // !DEDICATED && !NETCONSOLE if (bUseColor) { message.append(g_svRedF); } break; +#ifndef NETCONSOLE case LogType_t::SQ_INFO: bSquirrel = true; break; @@ -259,6 +262,7 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char bSquirrel = true; bWarning = true; break; +#endif // !NETCONSOLE } //------------------------------------------------------------------------- @@ -269,11 +273,13 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char const string formatted = FormatV(pszFormat, argsCopy); va_end(argsCopy); +#ifndef NETCONSOLE if (bUseColor && bSquirrel) { if (bWarning && g_bSQAuxError) { - if (formatted.find("SCRIPT ERROR:") != string::npos || formatted.find(" -> ") != string::npos) + if (formatted.find("SCRIPT ERROR:") != string::npos || + formatted.find(" -> ") != string::npos) { bError = true; } @@ -302,21 +308,16 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char message.append(g_svYellowF); } } - +#endif // !NETCONSOLE message.append(formatted); - if (!bSquirrel && message.back() != '\n') - { - message.append("\n"); - } - - std::lock_guard lock(g_LogMutex); //------------------------------------------------------------------------- // Emit to all interfaces //------------------------------------------------------------------------- + std::lock_guard lock(g_LogMutex); if (bToConsole) { - wconsole->debug(message); + g_TermLogger->debug(message); if (bUseColor) { @@ -325,16 +326,20 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char } } +#ifndef NETCONSOLE // Output is always logged to the file. + std::shared_ptr ntlogger = spdlog::get(pszLogger); // <-- Obtain by 'pszLogger'. + assert(ntlogger.get() != nullptr); ntlogger->debug(message); if (bToConsole) { #ifndef CLIENT_DLL - RCONServer()->Send(message, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast(context)); + RCONServer()->Send(formatted, pszUpTime, sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, + static_cast(context), static_cast(logType)); #endif // !CLIENT_DLL #ifndef DEDICATED - iconsole->debug(message); + g_ImGuiLogger->debug(message); if (g_bSpdLog_PostInit) { @@ -353,9 +358,12 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char g_LogStream.clear(); #endif // !DEDICATED +#endif // !NETCONSOLE + if (exitCode) // Terminate the process if an exit code was passed. { - if (MessageBoxA(NULL, Format("%s- %s", pszUpTime, message.c_str()).c_str(), "SDK Error", MB_ICONERROR | MB_OK)) + if (MessageBoxA(NULL, Format("%s- %s", pszUpTime, message.c_str()).c_str(), + "SDK Error", MB_ICONERROR | MB_OK)) { TerminateProcess(GetCurrentProcess(), exitCode); } @@ -399,12 +407,12 @@ void DevMsg(eDLL_T context, const char* fmt, ...) // Input : context - // *fmt - ... - //----------------------------------------------------------------------------- -void NetMsg(eDLL_T context, const char* fmt, ...) +void NetMsg(LogType_t logType, eDLL_T context, const char* uptime, const char* fmt, ...) { #ifndef DEDICATED va_list args; va_start(args, fmt); - CoreMsgV(LogType_t::LOG_NET, LogLevel_t::LEVEL_NOTIFY, context, "netconsole", fmt, args); + CoreMsgV(logType, LogLevel_t::LEVEL_NOTIFY, context, "netconsole", fmt, args, NO_ERROR, uptime); va_end(args); #endif // !DEDICATED } diff --git a/r5dev/tier0/dbg.h b/r5dev/tier0/dbg.h index 68d29bc3..26e80437 100644 --- a/r5dev/tier0/dbg.h +++ b/r5dev/tier0/dbg.h @@ -109,13 +109,13 @@ extern std::mutex g_LogMutex; ////////////////////////////////////////////////////////////////////////// void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const char* pszLogger, - const char* pszFormat, va_list args, const UINT exitCode = NO_ERROR); + const char* pszFormat, va_list args, const UINT exitCode = NO_ERROR, const char* pszUptimeOverride = nullptr); void CoreMsg(LogType_t logType, LogLevel_t logLevel, eDLL_T context, const UINT exitCode, const char* pszLogger, const char* pszFormat, ...); // These functions do not return. PLATFORM_INTERFACE void DevMsg(eDLL_T context, const char* fmt, ...) FMTFUNCTION(2, 3); -PLATFORM_INTERFACE void NetMsg(eDLL_T context, const char* fmt, ...) FMTFUNCTION(2, 3); +PLATFORM_INTERFACE void NetMsg(LogType_t logType, eDLL_T context, const char* uptime, const char* fmt, ...) FMTFUNCTION(4, 5); PLATFORM_INTERFACE void Warning(eDLL_T context, const char* fmt, ...) FMTFUNCTION(2, 3); PLATFORM_INTERFACE void Error(eDLL_T context, const UINT code, const char* fmt, ...) FMTFUNCTION(3, 4); diff --git a/r5dev/vproj/netconsole.vcxproj b/r5dev/vproj/netconsole.vcxproj index 39bd664d..e2ce88e1 100644 --- a/r5dev/vproj/netconsole.vcxproj +++ b/r5dev/vproj/netconsole.vcxproj @@ -27,6 +27,7 @@ + Create Create @@ -37,8 +38,8 @@ - + NotUsing NotUsing @@ -56,10 +57,13 @@ NotUsing + + + @@ -70,6 +74,7 @@ + 16.0 @@ -207,7 +212,7 @@ Console true - User32.lib;Bcrypt.lib;Ws2_32.lib;libprotobuf_x86.lib;libspdlog_x86.lib;%(AdditionalDependencies) + User32.lib;Bcrypt.lib;Ws2_32.lib;libspdlog_x86.lib;libprotobuf_x86.lib;%(AdditionalDependencies) $(SolutionDir)lib\win32\$(Configuration)\ @@ -242,7 +247,7 @@ true true true - User32.lib;Bcrypt.lib;Ws2_32.lib;libprotobuf_x86.lib;libspdlog_x86.lib;%(AdditionalDependencies) + User32.lib;Bcrypt.lib;Ws2_32.lib;libspdlog_x86.lib;libprotobuf_x86.lib;%(AdditionalDependencies) $(SolutionDir)lib\win32\$(Configuration)\ true @@ -283,7 +288,7 @@ true - User32.lib;Bcrypt.lib;Ws2_32.lib;libprotobuf_x86.lib;libspdlog_x86.lib;%(AdditionalDependencies) + User32.lib;Bcrypt.lib;Ws2_32.lib;libspdlog_x86.lib;libprotobuf_x86.lib;%(AdditionalDependencies) $(SolutionDir)lib\win32\$(Configuration)\ diff --git a/r5dev/vproj/netconsole.vcxproj.filters b/r5dev/vproj/netconsole.vcxproj.filters index 723627d7..acb1eeb9 100644 --- a/r5dev/vproj/netconsole.vcxproj.filters +++ b/r5dev/vproj/netconsole.vcxproj.filters @@ -29,6 +29,9 @@ {7064c656-b1c1-4940-be0a-eeb46b78a221} + + {2f5f6e2d-440a-472b-807d-aebfdf13dfe2} + @@ -55,12 +58,21 @@ sdk\public - - core - sdk\tier1 + + sdk\tier0 + + + core + + + windows + + + core + @@ -93,5 +105,11 @@ sdk\tier1 + + windows + + + core + \ No newline at end of file diff --git a/r5dev/windows/console.cpp b/r5dev/windows/console.cpp index b52048ce..52deb520 100644 --- a/r5dev/windows/console.cpp +++ b/r5dev/windows/console.cpp @@ -5,6 +5,7 @@ //=============================================================================// #include "core/stdafx.h" +#ifndef NETCONSOLE #include "core/init.h" #include "core/logdef.h" #include "tier0/frametask.h" @@ -12,9 +13,9 @@ #ifndef DEDICATED #include "windows/id3dx.h" #endif // !DEDICATED +#endif // !NETCONSOLE #include "windows/system.h" #include "windows/console.h" -#include "common/opcodes.h" static std::string s_ConsoleInput; @@ -71,6 +72,7 @@ void FlashConsoleBackground(int nFlashCount, int nFlashInterval, COLORREF color) //----------------------------------------------------------------------------- void Console_Init() { +#ifndef NETCONSOLE /////////////////////////////////////////////////////////////////////////// // Create the console window if (AllocConsole() == FALSE) @@ -89,20 +91,21 @@ void Console_Init() freopen_s(&fDummy, "CONOUT$", "w", stderr); //-- Create a worker thread to process console commands - DWORD dwMode = NULL; DWORD dwThreadId = NULL; DWORD __stdcall ProcessConsoleWorker(LPVOID); HANDLE hThread = CreateThread(NULL, 0, ProcessConsoleWorker, NULL, 0, &dwThreadId); - - HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); - HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE); if (hThread) { CloseHandle(hThread); } +#endif // !NETCONSOLE - if (g_svCmdLine.find("-ansiclr") != string::npos) + HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); + HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD dwMode = NULL; + + if (g_svCmdLine.find("-ansicolor") != string::npos) { GetConsoleMode(hOutput, &dwMode); dwMode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; @@ -111,13 +114,16 @@ void Console_Init() { // Warn the user if 'VirtualTerminalLevel' could not be set on users environment. MessageBoxA(NULL, "Failed to set console mode 'VirtualTerminalLevel'.\n" - "Please omit the '-ansiclr' parameter and restart \nthe game if output logging appears distorted.", "SDK Warning", MB_ICONEXCLAMATION | MB_OK); + "Please omit the '-ansicolor' parameter and restart \nthe program if output logging appears distorted.", "SDK Warning", MB_ICONEXCLAMATION | MB_OK); } SetConsoleBackgroundColor(0x00000000); AnsiColors_Init(); } + +#ifndef NETCONSOLE SetConsoleCtrlHandler(ConsoleHandlerRoutine, true); +#endif // !NETCONSOLE } //----------------------------------------------------------------------------- @@ -134,10 +140,10 @@ void Console_Shutdown() } } +#ifndef NETCONSOLE //############################################################################# -// WORKER THREAD +// CONSOLE WORKER //############################################################################# - DWORD __stdcall ProcessConsoleWorker(LPVOID) { while (true) @@ -156,3 +162,4 @@ DWORD __stdcall ProcessConsoleWorker(LPVOID) } return NULL; } +#endif // !NETCONSOLE