From 7a3bea3c0afee85ec5d049aae7b2a4aa1782ed49 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:34:22 +0200 Subject: [PATCH 1/7] 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; From df119e69d767fa575696f1c6172ca9bf60fc2cdb Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 13 May 2019 14:19:58 +0200 Subject: [PATCH 2/7] Removed redundant semi-colons --- src/Flags.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index ee18b4a3..3ab98ce9 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,8 +7,8 @@ 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 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 From 7f75ad6ef8ca9c1a2b87f860e4287b32c14845f3 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 13 May 2019 14:20:39 +0200 Subject: [PATCH 3/7] Added comment for macros --- src/Flags.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Flags.cpp b/src/Flags.cpp index 3ab98ce9..afc3706a 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,6 +7,7 @@ unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; +// Macros for setting, un-setting and getting bits #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)) From a0f4bae094d5724b78fe974770b74ccda42d1858 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 13 May 2019 18:58:29 +0200 Subject: [PATCH 4/7] Moved and renamed flag macros Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index afc3706a..97eb069c 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,11 +7,6 @@ unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; -// Macros for setting, un-setting and getting bits -#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() { @@ -23,20 +18,29 @@ void InitSkipFlags() memset(gSkipFlag, 0, sizeof(gSkipFlag)); } +// Macros for setting, un-setting and getting flags +// Each flag is stored in a single bit +#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)) +#define SET_FLAG SET_BIT +#define UNSET_FLAG UNSET_BIT +#define GET_FLAG GET_BIT + //NPC flags void SetNPCFlag(long a) { - SET_BIT(gFlagNPC, a); + SET_FLAG(gFlagNPC, a); } void CutNPCFlag(long a) { - UNSET_BIT(gFlagNPC, a); + UNSET_FLAG(gFlagNPC, a); } BOOL GetNPCFlag(long a) { - if (GET_BIT(gFlagNPC, a)) + if (GET_FLAG(gFlagNPC, a)) return TRUE; else return FALSE; @@ -45,17 +49,17 @@ BOOL GetNPCFlag(long a) //Skip flags void SetSkipFlag(long a) { - SET_BIT(gSkipFlag, a); + SET_FLAG(gSkipFlag, a); } void CutSkipFlag(long a) { - UNSET_BIT(gSkipFlag, a); + UNSET_FLAG(gSkipFlag, a); } BOOL GetSkipFlag(long a) { - if (GET_BIT(gSkipFlag, a)) + if (GET_FLAG(gSkipFlag, a)) return TRUE; else return FALSE; From bce894210da1fecc16e1112dcacb62e39adf4364 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 13 May 2019 20:54:43 +0200 Subject: [PATCH 5/7] Move macros in Flags.cpp right below the includes Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index 97eb069c..a1f7dc10 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -4,6 +4,16 @@ #include "WindowsWrapper.h" +// Macros for setting, un-setting and getting bits +#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)) + +// Each flag is stored in a bit, so we can use the exact same macros for this +#define SET_FLAG(x, i) SET_BIT(x, i) +#define UNSET_FLAG(x, i) UNSET_BIT(x, i) +#define GET_FLAG(x, i) GET_BIT(x, i) + unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; @@ -18,15 +28,6 @@ void InitSkipFlags() memset(gSkipFlag, 0, sizeof(gSkipFlag)); } -// Macros for setting, un-setting and getting flags -// Each flag is stored in a single bit -#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)) -#define SET_FLAG SET_BIT -#define UNSET_FLAG UNSET_BIT -#define GET_FLAG GET_BIT - //NPC flags void SetNPCFlag(long a) { From 92a2327187f9d0c3f5b2ed6948b0d832c7e2d58e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 15 May 2019 13:25:13 +0200 Subject: [PATCH 6/7] Removed BIT macros in Flags.cpp Just directly define the FLAG macros as those --- src/Flags.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index a1f7dc10..500da014 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -5,14 +5,10 @@ #include "WindowsWrapper.h" // Macros for setting, un-setting and getting bits -#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)) - -// Each flag is stored in a bit, so we can use the exact same macros for this -#define SET_FLAG(x, i) SET_BIT(x, i) -#define UNSET_FLAG(x, i) UNSET_BIT(x, i) -#define GET_FLAG(x, i) GET_BIT(x, i) +// Each flag is stored in a bit, so we can use the exact same macros for this (not defining BIT macros for conciseness) +#define SET_FLAG(x, i) ((x)[(i) / 8] |= 1 << (i) % 8) +#define UNSET_FLAG(x, i) ((x)[(i) / 8] &= ~(1 << (i) % 8)) +#define GET_FLAG(x, i) ((x)[(i) / 8] & (1 << (i) % 8)) unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; From 0e0cbf94092ff15adcb179efbb7a76582ceb188d Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 15 May 2019 17:46:14 +0200 Subject: [PATCH 7/7] Simplify a comment in Flags.cpp Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index 500da014..face9fed 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -4,8 +4,8 @@ #include "WindowsWrapper.h" -// Macros for setting, un-setting and getting bits -// Each flag is stored in a bit, so we can use the exact same macros for this (not defining BIT macros for conciseness) +// Macros for setting, un-setting and getting flags +// Each flag is stored in a bit, so we can use the exact same macros we'd use for bits #define SET_FLAG(x, i) ((x)[(i) / 8] |= 1 << (i) % 8) #define UNSET_FLAG(x, i) ((x)[(i) / 8] &= ~(1 << (i) % 8)) #define GET_FLAG(x, i) ((x)[(i) / 8] & (1 << (i) % 8))