mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier1: fix flag testing bug in ConVar::Create
The archive + playerprofile flags check was done on the uninitialized member variable 'm_nFlags', but it should've been performed on the function's input parameter 'flags' as m_nFlags is only initialized past this check in BaseClass::Create (its part of ConCommandBase). This caused statically initialized ConVar's flagged 'FCVAR_ARCHIVE | FCVAR_ARCHIVE_PLAYERPROFILE' to go undetected, and dynamically initialized ones (e.g. through mod settings) to have random memory and intermittently fail this check. The latter is how this bug was found and ultimately fixed in this patch.
This commit is contained in:
parent
3fc1bcd2b7
commit
56f8a69114
@ -1020,7 +1020,7 @@ void ConVar::Create(const char* pName, const char* pDefaultValue, int flags /*=
|
||||
// Only 1 of the 2 can be set on a ConVar, both means there is a bug in
|
||||
// your code, fix it!
|
||||
const int nFlagsToCheck = (FCVAR_ARCHIVE | FCVAR_ARCHIVE_PLAYERPROFILE);
|
||||
if ((m_nFlags & nFlagsToCheck) == nFlagsToCheck)
|
||||
if ((flags & nFlagsToCheck) == nFlagsToCheck)
|
||||
{
|
||||
Error(eDLL_T::COMMON, EXIT_FAILURE,
|
||||
"Convar '%s' is flagged as both FCVAR_ARCHIVE and FCVAR_ARCHIVE_PLAYERPROFILE.\n", pName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user