Modify all (4) instances of Flags_GetRandomizerInf() returns that were u8 to s32 to avoid value overflow. (#4463)

This commit is contained in:
Malkierian 2024-10-21 14:55:46 -07:00 committed by GitHub
parent 92c791b7c0
commit 17d8487730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -28,8 +28,8 @@ typedef struct {
s16 rupees;
s16 gsTokens;
u8 isDoubleDefenseAcquired;
u8 gregFound;
u8 hasWallet;
s32 gregFound;
s32 hasWallet;
} SaveFileMetaInfo;
#ifdef __cplusplus

View File

@ -29,5 +29,5 @@ s32 Flags_GetEnv(PlayState* play, s16 flag) {
s16 bit = flag % 16;
s16 mask = 1 << bit;
return play->envFlags[index] & mask;
return (play->envFlags[index] & mask) != 0;
}

View File

@ -4971,7 +4971,7 @@ s32 Flags_GetRandomizerInf(RandomizerInf flag) {
* Sets "randomizerInf" flag.
*/
void Flags_SetRandomizerInf(RandomizerInf flag) {
u8 previouslyOff = !Flags_GetRandomizerInf(flag);
s32 previouslyOff = !Flags_GetRandomizerInf(flag);
gSaveContext.randomizerInf[flag >> 4] |= (1 << (flag & 0xF));
if (previouslyOff) {
LUSLOG_INFO("RandomizerInf Flag Set - %#x", flag);
@ -4983,7 +4983,7 @@ void Flags_SetRandomizerInf(RandomizerInf flag) {
* Unsets "randomizerInf" flag.
*/
void Flags_UnsetRandomizerInf(RandomizerInf flag) {
u8 previouslyOn = Flags_GetRandomizerInf(flag);
s32 previouslyOn = Flags_GetRandomizerInf(flag);
gSaveContext.randomizerInf[flag >> 4] &= ~(1 << (flag & 0xF));
if (previouslyOn) {
LUSLOG_INFO("RandomizerInf Flag Unset - %#x", flag);