From 159bc5d869346ce3c4f213988e8cceffa47c12fa Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 4 Nov 2019 11:42:34 +0100 Subject: [PATCH 1/8] Documentation : Make operator priority clearer) 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 5012397c..65bf3521 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -6,9 +6,9 @@ // 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)) +#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 adc4f99c5a920363d22ef352bae5f9ce096c7e0c Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Thu, 12 Sep 2019 16:48:19 +0200 Subject: [PATCH 2/8] Remove the undefs in WindowsWrapper, as these have no purpose here (no collisions with accurate) Signed-off-by: Gabriel Ravier --- src/WindowsWrapper.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index e48f8dd1..47810b8d 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -1,10 +1,6 @@ #pragma once #include -// Avoid name collisions -#undef DrawText -#undef FindResource -#undef CreateWindow #define SET_RECT(rect, l, t, r, b) \ rect.left = l; \ From 3c920996b80ddbce6a431b862ee6fda2cef71ee5 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 10:43:09 +0100 Subject: [PATCH 3/8] Make memcmp usage clearer Signed-off-by: Gabriel Ravier --- src/Map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Map.cpp b/src/Map.cpp index 06ce24b0..dde99212 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -41,7 +41,7 @@ BOOL LoadMapData2(const char *path_map) char check[3]; fread(check, 1, 3, fp); - if (memcmp(check, code_pxma, 3)) + if (memcmp(check, code_pxma, 3) != 0) { fclose(fp); return FALSE; From 053770b81b4b09c0219b6da53c358d6280534c82 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Mon, 4 Nov 2019 09:50:23 +0100 Subject: [PATCH 4/8] Use "strcmp(a, b) != 0" so it's clearer what we're checking for Signed-off-by: Gabriel Ravier --- src/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config.cpp b/src/Config.cpp index 9c30d537..30b14d34 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -31,7 +31,7 @@ BOOL LoadConfigData(CONFIG *conf) fclose(fp); // Check if version is not correct, and return if it failed - if (fread_result != 1 || strcmp(conf->proof, config_magic)) + if (fread_result != 1 || strcmp(conf->proof, config_magic) != 0) { memset(conf, 0, sizeof(CONFIG)); return FALSE; From f96b7fa56607e73e80019c031a7095b9d02f9463 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 17:16:20 +0100 Subject: [PATCH 5/8] Use "memcmp(a, b) != 0" instead of "memcmp(a, b)" so it's clearer we're searching for a difference Signed-off-by: Gabriel Ravier --- src/NpChar.cpp | 2 +- src/Profile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 9e50f2b3..589eab8b 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -68,7 +68,7 @@ BOOL LoadEvent(const char *path_event) // Read "PXE" check char code[4]; fread(code, 1, 4, fp); - if (memcmp(code, gPassPixEve, 3)) + if (memcmp(code, gPassPixEve, 3) != 0) { #ifdef FIX_BUGS // The original game forgot to close the file here diff --git a/src/Profile.cpp b/src/Profile.cpp index 0f0cb37f..f9dc051c 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -104,7 +104,7 @@ BOOL LoadProfile(const char *name) // Check header code fread(profile.code, 8, 1, fp); - if (memcmp(profile.code, gProfileCode, 8)) + if (memcmp(profile.code, gProfileCode, 8) != 0) { #ifdef FIX_BUGS fclose(fp); // The original game forgets to close the file From bae879e3b592c89e6dd5f84fe8bd904e409786ed Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 17:27:04 +0100 Subject: [PATCH 6/8] Check "no" against MUS_SILENCE instead of converting it to a bool Signed-off-by: Gabriel Ravier --- src/Stage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stage.cpp b/src/Stage.cpp index e86dbfc7..0d626f14 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -252,7 +252,7 @@ MusicID gMusicNo; void ChangeMusic(MusicID no) { - if (no && no == gMusicNo) + if (no == MUS_SILENCE && no == gMusicNo) return; //Stop and keep track of old song From 571a7ca72373a25ced91bacd301e365b832a0a5b Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Tue, 5 Nov 2019 17:33:05 +0100 Subject: [PATCH 7/8] Bug : Put parentheses around IS_COMMAND and its parameters Signed-off-by: Gabriel Ravier --- src/TextScr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 8ba144ed..7e654a51 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -33,7 +33,7 @@ #include "Stage.h" #include "Tags.h" -#define IS_COMMAND(c1, c2, c3) gTS.data[gTS.p_read + 1] == c1 && gTS.data[gTS.p_read + 2] == c2 && gTS.data[gTS.p_read + 3] == c3 +#define IS_COMMAND(c1, c2, c3) (gTS.data[gTS.p_read + 1] == (c1) && gTS.data[gTS.p_read + 2] == (c2) && gTS.data[gTS.p_read + 3] == (c3)) #define TSC_BUFFER_SIZE 0x5000 From 401a8f0d4213e6464f1347b1053c669e054d3cc4 Mon Sep 17 00:00:00 2001 From: Gabriel Ravier Date: Wed, 6 Nov 2019 20:21:56 +0100 Subject: [PATCH 8/8] Bug : Fix wrong `==` to `!=` --- src/Stage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stage.cpp b/src/Stage.cpp index 0d626f14..b6076c33 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -252,7 +252,7 @@ MusicID gMusicNo; void ChangeMusic(MusicID no) { - if (no == MUS_SILENCE && no == gMusicNo) + if (no != MUS_SILENCE && no == gMusicNo) return; //Stop and keep track of old song