General cleanup and improvements

This commit is contained in:
Kawe Mazidjatari 2022-06-12 17:41:26 +02:00
parent 6451aaba2b
commit 162e709190
7 changed files with 37 additions and 47 deletions

@ -29,13 +29,9 @@ inline auto v_sq_pushroottable = p_sq_pushroottable.RCast<SQRESULT(*)(HSQUIRRELV
inline CMemory p_sq_pushbool;
inline auto v_sq_pushbool = p_sq_pushbool.RCast<void (*)(HSQUIRRELVM v, SQBool b)>();
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
inline CMemory p_sq_pushstring;
inline auto v_sq_pushstring = p_sq_pushstring.RCast<void (*)(HSQUIRRELVM v, const SQChar* string, SQInteger len)>();
#elif defined (GAMEDLL_S3)
inline CMemory p_sq_pushstring;
inline auto v_sq_pushstring = p_sq_pushstring.RCast<void (*)(HSQUIRRELVM v, const SQChar* string, SQInteger len)>();
#endif
inline CMemory p_sq_pushinteger;
inline auto v_sq_pushinteger = p_sq_pushinteger.RCast<void (*)(HSQUIRRELVM v, SQInteger val)>();
@ -53,13 +49,10 @@ inline auto v_sq_newslot = p_sq_newslot.RCast<SQRESULT(*)(HSQUIRRELVM v, SQInteg
inline CMemory p_sq_arrayappend;
inline auto v_sq_arrayappend = p_sq_arrayappend.RCast<SQRESULT(*)(HSQUIRRELVM v, SQInteger idx)>();
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
inline CMemory p_sq_pushstructure;
inline auto v_sq_pushstructure = p_sq_pushstructure.RCast<SQRESULT(*)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2)>();
#elif defined (GAMEDLL_S3)
inline CMemory p_sq_pushstructure;
inline auto v_sq_pushstructure = p_sq_pushstructure.RCast<SQRESULT(*)(HSQUIRRELVM v, const SQChar* name, const SQChar* member, const SQChar* codeclass1, const SQChar* codeclass2)>();
#endif
inline CMemory p_sq_compilebuffer;
inline auto v_sq_compilebuffer = p_sq_compilebuffer.RCast<SQRESULT(*)(HSQUIRRELVM v, SQBufState* bufferstate, const SQChar* buffer, SQInteger level)>();

@ -22,7 +22,7 @@ enum class SQCONTEXT : SQInteger
NONE
};
const static std::string SQVM_TYPE_T[4] =
const static string SQVM_TYPE_T[4] =
{
"SERVER",
"CLIENT",
@ -30,7 +30,7 @@ const static std::string SQVM_TYPE_T[4] =
"NONE"
};
const static std::string SQVM_LOG_T[4] =
const static string SQVM_LOG_T[4] =
{
"Script(S):",
"Script(C):",
@ -38,7 +38,7 @@ const static std::string SQVM_LOG_T[4] =
"Script(X):"
};
const static std::string SQVM_ANSI_LOG_T[4] =
const static string SQVM_ANSI_LOG_T[4] =
{
"\033[38;2;151;149;187mScript(S):",
"\033[38;2;151;149;163mScript(C):",
@ -46,7 +46,7 @@ const static std::string SQVM_ANSI_LOG_T[4] =
"\033[38;2;151;149;163mScript(X):"
};
const static std::string SQVM_WARNING_ANSI_LOG_T[4] =
const static string SQVM_WARNING_ANSI_LOG_T[4] =
{
"\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",
@ -54,7 +54,7 @@ const static std::string SQVM_WARNING_ANSI_LOG_T[4] =
"\033[38;2;151;149;163mScript(X):\033[38;2;255;255;000m"
};
const static std::string SQVM_ERROR_ANSI_LOG_T[4] =
const static 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",

