General cleanup

* Use Cbuf functions for executing commands in ImGui panels.
* Use const qualifiers for all vftable indexes.
This commit is contained in:
Kawe Mazidjatari 2022-08-09 02:35:00 +02:00
parent 0e5724c187
commit 9d06a02614
15 changed files with 71 additions and 71 deletions

View File

@ -37,7 +37,7 @@ public:
void* /* CUserCmd* */ GetUserCmd(int sequenceNumber) // @0x1405BB020 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
{
static int index = 28;
const int index = 28;
return CallVFunc<void*>(index, this, sequenceNumber); /*48 83 EC 28 48 8B 05 ? ? ? ? 48 8D 0D ? ? ? ? 44 8B C2*/
}
};

View File

@ -10,7 +10,7 @@ CEngine* g_pEngine = nullptr;
//-----------------------------------------------------------------------------
bool CEngine::Load(bool dedicated, const char* rootDir)
{
static int index = 1;
const int index = 1;
return CallVFunc<bool>(index, this, dedicated, rootDir);
}
@ -19,7 +19,7 @@ bool CEngine::Load(bool dedicated, const char* rootDir)
//-----------------------------------------------------------------------------
void CEngine::Unload(void)
{
static int index = 2;
const int index = 2;
CallVFunc<void>(index, this);
}
@ -44,7 +44,7 @@ EngineState_t CEngine::GetState(void) const
//-----------------------------------------------------------------------------
void CEngine::Frame(void)
{
static int index = 5;
const int index = 5;
CallVFunc<void>(index, this);
}
@ -61,7 +61,7 @@ float CEngine::GetFrameTime(void) const
//-----------------------------------------------------------------------------
float CEngine::GetPreviousTime(void) // I'm not sure if this is right, should double check.
{
static int index = 7;
const int index = 7;
return CallVFunc<float>(index, this);
}
@ -78,6 +78,6 @@ __m128 __fastcall CEngine::GetCurTime(CEngine *thisPtr) const
//-----------------------------------------------------------------------------
void CEngine::SetQuitting(EngineDllQuitting_t quitDllState)
{
static int index = 9;
const int index = 9;
CallVFunc<void>(index, this, quitDllState);
}

View File

