From 7a3bea3c0afee85ec5d049aae7b2a4aa1782ed49 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:34:22 +0200 Subject: [PATCH] Change Flags.cpp to use macros Pixel probably did this tbh Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index c7e3d192..ee18b4a3 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,6 +7,10 @@ unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; +#define SET_BIT(x, i) ((x)[(i) / 8] |= 1 << (i) % 8;) +#define UNSET_BIT(x, i) ((x)[(i) / 8] &= ~(1 << (i) % 8);) +#define GET_BIT(x, i) ((x)[(i) / 8] & (1 << (i) % 8)) + //Flag inits void InitFlags() { @@ -21,17 +25,17 @@ void InitSkipFlags() //NPC flags void SetNPCFlag(long a) { - gFlagNPC[a / 8] |= 1 << a % 8; + SET_BIT(gFlagNPC, a); } void CutNPCFlag(long a) { - gFlagNPC[a / 8] &= ~(1 << a % 8); + UNSET_BIT(gFlagNPC, a); } BOOL GetNPCFlag(long a) { - if (gFlagNPC[a / 8] & (1 << a % 8)) + if (GET_BIT(gFlagNPC, a)) return TRUE; else return FALSE; @@ -40,17 +44,17 @@ BOOL GetNPCFlag(long a) //Skip flags void SetSkipFlag(long a) { - gSkipFlag[a / 8] |= 1 << a % 8; + SET_BIT(gSkipFlag, a); } void CutSkipFlag(long a) { - gSkipFlag[a / 8] &= ~(1 << a % 8); + UNSET_BIT(gSkipFlag, a); } BOOL GetSkipFlag(long a) { - if (gSkipFlag[a / 8] & (1 << a % 8)) + if (GET_BIT(gSkipFlag, a)) return TRUE; else return FALSE;