Use size_t for SDK_ARRAYSIZE instead

sizeof() returns a size_t.
This commit is contained in:
Kawe Mazidjatari 2022-07-03 19:18:23 +02:00
parent b075977dd7
commit becf8eb6a5
3 changed files with 7 additions and 11 deletions

View File

@ -35,10 +35,10 @@ void R5Dev_Init()
#endif // !DEDICATED
SpdLog_Init();
spdlog::info("\n");
for (int i = 0; i < (&R5R_EMBLEM)[1] - R5R_EMBLEM; i++)
for (size_t i = 0; i < SDK_ARRAYSIZE(R5R_EMBLEM); i++)
{
std::string svEscaped = StringEscape(R5R_EMBLEM[i]);
spdlog::info("{}{}{}\n", g_svRedF.c_str(), svEscaped.c_str(), g_svReset.c_str());
spdlog::info("{:s}{:s}{:s}\n", g_svRedF.c_str(), svEscaped.c_str(), g_svReset.c_str());
}
spdlog::info("\n");

View File

@ -135,7 +135,7 @@
#define MAX_MAP_NAME 64
#define SDK_VERSION "VGameSDK001" // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility).
#define SDK_ARRAYSIZE(arr) ((int)(sizeof(arr) / sizeof(*arr))) // Name due to IMGUI implementation and NT implementation that we shouldn't share across everywhere.
#define SDK_ARRAYSIZE(arr) ((sizeof(arr) / sizeof(*arr))) // Name due to IMGUI implementation and NT implementation that we shouldn't share across everywhere.
#ifndef DEDICATED
#define SDK_DEFAULT_CFG "platform\\cfg\\startup_default.cfg"

View File

@ -204,11 +204,9 @@ void ConVar::PurgeShipped(void) const
"voice_enabled",
};
for (int i = 0; i < SDK_ARRAYSIZE(pszToPurge); i++)
for (size_t i = 0; i < SDK_ARRAYSIZE(pszToPurge); i++)
{
ConVar* pCVar = g_pCVar->FindVar(pszToPurge[i]);
if (pCVar)
if (ConVar* pCVar = g_pCVar->FindVar(pszToPurge[i]))
{
pCVar->SetValue(0);
}
@ -241,11 +239,9 @@ void ConVar::PurgeHostNames(void) const
"users_hostname"
};
for (int i = 0; i < SDK_ARRAYSIZE(pszHostNames); i++)
for (size_t i = 0; i < SDK_ARRAYSIZE(pszHostNames); i++)
{
ConVar* pCVar = g_pCVar->FindVar(pszHostNames[i]);
if (pCVar)
if (ConVar* pCVar = g_pCVar->FindVar(pszHostNames[i]))
{
pCVar->ChangeStringValueUnsafe("0.0.0.0");
}