Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
masks.h File Reference

Go to the source code of this file.

Functions

bool checkbit (int &, int)
 
void dosetbit (int &, int)
 
void unsetbit (int &, int)
 
void flipbit (int &, int)
 
float Delta (float a, float b)
 

Function Documentation

bool checkbit ( int ,
int   
)

Definition at line 3 of file masks.cpp.

Referenced by NavigationSystem::Draw(), NavigationSystem::DrawButton(), NavigationSystem::DrawObjectives(), NavigationSystem::DrawSystem(), navscreenoccupied::findfreefloat(), and flipbit().

4 {
5  if ( (bit_number > 31) || (bit_number < 0) )
6  return 0;
7  if ( ( number&(1<<bit_number) ) != 0 )
8  return 1;
9 
10  else
11  return 0;
12 }
float Delta ( float  a,
float  b 
)

Definition at line 43 of file masks.cpp.

References b.

Referenced by Opcode::SAP_PairData::AddPair(), drawlistitem(), NavigationSystem::DrawMission(), OPC_PointAABBSqrDist(), and NavigationSystem::TestIfInRangeBlk().

44 {
45  float ans = a-b;
46  if (ans < 0)
47  return -1.0*ans;
48  else
49  return ans;
50 }
void dosetbit ( int ,
int   
)

Definition at line 14 of file masks.cpp.

Referenced by NavigationSystem::DrawButton(), navscreenoccupied::findfreefloat(), flipbit(), and NavigationSystem::ParseFile().

15 {
16  if ( (bit_number > 31) || (bit_number < 0) )
17  return;
18  number = ( number|(1<<bit_number) );
19 }
void flipbit ( int ,
int   
)

Definition at line 33 of file masks.cpp.

References checkbit(), dosetbit(), and unsetbit().

Referenced by NavigationSystem::DrawButton().

34 {
35  if ( (bit_number > 31) || (bit_number < 0) )
36  return;
37  if (checkbit( number, bit_number ) == 1)
38  unsetbit( number, bit_number );
39  else
40  dosetbit( number, bit_number );
41 }
void unsetbit ( int ,
int   
)

Definition at line 21 of file masks.cpp.

Referenced by NavigationSystem::ClearPriorities(), NavigationSystem::DrawButton(), NavigationSystem::DrawSystem(), flipbit(), and NavigationSystem::Setup().

22 {
23  if ( (bit_number > 31) || (bit_number < 0) )
24  return;
25  int temp = 0;
26  if (bit_number != 0)
27  temp = ( ( 0xffffffff<<(bit_number+1) )|( 0xffffffff>>(32-bit_number) ) );
28  else
29  temp = ( 0xffffffff<<(bit_number+1) );
30  number = number&temp;
31 }