diff --git a/src/Flags.cpp b/src/Flags.cpp index c7e3d192..5012397c 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -4,10 +4,16 @@ #include "WindowsWrapper.h" +// 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)) + unsigned char gFlagNPC[1000]; unsigned char gSkipFlag[8]; -//Flag inits +// Flag initializers void InitFlags() { memset(gFlagNPC, 0, sizeof(gFlagNPC)); @@ -18,39 +24,39 @@ void InitSkipFlags() memset(gSkipFlag, 0, sizeof(gSkipFlag)); } -//NPC flags +// NPC flags void SetNPCFlag(long a) { - gFlagNPC[a / 8] |= 1 << a % 8; + SET_FLAG(gFlagNPC, a); } void CutNPCFlag(long a) { - gFlagNPC[a / 8] &= ~(1 << a % 8); + UNSET_FLAG(gFlagNPC, a); } BOOL GetNPCFlag(long a) { - if (gFlagNPC[a / 8] & (1 << a % 8)) + if (GET_FLAG(gFlagNPC, a)) return TRUE; else return FALSE; } -//Skip flags +// Skip flags void SetSkipFlag(long a) { - gSkipFlag[a / 8] |= 1 << a % 8; + SET_FLAG(gSkipFlag, a); } void CutSkipFlag(long a) { - gSkipFlag[a / 8] &= ~(1 << a % 8); + UNSET_FLAG(gSkipFlag, a); } BOOL GetSkipFlag(long a) { - if (gSkipFlag[a / 8] & (1 << a % 8)) + if (GET_FLAG(gSkipFlag, a)) return TRUE; else return FALSE; diff --git a/src/Frame.cpp b/src/Frame.cpp index d5b3589a..f50c17be 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 short 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)