mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Show script error callstacks and context in colors in the external console
Show colors on console and use color constant to determine color instead of comparing strings in the console render loop. removed 5 string compares which should once again bump the performance quite a bit. The last string compares will be removed soon
This commit is contained in:
parent
e22ec87db7
commit
46134434a9
@ -53,6 +53,7 @@
|
||||
#include "squirrel/sqinit.h"
|
||||
#include "squirrel/sqapi.h"
|
||||
#include "squirrel/sqvm.h"
|
||||
#include "squirrel/sqstdaux.h"
|
||||
#include "studiorender/studiorendercontext.h"
|
||||
#include "rtech/rtech_game.h"
|
||||
#include "rtech/rtech_utils.h"
|
||||
@ -188,6 +189,7 @@ void Systems_Init()
|
||||
|
||||
SQAPI_Attach();
|
||||
SQVM_Attach();
|
||||
SQAUX_Attach();
|
||||
|
||||
RTech_Game_Attach();
|
||||
#ifndef DEDICATED
|
||||
@ -301,6 +303,7 @@ void Systems_Shutdown()
|
||||
#endif // !CLIENT_DLL
|
||||
SQAPI_Detach();
|
||||
SQVM_Detach();
|
||||
SQAUX_Detach();
|
||||
|
||||
RTech_Game_Detach();
|
||||
#ifndef DEDICATED
|
||||
|
@ -799,13 +799,6 @@ void CConsole::ColorLog(void) const
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "[WARNING]")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
||||
if (strncmp(m_ivConLog[i].m_svConLog.c_str(), "# ", 2) == 0) { imColor = ImVec4(1.00f, 0.80f, 0.60f, 1.00f); true; }
|
||||
|
||||
//// Squirrel VM script debug
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "CALLSTACK")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "LOCALS")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "DIAGPRINTS")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "SCRIPT ERROR")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
||||
if (strstr(m_ivConLog[i].m_svConLog.c_str(), "<><>GRX<><>")) { imColor = ImVec4(0.00f, 0.30f, 1.00f, 1.00f); true; }
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, imColor);
|
||||
ImGui::TextWrapped(m_ivConLog[i].m_svConLog.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
|
29
r5dev/squirrel/sqstdaux.cpp
Normal file
29
r5dev/squirrel/sqstdaux.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
//=============================================================================//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "tier0/tslist.h"
|
||||
#include "squirrel/sqvm.h"
|
||||
#include "squirrel/sqstdaux.h"
|
||||
|
||||
bool g_bSQAuxError = false;
|
||||
SQInteger sqstd_aux_printerror(HSQUIRRELVM v)
|
||||
{
|
||||
g_bSQAuxError = true;
|
||||
SQInteger results = v_sqstd_aux_printerror(v);
|
||||
g_bSQAuxError = false;
|
||||
return results;
|
||||
}
|
||||
|
||||
void SQAUX_Attach()
|
||||
{
|
||||
DetourAttach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror);
|
||||
}
|
||||
|
||||
void SQAUX_Detach()
|
||||
{
|
||||
DetourDetach((LPVOID*)&v_sqstd_aux_printerror, &sqstd_aux_printerror);
|
||||
}
|
37
r5dev/squirrel/sqstdaux.h
Normal file
37
r5dev/squirrel/sqstdaux.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
extern bool g_bSQAuxError;
|
||||
|
||||
inline CMemory p_sqstd_aux_printerror;
|
||||
inline auto v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast<SQInteger(*)(HSQUIRRELVM v)>();
|
||||
|
||||
|
||||
void SQAUX_Attach();
|
||||
void SQAUX_Detach();
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class HSqStdAux : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
std::cout << "| FUN: sqstd_aux_printerror : 0x" << std::hex << std::uppercase << p_sqstd_aux_printerror.GetPtr() << std::setw(nPad) << " |" << std::endl;
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
}
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
p_sqstd_aux_printerror = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x55\x56\x57\x41\x54\x41\x55\x41\x57\x48\x81\xEC\x00\x00\x00\x00"), "xxxxxxxxxxxxxx????");
|
||||
v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast<SQInteger(*)(HSQUIRRELVM)>(); /*40 53 55 56 57 41 54 41 55 41 57 48 81 EC ?? ?? ?? ??*/
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
p_sqstd_aux_printerror = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00\xFF\x05\x00\x00\x00\x00"), "xxxxxxxxxxxxxxx????xx????");
|
||||
v_sqstd_aux_printerror = p_sqstd_aux_printerror.RCast<SQInteger(*)(HSQUIRRELVM)>(); /*40 53 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ?? FF 05 ?? ?? ?? ??*/
|
||||
#endif
|
||||
}
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
virtual void Detach(void) const { }
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
REGISTER(HSqStdAux);
|
@ -94,10 +94,10 @@ const static std::string SQVM_LOG_T[4] =
|
||||
|
||||
const static std::string SQVM_WARNING_LOG_T[4] =
|
||||
{
|
||||
"Script(S):Warning:",
|
||||
"Script(C):Warning:",
|
||||
"Script(U):Warning:",
|
||||
"Script(X):Warning:"
|
||||
"Script(S):",
|
||||
"Script(C):",
|
||||
"Script(U):",
|
||||
"Script(X):"
|
||||
};
|
||||
|
||||
const static std::string SQVM_ANSI_LOG_T[4] =
|
||||
@ -110,9 +110,17 @@ const static std::string SQVM_ANSI_LOG_T[4] =
|
||||
|
||||
const static std::string SQVM_WARNING_ANSI_LOG_T[4] =
|
||||
{
|
||||
"\033[38;2;151;149;187mScript(S):\033[38;2;255;255;000mWarning:",
|
||||
"\033[38;2;151;149;163mScript(C):\033[38;2;255;255;000mWarning:",
|
||||
"\033[38;2;151;123;136mScript(U):\033[38;2;255;255;000mWarning:",
|
||||
"\033[38;2;151;149;163mScript(X):\033[38;2;255;255;000mWarning:"
|
||||
"\033[38;2;151;149;187mScript(S):\033[38;2;255;255;000m",
|
||||
"\033[38;2;151;149;163mScript(C):\033[38;2;255;255;000m",
|
||||
"\033[38;2;151;123;136mScript(U):\033[38;2;255;255;000m",
|
||||
"\033[38;2;151;149;163mScript(X):\033[38;2;255;255;000m"
|
||||
};
|
||||
|
||||
const static std::string SQVM_ERROR_ANSI_LOG_T[4] =
|
||||
{
|
||||
"\033[38;2;151;149;187mScript(S):\033[38;2;255;000;000m",
|
||||
"\033[38;2;151;149;163mScript(C):\033[38;2;255;000;000m",
|
||||
"\033[38;2;151;123;136mScript(U):\033[38;2;255;000;000m",
|
||||
"\033[38;2;151;149;163mScript(X):\033[38;2;255;000;000m"
|
||||
};
|
||||
#endif // SQTYPE_H
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "squirrel/sqtype.h"
|
||||
#include "squirrel/sqvm.h"
|
||||
#include "squirrel/sqinit.h"
|
||||
#include "squirrel/sqstdaux.h"
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
// Purpose: prints the output of each VM to the console
|
||||
@ -74,12 +75,12 @@ SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
std::string vmStr = SQVM_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
vmStr.append(buf);
|
||||
|
||||
if (sq_showvmoutput->GetInt() > 0)
|
||||
{
|
||||
if (sq_showvmoutput->GetInt() > 0) {
|
||||
sqlogger->debug(vmStr);
|
||||
}
|
||||
if (sq_showvmoutput->GetInt() > 1)
|
||||
{
|
||||
bool bError = false;
|
||||
if (!g_bSpdLog_UseAnsiClr)
|
||||
{
|
||||
wconsole->debug(vmStr);
|
||||
@ -89,7 +90,21 @@ SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
std::string vmStrAnsi;
|
||||
if (g_bSQAuxError)
|
||||
{
|
||||
if (strstr(buf, "SCRIPT ERROR:") || strstr(buf, " -> "))
|
||||
{
|
||||
bError = true;
|
||||
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
}
|
||||
else {
|
||||
vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
}
|
||||
}
|
||||
else {
|
||||
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
|
||||
}
|
||||
vmStrAnsi.append(buf);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
@ -104,20 +119,32 @@ SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
if (sq_showvmoutput->GetInt() > 2)
|
||||
{
|
||||
ImVec4 color;
|
||||
switch (context)
|
||||
if (g_bSQAuxError)
|
||||
{
|
||||
case SQCONTEXT::SERVER:
|
||||
color = ImVec4(0.59f, 0.58f, 0.73f, 1.00f);
|
||||
break;
|
||||
case SQCONTEXT::CLIENT:
|
||||
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||
break;
|
||||
case SQCONTEXT::UI:
|
||||
color = ImVec4(0.59f, 0.48f, 0.53f, 1.00f);
|
||||
break;
|
||||
default:
|
||||
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||
break;
|
||||
if (bError) {
|
||||
color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
|
||||
}
|
||||
else {
|
||||
color = ImVec4(1.00f, 1.00f, 0.00f, 0.80f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
case SQCONTEXT::SERVER:
|
||||
color = ImVec4(0.59f, 0.58f, 0.73f, 1.00f);
|
||||
break;
|
||||
case SQCONTEXT::CLIENT:
|
||||
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||
break;
|
||||
case SQCONTEXT::UI:
|
||||
color = ImVec4(0.59f, 0.48f, 0.53f, 1.00f);
|
||||
break;
|
||||
default:
|
||||
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str(), color));
|
||||
|
@ -80,6 +80,7 @@
|
||||
<ClCompile Include="..\rtech\stryder\stryder.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqapi.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqinit.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqvm.cpp" />
|
||||
<ClCompile Include="..\thirdparty\imgui\src\imgui_utility.cpp" />
|
||||
<ClCompile Include="..\tier0\commandline.cpp" />
|
||||
@ -212,6 +213,7 @@
|
||||
<ClInclude Include="..\rtech\stryder\stryder.h" />
|
||||
<ClInclude Include="..\squirrel\sqapi.h" />
|
||||
<ClInclude Include="..\squirrel\sqinit.h" />
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h" />
|
||||
<ClInclude Include="..\squirrel\sqtype.h" />
|
||||
<ClInclude Include="..\squirrel\sqvm.h" />
|
||||
<ClInclude Include="..\studiorender\studiorendercontext.h" />
|
||||
|
@ -480,6 +480,9 @@
|
||||
<ClCompile Include="..\game\shared\animation.cpp">
|
||||
<Filter>sdk\game\shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1433,6 +1436,9 @@
|
||||
<ClInclude Include="..\thirdparty\nlohmann\detail\output\binary_writer.hpp">
|
||||
<Filter>thirdparty\nlohmann\detail\output</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -214,6 +214,7 @@
|
||||
<ClInclude Include="..\server\server.h" />
|
||||
<ClInclude Include="..\squirrel\sqapi.h" />
|
||||
<ClInclude Include="..\squirrel\sqinit.h" />
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h" />
|
||||
<ClInclude Include="..\squirrel\sqtype.h" />
|
||||
<ClInclude Include="..\squirrel\sqvm.h" />
|
||||
<ClInclude Include="..\studiorender\studiorendercontext.h" />
|
||||
@ -480,6 +481,7 @@
|
||||
<ClCompile Include="..\server\server.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqapi.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqinit.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqvm.cpp" />
|
||||
<ClCompile Include="..\tier0\commandline.cpp" />
|
||||
<ClCompile Include="..\tier0\cpu.cpp" />
|
||||
|
@ -1062,6 +1062,9 @@
|
||||
<ClInclude Include="..\thirdparty\nlohmann\detail\macro_scope.hpp">
|
||||
<Filter>thirdparty\nlohmann\detail</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
@ -1298,6 +1301,9 @@
|
||||
<ClCompile Include="..\game\shared\animation.cpp">
|
||||
<Filter>sdk\game\shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Dedicated.def" />
|
||||
|
@ -88,6 +88,7 @@
|
||||
<ClCompile Include="..\server\server.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqapi.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqinit.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp" />
|
||||
<ClCompile Include="..\squirrel\sqvm.cpp" />
|
||||
<ClCompile Include="..\thirdparty\imgui\src\imgui_utility.cpp" />
|
||||
<ClCompile Include="..\tier0\commandline.cpp" />
|
||||
@ -232,6 +233,7 @@
|
||||
<ClInclude Include="..\server\server.h" />
|
||||
<ClInclude Include="..\squirrel\sqapi.h" />
|
||||
<ClInclude Include="..\squirrel\sqinit.h" />
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h" />
|
||||
<ClInclude Include="..\squirrel\sqtype.h" />
|
||||
<ClInclude Include="..\squirrel\sqvm.h" />
|
||||
<ClInclude Include="..\studiorender\studiorendercontext.h" />
|
||||
|
@ -510,6 +510,9 @@
|
||||
<ClCompile Include="..\game\shared\animation.cpp">
|
||||
<Filter>sdk\game\shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\squirrel\sqstdaux.cpp">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1496,6 +1499,9 @@
|
||||
<ClInclude Include="..\thirdparty\nlohmann\detail\output\binary_writer.hpp">
|
||||
<Filter>thirdparty\nlohmann\detail\output</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\squirrel\sqstdaux.h">
|
||||
<Filter>sdk\squirrel</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
Loading…
x
Reference in New Issue
Block a user