Moved and renamed flag macros
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
parent
7f75ad6ef8
commit
a0f4bae094
1 changed files with 15 additions and 11 deletions
|
@ -7,11 +7,6 @@
|
||||||
unsigned char gFlagNPC[1000];
|
unsigned char gFlagNPC[1000];
|
||||||
unsigned char gSkipFlag[8];
|
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
|
//Flag inits
|
||||||
void InitFlags()
|
void InitFlags()
|
||||||
{
|
{
|
||||||
|
@ -23,20 +18,29 @@ void InitSkipFlags()
|
||||||
memset(gSkipFlag, 0, sizeof(gSkipFlag));
|
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
|
//NPC flags
|
||||||
void SetNPCFlag(long a)
|
void SetNPCFlag(long a)
|
||||||
{
|
{
|
||||||
SET_BIT(gFlagNPC, a);
|
SET_FLAG(gFlagNPC, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutNPCFlag(long a)
|
void CutNPCFlag(long a)
|
||||||
{
|
{
|
||||||
UNSET_BIT(gFlagNPC, a);
|
UNSET_FLAG(gFlagNPC, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GetNPCFlag(long a)
|
BOOL GetNPCFlag(long a)
|
||||||
{
|
{
|
||||||
if (GET_BIT(gFlagNPC, a))
|
if (GET_FLAG(gFlagNPC, a))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -45,17 +49,17 @@ BOOL GetNPCFlag(long a)
|
||||||
//Skip flags
|
//Skip flags
|
||||||
void SetSkipFlag(long a)
|
void SetSkipFlag(long a)
|
||||||
{
|
{
|
||||||
SET_BIT(gSkipFlag, a);
|
SET_FLAG(gSkipFlag, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutSkipFlag(long a)
|
void CutSkipFlag(long a)
|
||||||
{
|
{
|
||||||
UNSET_BIT(gSkipFlag, a);
|
UNSET_FLAG(gSkipFlag, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GetSkipFlag(long a)
|
BOOL GetSkipFlag(long a)
|
||||||
{
|
{
|
||||||
if (GET_BIT(gSkipFlag, a))
|
if (GET_FLAG(gSkipFlag, a))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue