1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-20 12:36:05 +08:00

Rework ConCommandRegList

This commit is contained in:
Nick Hastings
2023-05-18 23:47:58 -04:00
committed by Nicholas Hastings
parent 311c966f97
commit 2541d89f62

View File

@ -39,15 +39,9 @@ static int64 s_nCVarFlag = 0;
static bool s_bRegistered = false;
class ConCommandRegList;
static ConCommandRegList* s_pCmdRegList = nullptr;
class ConCommandRegList
{
public:
ConCommandRegList()
{
}
static void RegisterCommand(ConCommand* pCmd)
{
if (s_bConCommandsRegistered)
@ -63,15 +57,7 @@ public:
}
else
{
ConCommandRegList* pList = s_pCmdRegList;
if ( !pList || pList->m_Vec.Count() == 100 )
{
pList = new ConCommandRegList;
pList->m_pNext = s_pCmdRegList;
s_pCmdRegList = pList;
}
pList->m_Vec.AddToTail(*pCmd);
s_ConCommandRegList.AddToTail(pCmd);
}
}
@ -81,12 +67,9 @@ public:
{
s_bConCommandsRegistered = true;
ConCommandRegList* pList = s_pCmdRegList;
while ( pList != nullptr )
FOR_EACH_VEC( s_ConCommandRegList, i)
{
FOR_EACH_VEC( s_pCmdRegList->m_Vec, i )
{
ConCommand* pCmd = &pList->m_Vec[i];
ConCommand *pCmd = s_ConCommandRegList[i];
ConCommandHandle hndl = g_pCVar->RegisterConCommand(pCmd, s_nCVarFlag);
pCmd->SetHandle(hndl);
@ -96,23 +79,16 @@ public:
DebuggerBreakIfDebugging();
}
}
ConCommandRegList* pNext = pList->m_pNext;
delete pList;
pList = pNext;
}
s_pCmdRegList = nullptr;
}
}
private:
CUtlVectorFixed<ConCommand, 100> m_Vec;
ConCommandRegList* m_pNext = nullptr;
static CUtlVector<ConCommand*> s_ConCommandRegList;
static bool s_bConCommandsRegistered;
};
bool ConCommandRegList::s_bConCommandsRegistered = false;
CUtlVector<ConCommand*> ConCommandRegList::s_ConCommandRegList;
#ifdef CONVAR_WORK_FINISHED
template <typename ToCheck, std::size_t ExpectedSize, std::size_t RealSize = sizeof(ToCheck)>