@ -108,8 +108,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
svOut.append(szBuf);
svOut = std::regex_replace(svOut, rxAnsiExp, "");
char szNewLine = svOut.back();
if (szNewLine != '\n')
if (svOut.back() != '\n')
{
svOut.append("\n");
}
@ -126,8 +125,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
svAnsiOut = sANSI_DLL_T[static_cast<int>(context)];
svAnsiOut.append(szBuf);
char szNewLine = svAnsiOut.back();
if (szNewLine != '\n')
if (svAnsiOut.back() != '\n')
{
svAnsiOut.append("\n");
}
@ -216,8 +214,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
svOut.append(szBuf);
svOut = std::regex_replace(svOut, rxAnsiExp, "");
char szNewLine = svOut.back();
if (szNewLine != '\n')
if (svOut.back() != '\n')
{
svOut.append("\n");
}
@ -235,8 +232,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
svAnsiOut.append(g_svYellowF);
svAnsiOut.append(szBuf);
char szNewLine = svAnsiOut.back();
if (szNewLine != '\n')
if (svAnsiOut.back() != '\n')
{
svAnsiOut.append("\n");
}
@ -293,8 +289,7 @@ void Error(eDLL_T context, const char* fmt, ...)
svOut.append(szBuf);
svOut = std::regex_replace(svOut, rxAnsiExp, "");
char szNewLine = svOut.back();
if (szNewLine != '\n')
if (svOut.back() != '\n')
{
svOut.append("\n");
}
@ -312,8 +307,7 @@ void Error(eDLL_T context, const char* fmt, ...)
svAnsiOut.append(g_svRedF);
svAnsiOut.append(szBuf);
char szNewLine = svAnsiOut.back();
if (szNewLine != '\n')
if (svAnsiOut.back() != '\n')
{
svAnsiOut.append("\n");
}

@ -219,23 +219,22 @@ void ConVar::PurgeHostNames(void) const
{
const char* pszHostNames[] =
{
"pin_telemetry_hostname",
"assetdownloads_hostname",
"users_hostname",
"persistence_hostname",
"speechtotexttoken_hostname",
"communities_hostname",
"persistenceDef_hostname",
"party_hostname",
"speechtotext_hostname",
"serverReports_hostname",
"subscription_hostname",
"steamlink_hostname",
"staticfile_hostname",
"matchmaking_hostname",
"skill_hostname",
"party_hostname",
"persistence_hostname",
"persistenceDef_hostname",
"pin_telemetry_hostname",
"publication_hostname",
"stats_hostname"
"serverReports_hostname",
"skill_hostname",
"speechtotext_hostname",
"staticfile_hostname",
"stats_hostname",
"steamlink_hostname",
"subscription_hostname",
"users_hostname"
};
for (int i = 0; i < (&pszHostNames)[1] - pszHostNames; i++)
@ -720,7 +719,7 @@ void ConVar::ChangeStringValue(const char* pszTempVal, float flOldValue)
if (pszTempVal)
{
int len = strlen(pszTempVal) + 1;
size_t len = strlen(pszTempVal) + 1;
if (len > m_Value.m_iStringLength)
{
@ -732,7 +731,11 @@ void ConVar::ChangeStringValue(const char* pszTempVal, float flOldValue)
m_Value.m_pszString = new char[len];
m_Value.m_iStringLength = len;
}
else if (!m_Value.m_pszString)
{
m_Value.m_pszString = new char[len];
m_Value.m_iStringLength = len;
}
memcpy(const_cast<char*>(m_Value.m_pszString), pszTempVal, len);
}
else

@ -147,7 +147,7 @@ public:
struct CVValue_t
{
const char* m_pszString;
int64_t m_iStringLength;
size_t m_iStringLength;
float m_fValue;
int m_nValue;
};

@ -47,7 +47,7 @@ void CLogSystem::Update(void)
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CLogSystem::AddLog(LogType_t type, std::string svMessage)
void CLogSystem::AddLog(LogType_t type, string svMessage)
{
if (svMessage.length() > 0)
{

@ -22,13 +22,13 @@ enum class LogType_t : int
struct LogMsg_t
{
LogMsg_t(const std::string svMessage, const int nTicks, const LogType_t type)
LogMsg_t(const string svMessage, const int nTicks, const LogType_t type)
{
this->m_svMessage = svMessage;
this->m_nTicks = nTicks;
this->m_type = type;
}
std::string m_svMessage = "";
string m_svMessage = "";
int m_nTicks = 1024;
LogType_t m_type = LogType_t::NONE;
};
@ -37,7 +37,7 @@ class CLogSystem
{
public:
void Update(void);
void AddLog(LogType_t type, std::string svText);
void AddLog(LogType_t type, string svText);
void DrawLog(void);
void DrawHostStats(void) const;
void DrawSimStats(void) const;