@ -18,7 +18,7 @@ CFileSystem_Stdio* FileSystem()
//-----------------------------------------------------------------------------
void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPathAdd_t addType)
{
static int index = 12;
const int index = 12;
CallVFunc<void>(index, this, pPath, pPathID, addType);
}
@ -31,7 +31,7 @@ void IFileSystem::AddSearchPath(const char* pPath, const char* pPathID, SearchPa
//-----------------------------------------------------------------------------
bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
{
static int index = 13;
const int index = 13;
return CallVFunc<bool>(index, this, pPath, pPathID);
}
@ -43,7 +43,7 @@ bool IFileSystem::RemoveSearchPath(const char* pPath, const char* pPathID)
//-----------------------------------------------------------------------------
bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
{
static int index = 76;
const int index = 76;
return CallVFunc<bool>(index, this, pPath, pResult);
}
@ -54,7 +54,7 @@ bool IFileSystem::ReadFromCache(const char* pPath, void* pResult)
//-----------------------------------------------------------------------------
VPKData_t* IFileSystem::MountVPK(const char* pPath)
{
static int index = 92;
const int index = 92;
return CallVFunc<VPKData_t*>(index, this, pPath);
}

View File

@ -14,7 +14,7 @@
//-----------------------------------------------------------------------------
void CServerGameDLL::GameInit(void)
{
static int index = 1;
const int index = 1;
CallVFunc<void>(index, this);
}
@ -23,7 +23,7 @@ void CServerGameDLL::GameInit(void)
//-----------------------------------------------------------------------------
void CServerGameDLL::PrecompileScriptsJob(void)
{
static int index = 2;
const int index = 2;
CallVFunc<void>(index, this);
}
@ -32,7 +32,7 @@ void CServerGameDLL::PrecompileScriptsJob(void)
//-----------------------------------------------------------------------------
void CServerGameDLL::LevelShutdown(void)
{
static int index = 8;
const int index = 8;
CallVFunc<void>(index, this);
}
@ -42,7 +42,7 @@ void CServerGameDLL::LevelShutdown(void)
//-----------------------------------------------------------------------------
void CServerGameDLL::GameShutdown(void)
{
static int index = 9;
const int index = 9;
CallVFunc<void>(index, this);
}
@ -52,7 +52,7 @@ void CServerGameDLL::GameShutdown(void)
//-----------------------------------------------------------------------------
float CServerGameDLL::GetTickInterval(void)
{
static int index = 11;
const int index = 11;
return CallVFunc<float>(index, this);
}

View File

@ -300,6 +300,9 @@ void CBrowser::GetServerList(void)
//-----------------------------------------------------------------------------
// Purpose: connects to specified server
// Input : &svIp -
// &svPort -
// &svNetKey -
//-----------------------------------------------------------------------------
void CBrowser::ConnectToServer(const string& svIp, const string& svPort, const string& svNetKey)
{
@ -315,6 +318,8 @@ void CBrowser::ConnectToServer(const string& svIp, const string& svPort, const s
//-----------------------------------------------------------------------------
// Purpose: connects to specified server
// Input : &svServer -
// &svNetKey -
//-----------------------------------------------------------------------------
void CBrowser::ConnectToServer(const string& svServer, const string& svNetKey)
{
@ -675,14 +680,13 @@ void CBrowser::SendHostingPostRequest(void)
//-----------------------------------------------------------------------------
// Purpose: executes submitted commands in a separate thread
// Input : *pszCommand -
//-----------------------------------------------------------------------------
void CBrowser::ProcessCommand(const char* pszCommand)
{
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
t.detach(); // Detach from render thread.
// This is to avoid a race condition.
std::this_thread::sleep_for(std::chrono::milliseconds(1));
Cbuf_AddText(Cbuf_GetCurrentPlayer(), pszCommand, cmd_source_t::kCommandSrcCode);
std::thread t(Cbuf_Execute);
t.detach(); // Detatch from render thread.
}
//-----------------------------------------------------------------------------
@ -717,6 +721,7 @@ void CBrowser::RegenerateEncryptionKey(void) const
//-----------------------------------------------------------------------------
// Purpose: changes encryption key to specified one
// Input : &svNetKey -
//-----------------------------------------------------------------------------
void CBrowser::ChangeEncryptionKey(const string& svNetKey) const
{

View File

@ -530,11 +530,9 @@ void CConsole::ProcessCommand(const char* pszCommand)
{
DevMsg(eDLL_T::COMMON, "] %s\n", pszCommand);
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
t.detach(); // Detach from render thread.
// This is to avoid a race condition.
std::this_thread::sleep_for(std::chrono::milliseconds(1));
Cbuf_AddText(Cbuf_GetCurrentPlayer(), pszCommand, cmd_source_t::kCommandSrcCode);
std::thread t(Cbuf_Execute);
t.detach(); // Detatch from render thread.
m_nHistoryPos = -1;
for (ssize_t i = static_cast<ssize_t>(m_vHistory.size()) - 1; i >= 0; i--)

View File

@ -13,7 +13,7 @@
//-----------------------------------------------------------------------------
void CInputSystem::EnableInput(bool bEnabled)
{
static int index = 10;
const int index = 10;
CallVFunc<void>(index, this, bEnabled);
}
@ -22,7 +22,7 @@ void CInputSystem::EnableInput(bool bEnabled)
//-----------------------------------------------------------------------------
void CInputSystem::EnableMessagePump(bool bEnabled)
{
static int index = 11;
const int index = 11;
CallVFunc<void>(index, this, bEnabled);
}
@ -31,7 +31,7 @@ void CInputSystem::EnableMessagePump(bool bEnabled)
//-----------------------------------------------------------------------------
bool CInputSystem::IsButtonDown(ButtonCode_t Button)
{
static int index = 13;
const int index = 13;
return CallVFunc<bool>(index, this, Button);
}

View File

@ -19,22 +19,22 @@ class CIVDebugOverlay : public IVDebugOverlay
public:
void AddBoxOverlay(__m128i& vTransforms, const Vector3D& vMins, const Vector3D& vMaxs, int r, int g, int b, int a, bool bZBuffer, float flDuration)
{
static int index = 1;
const int index = 1;
CallVFunc<void>(index, this, vTransforms, vMins, vMaxs, r, g, b, a, bZBuffer, flDuration);
}
void AddSphereOverlay(const Vector3D& vOrigin, float flRadius, int nTheta, int nPhi, int r, int g, int b, int a, float flDuration)
{
static int index = 3;
const int index = 3;
CallVFunc<void>(index, this, vOrigin, flRadius, nTheta, nPhi, r, g, b, a, flDuration);
}
void AddLineOverlay(const Vector3D& vStart, const Vector3D& vEnd, int r, int g, int b, char bZBuffer, float flDuration)
{
static int index = 5;
const int index = 5;
CallVFunc<void>(index, this, vStart, vEnd, r, g, b, bZBuffer, flDuration);
}
void AddCapsuleOverlay(const Vector3D& vStart, const Vector3D& vEnd, const Vector3D& vRadius, const Vector3D& vTop, const Vector3D& vBottom, int r, int g, int b, int a, float flDuration)
{
static int index = 12;
const int index = 12;
CallVFunc<void>(index, this, vStart, vEnd, vRadius, vTop, vBottom, r, g, b, a, flDuration);
}
};

View File

@ -31,7 +31,7 @@ class VRui : public IDetour
p_Rui_LoadAsset = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xE8\x00\x00\x00\x00\xEB\x03\x49\x8B\xC6\x48\x89\x86\x00\x00\x00\x00\x8B\x86\x00\x00\x00\x00"), "x????xxxxxxxx????xx????").FollowNearCallSelf();
v_Rui_LoadAsset = p_Rui_LoadAsset.RCast<void* (*)(const char*)>(); /*E8 ?? ?? ?? ?? EB 03 49 8B C6 48 89 86 ?? ?? ?? ?? 8B 86 ?? ?? ?? ??*/
p_Rui_GetFontFace = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x74\x05\x49\x8B\xD1\xEB\x19\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x48\x58\x48\x85\xC9\x48\x0F\x45\xD1\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x75\x19\x48\x8B\x05\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x4C\x8B\x40\x58\x4D\x85\xC0\x4D\x0F\x45\xC8\x49\x8B\xC9\x48\xFF\x25\x00\x00\x00\x00"), "xx????????xxx????xxxxxxxxxx????xxx????xxxxxxxxxxxxx????????xxxxx????xxx????xxxxxxxxxxxxxxxxx????");;
p_Rui_GetFontFace = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x74\x05\x49\x8B\xD1\xEB\x19\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x15\x00\x00\x00\x00\x48\x8B\x48\x58\x48\x85\xC9\x48\x0F\x45\xD1\xF7\x05\x00\x00\x00\x00\x00\x00\x00\x00\x75\x19\x48\x8B\x05\x00\x00\x00\x00\x4C\x8D\x0D\x00\x00\x00\x00\x4C\x8B\x40\x58\x4D\x85\xC0\x4D\x0F\x45\xC8\x49\x8B\xC9\x48\xFF\x25\x00\x00\x00\x00"), "xx????????xxx????xxxxxxxxxx????xxx????xxxxxxxxxxxxx????????xxxxx????xxx????xxxxxxxxxxxxxxxxx????");
v_Rui_GetFontFace = p_Rui_GetFontFace.RCast<int16_t(*)(void)>();/*F7 05 ? ? ? ? ? ? ? ? 4C 8D 0D ? ? ? ? 74 05 49 8B D1 EB 19 48 8B 05 ? ? ? ? 48 8D 15 ? ? ? ? 48 8B 48 58 48 85 C9 48 0F 45 D1 F7 05 ? ? ? ? ? ? ? ? 75 19 48 8B 05 ? ? ? ? 4C 8D 0D ? ? ? ? 4C 8B 40 58 4D 85 C0 4D 0F 45 C8 49 8B C9 48 FF 25 ? ? ? ?*/
}
virtual void GetVar(void) const { }

View File

@ -246,15 +246,15 @@ SQBool Script_LoadScript(HSQUIRRELVM v, const SQChar* szScriptPath, const SQChar
//---------------------------------------------------------------------------------
void Script_Execute(const SQChar* code, SQCONTEXT context)
{
CSquirrelVM* scriptVM = Script_GetContextObject(context);
CSquirrelVM* script = Script_GetContextObject(context);
if (!scriptVM)
if (!script)
{
Error(eDLL_T::ENGINE, "Attempted to run %s script while VM isn't initialized\n", SQVM_GetContextName(context));
return;
}
HSQUIRRELVM v = scriptVM->GetVM();
HSQUIRRELVM v = script->GetVM();
if (!v)
{
Error(eDLL_T::ENGINE, "Attempted to run %s script while VM isn't initialized\n", SQVM_GetContextName(context));

View File

@ -53,11 +53,8 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
nResponseId = -4;
break;
default:
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
context = v->GetContext();
#else // Nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
context = SQVM_GetContextIndex(v);
#endif
switch (context)
{
case SQCONTEXT::SERVER:
@ -154,7 +151,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
}
else
{
vmStrAnsi = Plat_GetProcessUpTime();;
vmStrAnsi = Plat_GetProcessUpTime();
vmStrAnsi.append(SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)]);
}
vmStrAnsi.append(buf);

View File

@ -1955,7 +1955,7 @@ dtStatus dtMarkCylinderArea(dtTileCacheLayer& layer, const float* orig, const fl
bmin[2] = pos[2];
bmax[0] = pos[0] + radius;
bmax[1] = pos[1] + radius;
bmax[2] = pos[2] + height;;
bmax[2] = pos[2] + height;
const float r2 = dtSqr(radius/cs + 0.5f);
const int w = (int)layer.header->width;

View File

@ -33,7 +33,7 @@ CCommandLine::~CCommandLine(void)
//-----------------------------------------------------------------------------
void CCommandLine::CreateCmdLine(const char* pszCommandline)
{
static int index = 0;
const int index = 0;
CallVFunc<void>(index, this, pszCommandline);
}
@ -42,7 +42,7 @@ void CCommandLine::CreateCmdLine(const char* pszCommandline)
//-----------------------------------------------------------------------------
void CCommandLine::CreateCmdLine(int argc, char** argv)
{
static int index = 1;
const int index = 1;
CallVFunc<void>(index, this, argc, argv);
}
@ -51,7 +51,7 @@ void CCommandLine::CreateCmdLine(int argc, char** argv)
//-----------------------------------------------------------------------------
void CCommandLine::CreatePool(void* pMem)
{
static int index = 2;
const int index = 2;
CallVFunc<void>(index, this, pMem);
}
@ -61,7 +61,7 @@ void CCommandLine::CreatePool(void* pMem)
//-----------------------------------------------------------------------------
const char* CCommandLine::GetCmdLine(void)
{
static int index = 3;
const int index = 3;
return CallVFunc<const char*>(index, this);
}
@ -73,7 +73,7 @@ const char* CCommandLine::GetCmdLine(void)
//-----------------------------------------------------------------------------
const char* CCommandLine::CheckParm(const char* psz, const char** ppszValue)
{
static int index = 4;
const int index = 4;
return CallVFunc<const char*>(index, this, psz, ppszValue);
}
@ -83,7 +83,7 @@ const char* CCommandLine::CheckParm(const char* psz, const char** ppszValue)
//-----------------------------------------------------------------------------
void CCommandLine::RemoveParm(const char* pszParm)
{
static int index = 5;
const int index = 5;
CallVFunc<void>(index, this, pszParm);
}
@ -94,7 +94,7 @@ void CCommandLine::RemoveParm(const char* pszParm)
//-----------------------------------------------------------------------------
void CCommandLine::AppendParm(const char* pszParm, const char* pszValues)
{
static int index = 6;
const int index = 6;
CallVFunc<void>(index, this, pszParm, pszValues);
}
@ -103,17 +103,17 @@ void CCommandLine::AppendParm(const char* pszParm, const char* pszValues)
//-----------------------------------------------------------------------------
float CCommandLine::ParmValue(const char* psz, float flDefaultVal)
{
static int index = 7;
const int index = 7;
return CallVFunc<float>(index, this, psz, flDefaultVal);
}
int CCommandLine::ParmValue(const char* psz, int nDefaultVal)
{
static int index = 8;
const int index = 8;
return CallVFunc<int>(index, this, psz, nDefaultVal);
}
const char* CCommandLine::ParmValue(const char* psz, const char* pDefaultVal)
{
static int index = 9;
const int index = 9;
return CallVFunc<const char*>(index, this, psz, pDefaultVal);
}
@ -122,25 +122,25 @@ const char* CCommandLine::ParmValue(const char* psz, const char* pDefaultVal)
//-----------------------------------------------------------------------------
int CCommandLine::ParmCount(void)
{
static int index = 10;
const int index = 10;
return CallVFunc<int>(index, this);
}
int CCommandLine::FindParm(const char* psz)
{
static int index = 11;
const int index = 11;
return CallVFunc<int>(index, this, psz);
}
const char* CCommandLine::GetParm(int nIndex)
{
static int index = 12;
const int index = 12;
return CallVFunc<const char*>(index, this, nIndex);
}
void CCommandLine::SetParm(int nIndex, char const* pParm)
{
static int index = 14;
const int index = 14;
CallVFunc<void>(index, this, nIndex, pParm);
}

View File

@ -172,7 +172,7 @@ ConVar* rui_drawEnable = nullptr;
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::RegisterConCommand(ConCommandBase* pCommandToRemove)
{
static int index = 9;
const int index = 9;
return CallVFunc<ConCommandBase*>(index, this, pCommandToRemove);
}
@ -182,7 +182,7 @@ ConCommandBase* CCVar::RegisterConCommand(ConCommandBase* pCommandToRemove)
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::UnregisterConCommand(ConCommandBase* pCommandToRemove)
{
static int index = 10;
const int index = 10;
return CallVFunc<ConCommandBase*>(index, this, pCommandToRemove);
}
@ -192,7 +192,7 @@ ConCommandBase* CCVar::UnregisterConCommand(ConCommandBase* pCommandToRemove)
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::FindCommandBase(const char* pszCommandName)
{
static int index = 14;
const int index = 14;
return CallVFunc<ConCommandBase*>(index, this, pszCommandName);
}
@ -202,7 +202,7 @@ ConCommandBase* CCVar::FindCommandBase(const char* pszCommandName)
//-----------------------------------------------------------------------------
ConVar* CCVar::FindVar(const char* pszVarName)
{
static int index = 16;
const int index = 16;
return CallVFunc<ConVar*>(index, this, pszVarName);
}
@ -212,7 +212,7 @@ ConVar* CCVar::FindVar(const char* pszVarName)
//-----------------------------------------------------------------------------
ConCommand* CCVar::FindCommand(const char* pszCommandName)
{
static int index = 18;
const int index = 18;
return CallVFunc<ConCommand*>(index, this, pszCommandName);
}
@ -254,7 +254,7 @@ void CCVar::QueueMaterialThreadSetValue(ConVar* pConVar, const char* pValue)
//-----------------------------------------------------------------------------
CCVarIteratorInternal* CCVar::FactoryInternalIterator(void)
{
static int index = 41;
const int index = 41;
return CallVFunc<CCVarIteratorInternal*>(index, this);
}

View File

@ -24,7 +24,7 @@ CKeyValuesSystem* KeyValuesSystem()
//-----------------------------------------------------------------------------
void CKeyValuesSystem::RegisterSizeofKeyValues(int64_t nSize)
{
static int index = 0;
const int index = 0;
CallVFunc<void>(index, this, nSize);
}
@ -35,7 +35,7 @@ void CKeyValuesSystem::RegisterSizeofKeyValues(int64_t nSize)
//-----------------------------------------------------------------------------
void* CKeyValuesSystem::AllocKeyValuesMemory(int64_t nSize)
{
static int index = 1;
const int index = 1;
return CallVFunc<void*>(index, this, nSize);
}
@ -45,7 +45,7 @@ void* CKeyValuesSystem::AllocKeyValuesMemory(int64_t nSize)
//-----------------------------------------------------------------------------
void CKeyValuesSystem::FreeKeyValuesMemory(void* pMem)
{
static int index = 2;
const int index = 2;
CallVFunc<void>(index, this, pMem);
}
@ -57,7 +57,7 @@ void CKeyValuesSystem::FreeKeyValuesMemory(void* pMem)
//-----------------------------------------------------------------------------
HKeySymbol CKeyValuesSystem::GetSymbolForString(const char* szName, bool bCreate)
{
static int index = 3;
const int index = 3;
return CallVFunc<HKeySymbol>(index, this, szName, bCreate);
}
@ -68,7 +68,7 @@ HKeySymbol CKeyValuesSystem::GetSymbolForString(const char* szName, bool bCreate
//-----------------------------------------------------------------------------
const char* CKeyValuesSystem::GetStringForSymbol(HKeySymbol symbol)
{
static int index = 4;
const int index = 4;
return CallVFunc<const char*>(index, this, symbol);
}
@ -78,7 +78,7 @@ const char* CKeyValuesSystem::GetStringForSymbol(HKeySymbol symbol)
//-----------------------------------------------------------------------------
void* CKeyValuesSystem::GetMemPool(void)
{
static int index = 7;
const int index = 7;
return CallVFunc<void*>(index, this);
}
@ -90,7 +90,7 @@ void* CKeyValuesSystem::GetMemPool(void)
//-----------------------------------------------------------------------------
void CKeyValuesSystem::SetKeyValuesExpressionSymbol(const char* szName, bool bValue)
{
static int index = 8;
const int index = 8;
CallVFunc<void>(index, this, szName, bValue);
}
@ -100,7 +100,7 @@ void CKeyValuesSystem::SetKeyValuesExpressionSymbol(const char* szName, bool bVa
//-----------------------------------------------------------------------------
bool CKeyValuesSystem::GetKeyValuesExpressionSymbol(const char* szName)
{
static int index = 9;
const int index = 9;
return CallVFunc<bool>(index, this, szName);
}
@ -113,6 +113,6 @@ bool CKeyValuesSystem::GetKeyValuesExpressionSymbol(const char* szName)
//-----------------------------------------------------------------------------
HKeySymbol CKeyValuesSystem::GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* szName, bool bCreate)
{
static int index = 10;
const int index = 10;
return CallVFunc<HKeySymbol>(index, this, hCaseInsensitiveSymbol, szName, bCreate);
}