Legacy cleanup, part 2 (#3659)

* Legacy cleanup, part 2

There are still things that can be removed, those will be likely done in part three:
`The Return of the Cleanup` :)

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>

* Fix windows build

Somehow there were some unfixed errors from enabled warnings?
I'm unsure if I've pulled repo in unstable state, or those were somehow
missed.

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
This commit is contained in:
Artur K
2021-08-30 22:40:02 +02:00
committed by GitHub
parent fa0f2a1007
commit 96a5f06ca3
116 changed files with 189 additions and 18706 deletions
+1 -226
View File
@@ -1762,7 +1762,7 @@ void CXConsole::ExecuteString(const char* command, const bool bSilentMode, const
AZ::StringFunc::TrimWhiteSpace(str, true, false);
// Unroll the exec command
bool unroll = (0 == AZ::StringFunc::Find(str, "exec", 0, false, false));
if (unroll)
@@ -2891,75 +2891,6 @@ int CXConsole::GetNumVisibleVars()
return numVars;
}
//////////////////////////////////////////////////////////////////////////
bool CXConsole::IsHashCalculated()
{
return m_bCheatHashDirty == false;
}
//////////////////////////////////////////////////////////////////////////
int CXConsole::GetNumCheatVars()
{
return static_cast<int>(m_randomCheckedVariables.size());
}
//////////////////////////////////////////////////////////////////////////
uint64 CXConsole::GetCheatVarHash()
{
return m_nCheatHash;
}
//////////////////////////////////////////////////////////////////////////
void CXConsole::SetCheatVarHashRange(size_t firstVar, size_t lastVar)
{
// check inputs are sane
#if !defined(NDEBUG)
size_t numVars = GetNumCheatVars();
assert(firstVar < numVars && lastVar < numVars && lastVar >= firstVar);
#endif
#if defined(DEFENCE_CVAR_HASH_LOGGING)
if (m_bCheatHashDirty)
{
CryLog("HASHING: WARNING - trying to set up new cvar hash range while existing hash still calculating!");
}
#endif
m_nCheatHashRangeFirst = firstVar;
m_nCheatHashRangeLast = lastVar;
m_bCheatHashDirty = true;
}
//////////////////////////////////////////////////////////////////////////
void CXConsole::CalcCheatVarHash()
{
if (!m_bCheatHashDirty)
{
return;
}
CCrc32 runningNameCrc32;
CCrc32 runningNameValueCrc32;
AddCVarsToHash(m_randomCheckedVariables.begin() + m_nCheatHashRangeFirst, m_randomCheckedVariables.begin() + m_nCheatHashRangeLast, runningNameCrc32, runningNameValueCrc32);
AddCVarsToHash(m_alwaysCheckedVariables.begin(), m_alwaysCheckedVariables.end() - 1, runningNameCrc32, runningNameValueCrc32);
// store hash
m_nCheatHash = (((uint64)runningNameCrc32.Get()) << 32) | runningNameValueCrc32.Get();
m_bCheatHashDirty = false;
#if defined(DEFENCE_CVAR_HASH_LOGGING)
if (!gEnv->IsDedicated())
{
CryLog("HASHING: Range %d->%d = %llx(%x,%x), max cvars = %d", m_nCheatHashRangeFirst, m_nCheatHashRangeLast,
m_nCheatHash, runningNameCrc32.Get(), runningNameValueCrc32.Get(),
GetNumCheatVars());
PrintCheatVars(true);
}
#endif
}
void CXConsole::AddCVarsToHash(ConsoleVariablesVector::const_iterator begin, ConsoleVariablesVector::const_iterator end, CCrc32& runningNameCrc32, CCrc32& runningNameValueCrc32)
{
for (ConsoleVariablesVector::const_iterator it = begin; it <= end; ++it)
@@ -2974,162 +2905,6 @@ void CXConsole::AddCVarsToHash(ConsoleVariablesVector::const_iterator begin, Con
}
}
void CXConsole::CmdDumpAllAnticheatVars([[maybe_unused]] IConsoleCmdArgs* pArgs)
{
#if defined(DEFENCE_CVAR_HASH_LOGGING)
CXConsole* pConsole = (CXConsole*)gEnv->pConsole;
if (pConsole->IsHashCalculated())
{
CryLog("HASHING: Displaying Full Anticheat Cvar list:");
pConsole->PrintCheatVars(false);
}
else
{
CryLogAlways("DumpAllAnticheatVars - cannot complete, cheat vars are in a state of flux, please retry.");
}
#endif
}
void CXConsole::CmdDumpLastHashedAnticheatVars([[maybe_unused]] IConsoleCmdArgs* pArgs)
{
#if defined(DEFENCE_CVAR_HASH_LOGGING)
CXConsole* pConsole = (CXConsole*)gEnv->pConsole;
if (pConsole->IsHashCalculated())
{
CryLog("HASHING: Displaying Last Hashed Anticheat Cvar list:");
pConsole->PrintCheatVars(true);
}
else
{
CryLogAlways("DumpLastHashedAnticheatVars - cannot complete, cheat vars are in a state of flux, please retry.");
}
#endif
}
void CXConsole::PrintCheatVars([[maybe_unused]] bool bUseLastHashRange)
{
#if defined(DEFENCE_CVAR_HASH_LOGGING)
if (m_bCheatHashDirty)
{
return;
}
size_t i = 0;
char floatFormatBuf[64];
size_t nStart = 0;
size_t nEnd = m_mapVariables.size();
if (bUseLastHashRange)
{
nStart = m_nCheatHashRangeFirst;
nEnd = m_nCheatHashRangeLast;
}
// iterate over all const cvars in our range
// then hash the string.
CryLog("VF_CHEAT & ~VF_CHEAT_NOCHECK list:");
ConsoleVariablesMap::const_iterator it, end = m_mapVariables.end();
for (it = m_mapVariables.begin(); it != end; ++it)
{
// only count cheat cvars
if ((it->second->GetFlags() & VF_CHEAT) == 0 ||
(it->second->GetFlags() & VF_CHEAT_NOCHECK) != 0)
{
continue;
}
// count up
i++;
// if we haven't reached the first var, or have passed the last var, break out
if (i - 1 < nStart)
{
continue;
}
if (i - 1 > nEnd)
{
break;
}
// add name & variable to string. We add both since adding only the value could cause
// many collisions with variables all having value 0 or all 1.
string hashStr = it->first;
if (it->second->GetType() == CVAR_FLOAT)
{
sprintf(floatFormatBuf, "%.1g", it->second->GetFVal());
hashStr += floatFormatBuf;
}
else
{
hashStr += it->second->GetString();
}
CryLog("%s", hashStr.c_str());
}
// iterate over any must-check variables
CryLog("VF_CHEAT_ALWAYS_CHECK list:");
for (it = m_mapVariables.begin(); it != end; ++it)
{
// only count cheat cvars
if ((it->second->GetFlags() & VF_CHEAT_ALWAYS_CHECK) == 0)
{
continue;
}
// add name & variable to string. We add both since adding only the value could cause
// many collisions with variables all having value 0 or all 1.
string hashStr = it->first;
hashStr += it->second->GetString();
CryLog("%s", hashStr.c_str());
}
#endif
}
char* CXConsole::GetCheatVarAt(uint32 nOffset)
{
if (m_bCheatHashDirty)
{
return NULL;
}
size_t i = 0;
size_t nStart = nOffset;
// iterate over all const cvars in our range
// then hash the string.
ConsoleVariablesMap::const_iterator it, end = m_mapVariables.end();
for (it = m_mapVariables.begin(); it != end; ++it)
{
// only count cheat cvars
if ((it->second->GetFlags() & VF_CHEAT) == 0 ||
(it->second->GetFlags() & VF_CHEAT_NOCHECK) != 0)
{
continue;
}
// count up
i++;
// if we haven't reached the first var continue
if (i - 1 < nStart)
{
continue;
}
return (char*)it->first;
}
return NULL;
}
//////////////////////////////////////////////////////////////////////////
size_t CXConsole::GetSortedVars(AZStd::vector<AZStd::string_view>& pszArray, const char* szPrefix)
{