mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CCVarIteratorInternal cleanup
* Improve readability. * Free allocated iterator memory. * Enforce FCVAR_HIDDEN ConVar's in ImGui console (there are only 17 ConVar's marked 'hidden', and most of these are stryder/platform related stuff. This is usefull for if we ever wish to create a hidden cvar).
This commit is contained in:
parent
61dbda67f7
commit
9f7d4f57d3
@ -474,46 +474,49 @@ void CConsole::FindFromPartial(void)
|
||||
|
||||
if (ConCommandBase* pCommandBase = g_pCVar->FindCommandBase(m_vsvCommandBases[i].m_svName.c_str()))
|
||||
{
|
||||
if (!pCommandBase->IsCommand())
|
||||
if (!pCommandBase->IsFlagSet(FCVAR_HIDDEN))
|
||||
{
|
||||
ConVar* pConVar = reinterpret_cast<ConVar*>(pCommandBase);
|
||||
if (!pCommandBase->IsCommand())
|
||||
{
|
||||
ConVar* pConVar = reinterpret_cast<ConVar*>(pCommandBase);
|
||||
|
||||
svValue = " = ["; // Assign default value to string if its a ConVar.
|
||||
svValue.append(pConVar->GetString());
|
||||
svValue.append("]");
|
||||
}
|
||||
if (con_suggestion_showhelptext->GetBool())
|
||||
{
|
||||
if (pCommandBase->GetHelpText())
|
||||
svValue = " = ["; // Assign default value to string if its a ConVar.
|
||||
svValue.append(pConVar->GetString());
|
||||
svValue.append("]");
|
||||
}
|
||||
if (con_suggestion_showhelptext->GetBool())
|
||||
{
|
||||
string svHelpText = pCommandBase->GetHelpText();
|
||||
if (!svHelpText.empty())
|
||||
if (pCommandBase->GetHelpText())
|
||||
{
|
||||
svValue.append(" - \"" + svHelpText + "\"");
|
||||
string svHelpText = pCommandBase->GetHelpText();
|
||||
if (!svHelpText.empty())
|
||||
{
|
||||
svValue.append(" - \"" + svHelpText + "\"");
|
||||
}
|
||||
}
|
||||
if (pCommandBase->GetUsageText())
|
||||
{
|
||||
string svUsageText = pCommandBase->GetUsageText();
|
||||
if (!svUsageText.empty())
|
||||
{
|
||||
svValue.append(" - \"" + svUsageText + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pCommandBase->GetUsageText())
|
||||
if (con_suggestion_showflags->GetBool())
|
||||
{
|
||||
string svUsageText = pCommandBase->GetUsageText();
|
||||
if (!svUsageText.empty())
|
||||
if (con_suggestion_flags_realtime->GetBool())
|
||||
{
|
||||
svValue.append(" - \"" + svUsageText + "\"");
|
||||
nFlags = pCommandBase->GetFlags();
|
||||
}
|
||||
else // Display compile-time flags instead.
|
||||
{
|
||||
nFlags = m_vsvCommandBases[i].m_nFlags;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (con_suggestion_showflags->GetBool())
|
||||
{
|
||||
if (con_suggestion_flags_realtime->GetBool())
|
||||
{
|
||||
nFlags = pCommandBase->GetFlags();
|
||||
}
|
||||
else // Display compile-time flags instead.
|
||||
{
|
||||
nFlags = m_vsvCommandBases[i].m_nFlags;
|
||||
}
|
||||
m_vSuggest.push_back(CSuggest(m_vsvCommandBases[i].m_svName + svValue, nFlags));
|
||||
}
|
||||
}
|
||||
m_vSuggest.push_back(CSuggest(m_vsvCommandBases[i].m_svName + svValue, nFlags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ bool CModAppSystemGroup::Create(CModAppSystemGroup* pModAppSystemGroup)
|
||||
if (CommandLine()->CheckParm("-devsdk"))
|
||||
{
|
||||
cv->EnableDevCvars();
|
||||
cv->EnableHiddenCvars();
|
||||
}
|
||||
|
||||
#endif // !DEDICATED
|
||||
|
@ -341,14 +341,11 @@ int CCvarUtilities::CountVariablesWithFlags(int flags)
|
||||
{
|
||||
int i = 0;
|
||||
ConCommandBase* var;
|
||||
CCvar::CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
|
||||
|
||||
// Loop through cvars...
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
|
||||
while (pFactory->IsValid())
|
||||
for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through cvars...
|
||||
{
|
||||
var = pFactory->Get();
|
||||
var = itint->Get();
|
||||
if (!var->IsCommand())
|
||||
{
|
||||
if (var->IsFlagSet(flags))
|
||||
@ -356,10 +353,9 @@ int CCvarUtilities::CountVariablesWithFlags(int flags)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
pFactory->Next();
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(itint);
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -369,38 +365,16 @@ int CCvarUtilities::CountVariablesWithFlags(int flags)
|
||||
void CCvarUtilities::EnableDevCvars()
|
||||
{
|
||||
// Loop through cvars...
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
CCvar::CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
|
||||
|
||||
while (pFactory->IsValid())
|
||||
for (itint->SetFirst(); itint->IsValid(); itint->Next())
|
||||
{
|
||||
// remove flag from all cvars
|
||||
ConCommandBase* pCommandBase = pFactory->Get();
|
||||
ConCommandBase* pCommandBase = itint->Get();
|
||||
pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
|
||||
pFactory->Next();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes the FCVAR_DEVELOPMENTONLY flag from all cvars, making them accessible
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarUtilities::EnableHiddenCvars()
|
||||
{
|
||||
// Loop through cvars...
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
|
||||
while (pFactory->IsValid())
|
||||
{
|
||||
// remove flag from all cvars
|
||||
ConCommandBase* pCommandBase = pFactory->Get();
|
||||
pCommandBase->RemoveFlags(FCVAR_HIDDEN);
|
||||
|
||||
pFactory->Next();
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(pFactory);
|
||||
MemAllocSingleton()->Free(itint);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -458,14 +432,11 @@ void CCvarUtilities::CvarList(const CCommand& args)
|
||||
DevMsg(eDLL_T::ENGINE, "cvar list\n--------------\n");
|
||||
|
||||
CUtlRBTree< ConCommandBase* > sorted(0, 0, ConCommandBaseLessFunc);
|
||||
CCvar::CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
|
||||
|
||||
// Loop through cvars...
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
|
||||
while (pFactory->IsValid())
|
||||
for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through all instances.
|
||||
{
|
||||
var = pFactory->Get();
|
||||
var = itint->Get();
|
||||
|
||||
if (!var->IsFlagSet(FCVAR_DEVELOPMENTONLY) &&
|
||||
!var->IsFlagSet(FCVAR_HIDDEN))
|
||||
@ -489,9 +460,10 @@ void CCvarUtilities::CvarList(const CCommand& args)
|
||||
sorted.Insert(var);
|
||||
}
|
||||
}
|
||||
pFactory->Next();
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(itint);
|
||||
|
||||
if (bLogging)
|
||||
{
|
||||
PrintListHeader(f);
|
||||
@ -560,13 +532,12 @@ void CCvarUtilities::CvarHelp(const CCommand& args)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarUtilities::CvarDifferences(const CCommand& args)
|
||||
{
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
CCvar::CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
|
||||
int i = 0;
|
||||
|
||||
while (pFactory->IsValid())
|
||||
for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through all instances.
|
||||
{
|
||||
ConCommandBase* pCommandBase = pFactory->Get();
|
||||
ConCommandBase* pCommandBase = itint->Get();
|
||||
|
||||
if (!pCommandBase->IsCommand() &&
|
||||
!pCommandBase->IsFlagSet(FCVAR_HIDDEN))
|
||||
@ -582,8 +553,9 @@ void CCvarUtilities::CvarDifferences(const CCommand& args)
|
||||
}
|
||||
}
|
||||
}
|
||||
pFactory->Next();
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(itint);
|
||||
DevMsg(eDLL_T::ENGINE, "--------------\n%3i changed convars\n", i);
|
||||
}
|
||||
|
||||
@ -609,12 +581,11 @@ void CCvarUtilities::CvarFindFlags_f(const CCommand& args)
|
||||
ConCommandBase* var;
|
||||
|
||||
// Loop through vars and print out findings
|
||||
CCvar::CCVarIteratorInternal* pFactory = g_pCVar->FactoryInternalIterator();
|
||||
pFactory->SetFirst();
|
||||
CCvar::CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
|
||||
|
||||
while (pFactory->IsValid())
|
||||
for (itint->SetFirst(); itint->IsValid(); itint->Next())
|
||||
{
|
||||
var = pFactory->Get();
|
||||
var = itint->Get();
|
||||
|
||||
if (!var->IsFlagSet(FCVAR_DEVELOPMENTONLY) || !var->IsFlagSet(FCVAR_HIDDEN))
|
||||
{
|
||||
@ -629,9 +600,9 @@ void CCvarUtilities::CvarFindFlags_f(const CCommand& args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pFactory->Next();
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(itint);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -782,6 +753,8 @@ unordered_map<string, ConCommandBase*> CCvar::DumpToMap(void)
|
||||
allConVars[pszCommandName] = pCommand;
|
||||
}
|
||||
|
||||
MemAllocSingleton()->Free(itint);
|
||||
|
||||
return allConVars;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,6 @@ public:
|
||||
|
||||
// Enable cvars marked with FCVAR_DEVELOPMENTONLY
|
||||
void EnableDevCvars();
|
||||
void EnableHiddenCvars();
|
||||
|
||||
// Lists cvars to console
|
||||
void CvarList(const CCommand& args);
|
||||
|
Loading…
x
Reference in New Issue
Block a user