ref: 461d1cfda94fef71a893b7cf24a7e6565fe4cc19
parent: 5a2f98ece4c01ab02005ae9433447ab2781ce5d4
parent: b49d3acf2cf1329d5f678bf5c042bd4623d67e8a
author: Gabriel Ravier <[email protected]>
date: Wed May 15 17:31:50 EDT 2019
Merge pull request #21 from Clownacy/master Merge Clownacy/master into master
--- 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 @@
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;
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -85,7 +85,7 @@
gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
#endif
- //Quake
+ // Quake
if (gFrame.quake2)
{
gFrame.x += (Random(-5, 5) * 0x200);
@@ -114,11 +114,11 @@
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);
@@ -125,7 +125,7 @@
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 SetFrameMyChar()
{
- //Move frame position
+ // Move frame position
int mc_x, mc_y;
GetMyCharPosition(&mc_x, &mc_y);
@@ -149,7 +149,7 @@
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)