diff --git a/r5dev/engine/cl_rcon.cpp b/r5dev/engine/cl_rcon.cpp index 1c191750..a106407e 100644 --- a/r5dev/engine/cl_rcon.cpp +++ b/r5dev/engine/cl_rcon.cpp @@ -12,6 +12,7 @@ #include "protoc/cl_rcon.pb.h" #include "engine/cl_rcon.h" #include "engine/sys_utils.h" +#include "squirrel/sqvm.h" #include "common/igameserverdata.h" //----------------------------------------------------------------------------- @@ -211,15 +212,61 @@ void CRConClient::ProcessBuffer(const char* pszIn, int nRecvLen) const //----------------------------------------------------------------------------- void CRConClient::ProcessMessage(const sv_rcon::response& sv_response) const { + std::string svOut = sv_response.responsebuf(); + switch (sv_response.responsetype()) { case sv_rcon::response_t::SERVERDATA_RESPONSE_AUTH: + { + StringReplace(svOut, sDLL_T[7], ""); + DevMsg(eDLL_T::NETCON, "%s", svOut.c_str()); + break; + } case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG: { - std::string svOut = sv_response.responsebuf(); - - // TODO: Manipulate string.. - DevMsg(eDLL_T::NONE, "%s", svOut.c_str()); + // !TODO: Network the enum for this. + if (strstr(svOut.c_str(), SQVM_LOG_T[0].c_str())) + { + HSQVM_PrintFunc(nullptr, const_cast("%s"), svOut.c_str()); + } + else // This has to be done for RUI color logging. + { + if (strstr(svOut.c_str(), sDLL_T[0].c_str())) + { + StringReplace(svOut, sDLL_T[0], ""); + DevMsg(eDLL_T::SERVER, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[1].c_str())) + { + StringReplace(svOut, sDLL_T[1], ""); + DevMsg(eDLL_T::CLIENT, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[2].c_str())) + { + StringReplace(svOut, sDLL_T[2], ""); + DevMsg(eDLL_T::UI, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[3].c_str())) + { + StringReplace(svOut, sDLL_T[3], ""); + DevMsg(eDLL_T::ENGINE, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[4].c_str())) + { + StringReplace(svOut, sDLL_T[4], ""); + DevMsg(eDLL_T::FS, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[5].c_str())) + { + StringReplace(svOut, sDLL_T[5], ""); + DevMsg(eDLL_T::RTECH, "%s", svOut.c_str()); + } + if (strstr(svOut.c_str(), sDLL_T[6].c_str())) + { + StringReplace(svOut, sDLL_T[6], ""); + DevMsg(eDLL_T::MS, "%s", svOut.c_str()); + } + } break; } default: @@ -291,5 +338,5 @@ bool CRConClient::IsConnected(void) const { return m_bConnEstablished; } - -CRConClient* g_pRConClient = new CRConClient(); \ No newline at end of file +/////////////////////////////////////////////////////////////////////////////// +CRConClient* g_pRConClient = new CRConClient(); diff --git a/r5dev/engine/sys_utils.cpp b/r5dev/engine/sys_utils.cpp index a0a22f57..ca7c64d8 100644 --- a/r5dev/engine/sys_utils.cpp +++ b/r5dev/engine/sys_utils.cpp @@ -82,7 +82,7 @@ void DevMsg(eDLL_T idx, const char* fmt, ...) va_end(args); }///////////////////////////// - svOut = sDLL_T[(int)idx].c_str(); + svOut = sDLL_T[static_cast(idx)].c_str(); svOut.append(szBuf); svOut = std::regex_replace(svOut, rxAnsiExp, ""); @@ -101,7 +101,7 @@ void DevMsg(eDLL_T idx, const char* fmt, ...) } else { - svAnsiOut = sANSI_DLL_T[(int)idx].c_str(); + svAnsiOut = sANSI_DLL_T[static_cast(idx)].c_str(); svAnsiOut.append(szBuf); char szNewLine = svAnsiOut.back(); @@ -121,7 +121,10 @@ void DevMsg(eDLL_T idx, const char* fmt, ...) iconsole->info(svOut); std::string s = g_spd_sys_w_oss.str(); - g_pLogSystem.AddLog((LogType_t)eDLL_T::ENGINE, s); + int nLog = static_cast(idx) + 3; // RUI log enum is shifted by 3 for scripts. + LogType_t tLog = static_cast(nLog); + + g_pLogSystem.AddLog(tLog, s); g_pIConsole->m_ivConLog.push_back(Strdup(s.c_str())); g_spd_sys_w_oss.str(""); diff --git a/r5dev/engine/sys_utils.h b/r5dev/engine/sys_utils.h index c402e46d..4d9070e9 100644 --- a/r5dev/engine/sys_utils.h +++ b/r5dev/engine/sys_utils.h @@ -33,7 +33,8 @@ enum class eDLL_T : int FS = 4, // File System RTECH = 5, // RTech API MS = 6, // Material System - NONE = 7 + NETCON = 7, // Net Console + NONE = 8 }; const std::string sDLL_T[8] = @@ -45,6 +46,7 @@ const std::string sDLL_T[8] = "Native(F):", "Native(R):", "Native(M):", + "Netcon(X):" "" }; diff --git a/r5dev/mathlib/color.h b/r5dev/mathlib/color.h index aab0221e..8470b361 100644 --- a/r5dev/mathlib/color.h +++ b/r5dev/mathlib/color.h @@ -1,5 +1,30 @@ #pragma once +struct color24 +{ + byte r, g, b; +}; + +typedef struct color32_s +{ + bool operator!=(const struct color32_s& other) const + { + return r != other.r || g != other.g || b != other.b || a != other.a; + } + inline unsigned* asInt(void) { return reinterpret_cast(this); } + inline const unsigned* asInt(void) const { return reinterpret_cast(this); } + inline void Copy(const color32_s& rhs) + { + *asInt() = *rhs.asInt(); + } + + byte r, g, b, a; +} color32; + +//----------------------------------------------------------------------------- +// Purpose: Basic handler for an rgb set of colors +// This class is fully inline +//----------------------------------------------------------------------------- class Color { public: @@ -10,5 +35,83 @@ public: _color[2] = (unsigned char)b; _color[3] = (unsigned char)a; } + void SetColor(int _r, int _g, int _b, int _a = 0) + { + _color[0] = (unsigned char)_r; + _color[1] = (unsigned char)_g; + _color[2] = (unsigned char)_b; + _color[3] = (unsigned char)_a; + } + void GetColor(int& _r, int& _g, int& _b, int& _a) const + { + _r = _color[0]; + _g = _color[1]; + _b = _color[2]; + _a = _color[3]; + } + int GetValue(int index) const + { + return _color[index]; + } + void SetRawColor(int color32) + { + *((int*)this) = color32; + } + int GetRawColor(void) const + { + return *((int*)this); + } + + inline int r() const { return _color[0]; } + inline int g() const { return _color[1]; } + inline int b() const { return _color[2]; } + inline int a() const { return _color[3]; } + + unsigned char& operator[](int index) + { + return _color[index]; + } + + const unsigned char& operator[](int index) const + { + return _color[index]; + } + + bool operator == (const Color& rhs) const + { + return (*((int*)this) == *((int*)&rhs)); + } + + bool operator != (const Color& rhs) const + { + return !(operator==(rhs)); + } + + Color& operator=(const Color& rhs) + { + SetRawColor(rhs.GetRawColor()); + return *this; + } + + Color& operator=(const color32& rhs) + { + _color[0] = rhs.r; + _color[1] = rhs.g; + _color[2] = rhs.b; + _color[3] = rhs.a; + return *this; + } + + color32 ToColor32(void) const + { + color32 newColor{}; + newColor.r = _color[0]; + newColor.g = _color[1]; + newColor.b = _color[2]; + newColor.a = _color[3]; + return newColor; + } + +private: unsigned char _color[4]; }; diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index 74c9eedc..1ee4ac80 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -23,12 +23,32 @@ //--------------------------------------------------------------------------------- void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...) { + static int vmIdx{}; + // We use the sqvm pointer as index for SDK usage as the function prototype has to match assembly. + switch (reinterpret_cast(sqvm)) + { + case 0: + vmIdx = 0; + break; + case 1: + vmIdx = 1; + break; + case 2: + vmIdx = 2; + break; + case 3: + vmIdx = 3; + break; + default: #ifdef GAMEDLL_S3 - int vmIdx = *(int*)((std::uintptr_t)sqvm + 0x18); + vmIdx = *reinterpret_cast(reinterpret_cast(sqvm) + 0x18); #else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3. - static int vmIdx = 3; + vmIdx = 3; #endif + break; + } static char buf[1024] = {}; + static std::regex rxAnsiExp("\\\033\\[.*?m"); static std::shared_ptr iconsole = spdlog::get("game_console"); static std::shared_ptr wconsole = spdlog::get("win_console"); @@ -71,6 +91,7 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...) } #ifndef DEDICATED + vmStr = std::regex_replace(vmStr, rxAnsiExp, ""); iconsole->debug(vmStr); if (sq_showvmoutput->GetInt() > 2) @@ -78,7 +99,7 @@ void* HSQVM_PrintFunc(void* sqvm, char* fmt, ...) std::string s = g_spd_sys_w_oss.str(); g_pIConsole->m_ivConLog.push_back(Strdup(s.c_str())); - g_pLogSystem.AddLog((LogType_t)vmIdx, s); + g_pLogSystem.AddLog(static_cast(vmIdx), s); g_spd_sys_w_oss.str(""); g_spd_sys_w_oss.clear(); @@ -149,7 +170,7 @@ void* HSQVM_WarningFunc(void* sqvm, int a2, int a3, int* nStringSize, void** ppS if (sq_showvmwarning->GetInt() > 2) { - g_pLogSystem.AddLog((LogType_t)vmIdx, s); + g_pLogSystem.AddLog(LogType_t::WARNING_C, s); g_pIConsole->m_ivConLog.push_back(Strdup(s.c_str())); } #endif // !DEDICATED diff --git a/r5dev/tier0/IConVar.cpp b/r5dev/tier0/IConVar.cpp index 9b9f24cb..fdf75118 100644 --- a/r5dev/tier0/IConVar.cpp +++ b/r5dev/tier0/IConVar.cpp @@ -45,60 +45,72 @@ ConVar::~ConVar(void) //----------------------------------------------------------------------------- // Purpose: register ConVar //----------------------------------------------------------------------------- -void ConVar::Init(void) +void ConVar::Init(void) const { //------------------------------------------------------------------------- // ENGINE | - cm_debug_cmdquery = new ConVar("cm_debug_cmdquery", "0", FCVAR_DEVELOPMENTONLY, "Prints the flags of each ConVar/ConCommand query to the console ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); - cm_return_false_cmdquery_all = new ConVar("cm_return_false_cmdquery_all", "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr); + cm_debug_cmdquery = new ConVar("cm_debug_cmdquery" , "0", FCVAR_DEVELOPMENTONLY, "Prints the flags of each ConVar/ConCommand query to the console ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); + cm_return_false_cmdquery_all = new ConVar("cm_return_false_cmdquery_all" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr); cm_return_false_cmdquery_cheats = new ConVar("cm_return_false_cmdquery_cheats", "0", FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED, "Returns false on all FCVAR_DEVELOPMENTONLY and FCVAR_CHEAT ConVar/ConCommand queries ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr); - r_debug_overlay_nodecay = new ConVar("r_debug_overlay_nodecay", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr); + r_debug_overlay_nodecay = new ConVar("r_debug_overlay_nodecay" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT , "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr); // TODO: RconPasswordChanged_f rcon_address = new ConVar("rcon_address", "::", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access address.", false, 0.f, false, 0.f, nullptr, nullptr); - rcon_password = new ConVar("rcon_password", "", FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon is disabled if empty).", false, 0.f, false, 0.f, nullptr, nullptr); + rcon_password = new ConVar("rcon_password", "" , FCVAR_SERVER_CANNOT_QUERY | FCVAR_DONTRECORD | FCVAR_RELEASE, "Remote server access password (rcon is disabled if empty).", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // SERVER | - sv_showconnecting = new ConVar("sv_showconnecting", "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_pylonvisibility = new ConVar("sv_pylonvisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon Master Server, 0 = Not visible, 1 = Visible, 2 = Hidden BUG BUG: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_showconnecting = new ConVar("sv_showconnecting" , "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_pylonvisibility = new ConVar("sv_pylonvisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon Master Server, 0 = Not visible, 1 = Visible, 2 = Hidden !TODO: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr); #ifdef DEDICATED - sv_rcon_debug = new ConVar("sv_rcon_debug", "0", FCVAR_RELEASE, "Show rcon debug information ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); - sv_rcon_banpenalty = new ConVar("sv_rcon_banpenalty", "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_debug = new ConVar("sv_rcon_debug" , "0" , FCVAR_RELEASE, "Show rcon debug information ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_banpenalty = new ConVar("sv_rcon_banpenalty" , "10", FCVAR_RELEASE, "Number of minutes to ban users who fail rcon authentication.", false, 0.f, false, 0.f, nullptr, nullptr); sv_rcon_maxfailures = new ConVar("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times a user can fail rcon authentication before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_rcon_maxignores = new ConVar("sv_rcon_maxignores", "15", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); - sv_rcon_maxsockets = new ConVar("sv_rcon_maxsockets", "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_maxignores = new ConVar("sv_rcon_maxignores" , "15", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr); + sv_rcon_maxsockets = new ConVar("sv_rcon_maxsockets" , "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets.", false, 0.f, false, 0.f, nullptr, nullptr); sv_rcon_whitelist_address = new ConVar("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentications. Example: '::ffff:127.0.0.1'.", false, 0.f, false, 0.f, nullptr, nullptr); #endif // DEDICATED //------------------------------------------------------------------------- // CLIENT | #ifndef DEDICATED - cl_drawconsoleoverlay = new ConVar("cl_drawconsoleoverlay", "0", FCVAR_DEVELOPMENTONLY, "Draw the console overlay at the top of the screen.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_consoleoverlay_lines = new ConVar("cl_consoleoverlay_lines", "3", FCVAR_DEVELOPMENTONLY, "Number of lines of console output to draw.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_drawconsoleoverlay = new ConVar("cl_drawconsoleoverlay" , "0" , FCVAR_DEVELOPMENTONLY, "Draw the console overlay at the top of the screen.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_consoleoverlay_lines = new ConVar("cl_consoleoverlay_lines" , "3" , FCVAR_DEVELOPMENTONLY, "Number of lines of console output to draw.", false, 0.f, false, 0.f, nullptr, nullptr); cl_consoleoverlay_offset_x = new ConVar("cl_consoleoverlay_offset_x", "10", FCVAR_DEVELOPMENTONLY, "X offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr); cl_consoleoverlay_offset_y = new ConVar("cl_consoleoverlay_offset_y", "10", FCVAR_DEVELOPMENTONLY, "Y offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr); - cl_consoleoverlay_native_clr = new ConVar("cl_consoleoverlay_native_clr", "255 255 255 255", FCVAR_DEVELOPMENTONLY, "Native RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); - cl_consoleoverlay_server_clr = new ConVar("cl_consoleoverlay_server_clr", "190 183 240 255", FCVAR_DEVELOPMENTONLY, "Server script VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); - cl_consoleoverlay_client_clr = new ConVar("cl_consoleoverlay_client_clr", "117 116 139 255", FCVAR_DEVELOPMENTONLY, "Client script VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); - cl_consoleoverlay_ui_clr = new ConVar("cl_consoleoverlay_ui_clr", "197 160 177 255", FCVAR_DEVELOPMENTONLY, "UI script VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_script_server_clr = new ConVar("cl_conoverlay_script_server_clr", "130 120 245 255", FCVAR_DEVELOPMENTONLY, "Script SERVER VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_script_client_clr = new ConVar("cl_conoverlay_script_client_clr", "117 116 139 255", FCVAR_DEVELOPMENTONLY, "Script CLIENT VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_script_ui_clr = new ConVar("cl_conoverlay_script_ui_clr ", "200 110 110 255", FCVAR_DEVELOPMENTONLY, "Script UI VM RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); - cl_showsimstats = new ConVar("cl_showsimstats", "0", FCVAR_DEVELOPMENTONLY, "Shows the tick counter for the server/client simulation and the render frame.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_conoverlay_native_server_clr = new ConVar("cl_conoverlay_native_server_clr", "020 050 248 255", FCVAR_DEVELOPMENTONLY, "Native SERVER RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_client_clr = new ConVar("cl_conoverlay_native_client_clr", "070 070 070 255", FCVAR_DEVELOPMENTONLY, "Native CLIENT RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_ui_clr = new ConVar("cl_conoverlay_native_ui_clr" , "200 060 060 255", FCVAR_DEVELOPMENTONLY, "Native UI RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_engine_clr = new ConVar("cl_conoverlay_native_engine_clr", "255 255 255 255", FCVAR_DEVELOPMENTONLY, "Native engine RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_fs_clr = new ConVar("cl_conoverlay_native_fs_clr" , "000 100 225 255", FCVAR_DEVELOPMENTONLY, "Native filesystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_rtech_clr = new ConVar("cl_conoverlay_native_rtech_clr" , "025 100 100 255", FCVAR_DEVELOPMENTONLY, "Native rtech RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_native_ms_clr = new ConVar("cl_conoverlay_native_ms_clr" , "200 020 180 255", FCVAR_DEVELOPMENTONLY, "Native materialsystem RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + + cl_conoverlay_netcon_clr = new ConVar("cl_conoverlay_netcon_clr" , "255 255 255 255", FCVAR_DEVELOPMENTONLY, "Net console RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + + cl_conoverlay_warning_clr = new ConVar("cl_conoverlay_warning_clr" , "180 180 020 255", FCVAR_DEVELOPMENTONLY, "Warning RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + cl_conoverlay_error_clr = new ConVar("cl_conoverlay_error_clr" , "225 050 050 255", FCVAR_DEVELOPMENTONLY, "Error RUI console overlay log color.", false, 1.f, false, 50.f, nullptr, nullptr); + + cl_showsimstats = new ConVar("cl_showsimstats" , "0" , FCVAR_DEVELOPMENTONLY, "Shows the tick counter for the server/client simulation and the render frame.", false, 0.f, false, 0.f, nullptr, nullptr); cl_simstats_offset_x = new ConVar("cl_simstats_offset_x", "1250", FCVAR_DEVELOPMENTONLY, "X offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_simstats_offset_y = new ConVar("cl_simstats_offset_y", "885", FCVAR_DEVELOPMENTONLY, "Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_simstats_offset_y = new ConVar("cl_simstats_offset_y", "885" , FCVAR_DEVELOPMENTONLY, "Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_showgpustats = new ConVar("cl_showgpustats", "0", FCVAR_DEVELOPMENTONLY, "Texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_showgpustats = new ConVar("cl_showgpustats" , "0" , FCVAR_DEVELOPMENTONLY, "Texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); cl_gpustats_offset_x = new ConVar("cl_gpustats_offset_x", "1250", FCVAR_DEVELOPMENTONLY, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); - cl_gpustats_offset_y = new ConVar("cl_gpustats_offset_y", "900", FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_gpustats_offset_y = new ConVar("cl_gpustats_offset_y", "900" , FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); con_max_size_logvector = new ConVar("con_max_size_logvector", "1000", FCVAR_DEVELOPMENTONLY, "Maximum number of logs in the console until cleanup starts.", false, 0.f, false, 0.f, nullptr, nullptr); - con_suggestion_limit = new ConVar("con_suggestion_limit", "120", FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", false, 0.f, false, 0.f, nullptr, nullptr); - con_suggestion_helptext = new ConVar("con_suggestion_helptext", "0", FCVAR_DEVELOPMENTONLY, "Show ConVar help text in autocomplete window. Disabled by default to keep window less populated.", false, 0.f, false, 0.f, nullptr, nullptr); + con_suggestion_limit = new ConVar("con_suggestion_limit" , "120" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", false, 0.f, false, 0.f, nullptr, nullptr); + con_suggestion_helptext = new ConVar("con_suggestion_helptext", "0" , FCVAR_DEVELOPMENTONLY, "Show ConVar help text in autocomplete window. Disabled by default to keep window less populated.", false, 0.f, false, 0.f, nullptr, nullptr); #endif // !DEDICATED //------------------------------------------------------------------------- // FILESYSTEM | - fs_warning_level_sdk = new ConVar("fs_warning_level_sdk", "0", FCVAR_DEVELOPMENTONLY, "Set the SDK filesystem warning level.", false, 0.f, false, 0.f, nullptr, nullptr); - fs_show_warning_output = new ConVar("fs_show_warning_output", "0", FCVAR_DEVELOPMENTONLY, "Logs the filesystem warnings to the console, filtered by 'fs_warning_level_native' ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); + fs_warning_level_sdk = new ConVar("fs_warning_level_sdk" , "0", FCVAR_DEVELOPMENTONLY, "Set the SDK filesystem warning level.", false, 0.f, false, 0.f, nullptr, nullptr); + fs_show_warning_output = new ConVar("fs_show_warning_output" , "0", FCVAR_DEVELOPMENTONLY, "Logs the filesystem warnings to the console, filtered by 'fs_warning_level_native' ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); fs_packedstore_entryblock_stats = new ConVar("fs_packedstore_entryblock_stats", "0", FCVAR_DEVELOPMENTONLY, "If set to 1, prints the stats of each file entry in the VPK during decompression ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // MATERIALSYSTEM | @@ -107,15 +119,15 @@ void ConVar::Init(void) #endif // !DEDICATED //------------------------------------------------------------------------- // SQUIRREL | - sq_showrsonloading = new ConVar("sq_showrsonloading", "0", FCVAR_DEVELOPMENTONLY, "Logs all 'rson' files loaded by the SQVM ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); + sq_showrsonloading = new ConVar("sq_showrsonloading" , "0", FCVAR_DEVELOPMENTONLY, "Logs all 'rson' files loaded by the SQVM ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); sq_showscriptloading = new ConVar("sq_showscriptloading", "0", FCVAR_DEVELOPMENTONLY, "Logs all scripts loaded by the SQVM to be pre-compiled ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); - sq_showvmoutput = new ConVar("sq_showvmoutput", "0", FCVAR_DEVELOPMENTONLY, "Prints the VM output to the console. 1 = Log to file. 2 = 1 + log to console. 3 = 1 + 2 + log to overhead console. 4 = only log to overhead console.", false, 0.f, false, 0.f, nullptr, nullptr); - sq_showvmwarning = new ConVar("sq_showvmwarning", "0", FCVAR_DEVELOPMENTONLY, "Prints the VM warning output to the console. 1 = Log to file. 2 = 1 + log to console.", false, 0.f, false, 0.f, nullptr, nullptr); + sq_showvmoutput = new ConVar("sq_showvmoutput" , "0", FCVAR_DEVELOPMENTONLY, "Prints the VM output to the console. 1 = Log to file. 2 = 1 + log to console. 3 = 1 + 2 + log to overhead console. 4 = only log to overhead console.", false, 0.f, false, 0.f, nullptr, nullptr); + sq_showvmwarning = new ConVar("sq_showvmwarning" , "0", FCVAR_DEVELOPMENTONLY, "Prints the VM warning output to the console. 1 = Log to file. 2 = 1 + log to console.", false, 0.f, false, 0.f, nullptr, nullptr); //------------------------------------------------------------------------- // NETCHANNEL | - net_userandomkey = new ConVar("net_userandomkey", "1", FCVAR_RELEASE, "If set to 1, the netchannel generates and sets a random base64 netkey.", false, 0.f, false, 0.f, nullptr, nullptr); - r5net_matchmaking_hostname = new ConVar("r5net_matchmaking_hostname", "r5a-comp-sv.herokuapp.com", FCVAR_RELEASE, "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr); - r5net_show_debug = new ConVar("r5net_show_debug", "1", FCVAR_DEVELOPMENTONLY, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr); + net_userandomkey = new ConVar("net_userandomkey" , "1" , FCVAR_RELEASE , "If set to 1, the netchannel generates and sets a random base64 netkey.", false, 0.f, false, 0.f, nullptr, nullptr); + r5net_matchmaking_hostname = new ConVar("r5net_matchmaking_hostname", "r5a-comp-sv.herokuapp.com", FCVAR_RELEASE , "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr); + r5net_show_debug = new ConVar("r5net_show_debug" , "1" , FCVAR_DEVELOPMENTONLY, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr); } //----------------------------------------------------------------------------- @@ -400,9 +412,9 @@ void ConVar::SetValue(Color clValue) for (int i = 0; i < 4; i++) { - if (!(clValue._color[i] == 0 && svResult.size() == 0)) + if (!(clValue.GetValue(i) == 0 && svResult.size() == 0)) { - svResult += std::to_string(clValue._color[i]); + svResult += std::to_string(clValue.GetValue(i)); svResult.append(" "); } } diff --git a/r5dev/tier0/IConVar.h b/r5dev/tier0/IConVar.h index 861c38c3..e3e4923e 100644 --- a/r5dev/tier0/IConVar.h +++ b/r5dev/tier0/IConVar.h @@ -88,7 +88,7 @@ public: bool bMin, float fMin, bool bMax, float fMax, void* pCallback, void* unk); ~ConVar(void); - void Init(void); + void Init(void) const; const char* GetBaseName(void) const; const char* GetHelpText(void) const; diff --git a/r5dev/tier0/cvar.cpp b/r5dev/tier0/cvar.cpp index a9ee8608..84f1cd38 100644 --- a/r5dev/tier0/cvar.cpp +++ b/r5dev/tier0/cvar.cpp @@ -32,10 +32,20 @@ ConVar* cl_drawconsoleoverlay = new ConVar(); ConVar* cl_consoleoverlay_lines = new ConVar(); ConVar* cl_consoleoverlay_offset_x = new ConVar(); ConVar* cl_consoleoverlay_offset_y = new ConVar(); -ConVar* cl_consoleoverlay_native_clr = new ConVar(); -ConVar* cl_consoleoverlay_server_clr = new ConVar(); -ConVar* cl_consoleoverlay_client_clr = new ConVar(); -ConVar* cl_consoleoverlay_ui_clr = new ConVar(); + +ConVar* cl_conoverlay_script_server_clr = new ConVar(); +ConVar* cl_conoverlay_script_client_clr = new ConVar(); +ConVar* cl_conoverlay_script_ui_clr = new ConVar(); +ConVar* cl_conoverlay_native_server_clr = new ConVar(); +ConVar* cl_conoverlay_native_client_clr = new ConVar(); +ConVar* cl_conoverlay_native_ui_clr = new ConVar(); +ConVar* cl_conoverlay_native_engine_clr = new ConVar(); +ConVar* cl_conoverlay_native_fs_clr = new ConVar(); +ConVar* cl_conoverlay_native_rtech_clr = new ConVar(); +ConVar* cl_conoverlay_native_ms_clr = new ConVar(); +ConVar* cl_conoverlay_netcon_clr = new ConVar(); +ConVar* cl_conoverlay_warning_clr = new ConVar(); +ConVar* cl_conoverlay_error_clr = new ConVar(); ConVar* cl_showsimstats = new ConVar(); ConVar* cl_simstats_offset_x = new ConVar(); diff --git a/r5dev/tier0/cvar.h b/r5dev/tier0/cvar.h index 5f04e9af..45e4c57c 100644 --- a/r5dev/tier0/cvar.h +++ b/r5dev/tier0/cvar.h @@ -43,10 +43,20 @@ extern ConVar* cl_drawconsoleoverlay; extern ConVar* cl_consoleoverlay_lines; extern ConVar* cl_consoleoverlay_offset_x; extern ConVar* cl_consoleoverlay_offset_y; -extern ConVar* cl_consoleoverlay_native_clr; -extern ConVar* cl_consoleoverlay_server_clr; -extern ConVar* cl_consoleoverlay_client_clr; -extern ConVar* cl_consoleoverlay_ui_clr; + +extern ConVar* cl_conoverlay_script_server_clr; +extern ConVar* cl_conoverlay_script_client_clr; +extern ConVar* cl_conoverlay_script_ui_clr; +extern ConVar* cl_conoverlay_native_server_clr; +extern ConVar* cl_conoverlay_native_client_clr; +extern ConVar* cl_conoverlay_native_ui_clr; +extern ConVar* cl_conoverlay_native_engine_clr; +extern ConVar* cl_conoverlay_native_fs_clr; +extern ConVar* cl_conoverlay_native_rtech_clr; +extern ConVar* cl_conoverlay_native_ms_clr; +extern ConVar* cl_conoverlay_netcon_clr; +extern ConVar* cl_conoverlay_warning_clr; +extern ConVar* cl_conoverlay_error_clr; extern ConVar* cl_showsimstats; extern ConVar* cl_simstats_offset_x; diff --git a/r5dev/vgui/CEngineVGui.cpp b/r5dev/vgui/CEngineVGui.cpp index cfe7ac4b..db9b3771 100644 --- a/r5dev/vgui/CEngineVGui.cpp +++ b/r5dev/vgui/CEngineVGui.cpp @@ -34,7 +34,7 @@ int HCEngineVGui_Paint(void* thisptr, int mode) //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CLogSystem::Update() +void CLogSystem::Update(void) { if (!g_pMatSystemSurface) { @@ -57,18 +57,18 @@ void CLogSystem::Update() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CLogSystem::AddLog(LogType_t type, std::string message) +void CLogSystem::AddLog(LogType_t type, std::string svMessage) { - if (message.length() > 0) + if (svMessage.length() > 0) { - m_vLogs.push_back(Log{ message, 1024, type }); + m_vLogs.push_back(Log{ svMessage, 1024, type }); } } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CLogSystem::DrawLog() +void CLogSystem::DrawLog(void) { if (m_vLogs.empty()) { return; } for (int i = 0; i < m_vLogs.size(); ++i) @@ -84,7 +84,7 @@ void CLogSystem::DrawLog() int x = cl_consoleoverlay_offset_x->GetInt(); Color c = GetLogColorForType(m_vLogs[i].Type); - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, x, y, c._color[0], c._color[1], c._color[2], alpha, m_vLogs[i].Message.c_str()); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, x, y, c.r(), c.g(), c.b(), alpha, m_vLogs[i].Message.c_str()); } else { @@ -104,27 +104,27 @@ void CLogSystem::DrawLog() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CLogSystem::DrawSimStats() +void CLogSystem::DrawSimStats(void) const { static Color c = { 255, 255, 255, 255 }; static const char* szLogbuf[4096]{}; snprintf((char*)szLogbuf, 4096, "Server Frame: (%d) Client Frame: (%d) Render Frame: (%d)\n", *sv_m_nTickCount, *cl_host_tickcount, *render_tickcount); - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_simstats_offset_x->GetInt(), cl_simstats_offset_y->GetInt(), c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_simstats_offset_x->GetInt(), cl_simstats_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CLogSystem::DrawGPUStats() +void CLogSystem::DrawGPUStats(void) const { static Color c = { 255, 255, 255, 255 }; static const char* szLogbuf[4096]{}; snprintf((char*)szLogbuf, 4096, "%8d/%8d/%8dkiB unusable/unfree/total GPU Streaming Texture memory\n", *unusable_streaming_tex_memory / 1024, *unfree_streaming_tex_memory / 1024, *unusable_streaming_tex_memory / 1024); - CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_gpustats_offset_x->GetInt(), cl_gpustats_offset_y->GetInt(), c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf); + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_gpustats_offset_x->GetInt(), cl_gpustats_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } //----------------------------------------------------------------------------- @@ -134,19 +134,35 @@ Color CLogSystem::GetLogColorForType(LogType_t type) { switch (type) { - case LogType_t::NATIVE: - return { cl_consoleoverlay_native_clr->GetColor() }; case LogType_t::SCRIPT_SERVER: - return { cl_consoleoverlay_server_clr->GetColor() }; + return { cl_conoverlay_script_server_clr->GetColor() }; case LogType_t::SCRIPT_CLIENT: - return { cl_consoleoverlay_client_clr->GetColor() }; + return { cl_conoverlay_script_client_clr->GetColor() }; case LogType_t::SCRIPT_UI: - return { cl_consoleoverlay_ui_clr->GetColor() }; + return { cl_conoverlay_script_ui_clr->GetColor() }; + case LogType_t::NATIVE_SERVER: + return { cl_conoverlay_native_server_clr->GetColor() }; + case LogType_t::NATIVE_CLIENT: + return { cl_conoverlay_native_client_clr->GetColor() }; + case LogType_t::NATIVE_UI: + return { cl_conoverlay_native_ui_clr->GetColor() }; + case LogType_t::NATIVE_ENGINE: + return { cl_conoverlay_native_engine_clr->GetColor() }; + case LogType_t::NATIVE_FS: + return { cl_conoverlay_native_fs_clr->GetColor() }; + case LogType_t::NATIVE_RTECH: + return { cl_conoverlay_native_rtech_clr->GetColor() }; + case LogType_t::NATIVE_MS: + return { cl_conoverlay_native_rtech_clr->GetColor() }; + case LogType_t::NETCON_S: + return { cl_conoverlay_netcon_clr->GetColor() }; + case LogType_t::WARNING_C: + return { cl_conoverlay_warning_clr->GetColor() }; + case LogType_t::ERROR_C: + return { cl_conoverlay_error_clr->GetColor() }; default: - return { cl_consoleoverlay_native_clr->GetColor() }; + return { cl_conoverlay_native_engine_clr->GetColor() }; } - - return { cl_consoleoverlay_native_clr->GetColor() }; } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/vgui/CEngineVGui.h b/r5dev/vgui/CEngineVGui.h index 1e48afd6..d435447f 100644 --- a/r5dev/vgui/CEngineVGui.h +++ b/r5dev/vgui/CEngineVGui.h @@ -7,8 +7,17 @@ enum class LogType_t : int SCRIPT_SERVER, SCRIPT_CLIENT, SCRIPT_UI, - SCRIPT_WARNING, - NATIVE + NATIVE_SERVER, + NATIVE_CLIENT, + NATIVE_UI, + NATIVE_ENGINE, + NATIVE_FS, + NATIVE_RTECH, + NATIVE_MS, + NETCON_S, + WARNING_C, + ERROR_C, + NONE }; struct Log @@ -21,17 +30,17 @@ struct Log } std::string Message = ""; int Ticks = 1024; - LogType_t Type = LogType_t::NATIVE; + LogType_t Type = LogType_t::NONE; }; class CLogSystem { public: - void Update(); + void Update(void); void AddLog(LogType_t type, std::string text); - void DrawLog(); - void DrawSimStats(); - void DrawGPUStats(); + void DrawLog(void); + void DrawSimStats(void) const; + void DrawGPUStats(void) const; private: Color GetLogColorForType(LogType_t type);