From 7a3bea3c0afee85ec5d049aae7b2a4aa1782ed49 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:34:22 +0200 Subject: [PATCH 01/13] 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 808df2b720842d75bf88b84d9a68bf47429ef566 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:37:58 +0200 Subject: [PATCH 02/13] Added a newline for a weird for and added a space after a comment in Font.cpp Signed-off-by: Gabriel Ravier --- src/Font.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index 915cd499..69f342c4 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -14,7 +14,7 @@ #include "File.h" // Uncomment for that authentic pre-Windows Vista feel -//#define DISABLE_FONT_ANTIALIASING +// #define DISABLE_FONT_ANTIALIASING #undef MIN #undef MAX @@ -1655,7 +1655,8 @@ static unsigned long UTF8ToUnicode(const unsigned char *string, unsigned int *by unsigned long charcode; unsigned int zero_bit = 0; - for (unsigned char lead_byte = string[0]; zero_bit < 5 && (lead_byte & 0x80); ++zero_bit, lead_byte <<= 1); + for (unsigned char lead_byte = string[0]; zero_bit < 5 && (lead_byte & 0x80); ++zero_bit, lead_byte <<= 1) + ; switch (zero_bit) { From 182dda4dd9335704b78347f74c37f7343c4c65cd Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:39:55 +0200 Subject: [PATCH 03/13] Correct comment formatting in Frame.cpp Signed-off-by: Gabriel Ravier --- src/Frame.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index 2a148902..203a36c0 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -85,7 +85,7 @@ void MoveFrame3() gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200; #endif - //Quake + // Quake if (gFrame.quake2) { gFrame.x += (Random(-5, 5) * 0x200); @@ -114,18 +114,18 @@ void GetFramePosition(int *fx, int *fy) void SetFramePosition(int fx, int fy) { - //End quake + // End quake gFrame.quake = 0; gFrame.quake2 = 0; - //Move frame position + // Move frame position int16_t map_w, map_l; GetMapData(0, &map_w, &map_l); gFrame.x = fx; gFrame.y = fy; - //Keep in bounds + // Keep in bounds if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) @@ -139,7 +139,7 @@ void SetFramePosition(int fx, int fy) void SetFrameMyChar() { - //Move frame position + // Move frame position int mc_x, mc_y; GetMyCharPosition(&mc_x, &mc_y); @@ -149,7 +149,7 @@ void SetFrameMyChar() gFrame.x = mc_x - (WINDOW_WIDTH << 8); gFrame.y = mc_y - (WINDOW_HEIGHT << 8); - //Keep in bounds + // Keep in bounds if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) From e294162040ff91344460d8f3ca267f2e9577a370 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 8 May 2019 08:29:50 +0200 Subject: [PATCH 04/13] Fixed some comment formatting in Flags.cpp Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index c7e3d192..1b427919 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,7 +7,7 @@ unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; -//Flag inits +// Flag inits void InitFlags() { memset(gFlagNPC, 0, sizeof(gFlagNPC)); @@ -18,7 +18,7 @@ void InitSkipFlags() memset(gSkipFlag, 0, sizeof(gSkipFlag)); } -//NPC flags +// NPC flags void SetNPCFlag(long a) { gFlagNPC[a / 8] |= 1 << a % 8; @@ -37,7 +37,7 @@ BOOL GetNPCFlag(long a) return FALSE; } -//Skip flags +// Skip flags void SetSkipFlag(long a) { gSkipFlag[a / 8] |= 1 << a % 8; From 18ae3e6bf7874ceffeee78b2a764de2ea1343ef1 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Fri, 10 May 2019 09:15:31 +0200 Subject: [PATCH 05/13] Corrected technically orthographically false comment Signed-off-by: Gabriel Ravier --- src/Flags.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Flags.cpp b/src/Flags.cpp index 1b427919..f8a21181 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -7,7 +7,7 @@ unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; -// Flag inits +// Flag initializers void InitFlags() { memset(gFlagNPC, 0, sizeof(gFlagNPC)); From df119e69d767fa575696f1c6172ca9bf60fc2cdb Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 13 May 2019 14:19:58 +0200 Subject: [PATCH 06/13] 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 07/13] 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 08/13] 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 09/13] 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 45fb8940af5c82d41a131c2c1e4cc9e92c9fe6c3 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 14 May 2019 08:24:52 +0200 Subject: [PATCH 10/13] Correct style in Font.cpp Signed-off-by: Gabriel Ravier --- src/Font.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index 69f342c4..7e008530 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -1655,8 +1655,7 @@ static unsigned long UTF8ToUnicode(const unsigned char *string, unsigned int *by unsigned long charcode; unsigned int zero_bit = 0; - for (unsigned char lead_byte = string[0]; zero_bit < 5 && (lead_byte & 0x80); ++zero_bit, lead_byte <<= 1) - ; + for (unsigned char lead_byte = string[0]; zero_bit < 5 && (lead_byte & 0x80); ++zero_bit, lead_byte <<= 1); switch (zero_bit) { From ccb37e12b1f54c6dc24d29f8b4f696b28883f2cd Mon Sep 17 00:00:00 2001 From: Gabriel Ravier <31440290+GabrielRavier@users.noreply.github.com> Date: Tue, 14 May 2019 11:22:38 +0200 Subject: [PATCH 11/13] Remove space before commented out code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ಠ_ಠ Co-Authored-By: Clownacy --- src/Font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Font.cpp b/src/Font.cpp index 7e008530..915cd499 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -14,7 +14,7 @@ #include "File.h" // Uncomment for that authentic pre-Windows Vista feel -// #define DISABLE_FONT_ANTIALIASING +//#define DISABLE_FONT_ANTIALIASING #undef MIN #undef MAX From 92a2327187f9d0c3f5b2ed6948b0d832c7e2d58e Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 15 May 2019 13:25:13 +0200 Subject: [PATCH 12/13] 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 13/13] 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))