Less bitfucking:

* Don't store whether a research item is possible in a bitflag; use a boolean instead
 * Use functions instead of macros to access research->possible

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4872 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-05-01 20:00:13 +00:00
parent 43fb7d845a
commit 507a1a6da2
2 changed files with 13 additions and 4 deletions

View File

@ -10420,7 +10420,7 @@ static BOOL writeResearchFile(char *pFileName)
for (player = 0; player < MAX_PLAYERS; player++)
{
psSaveResearch->possible[player] = (UBYTE)IsResearchPossible(&asPlayerResList[player][i]);
psSaveResearch->possible[player] = IsResearchPossible(&asPlayerResList[player][i]);
psSaveResearch->researched[player] = (UBYTE)(asPlayerResList[player][i].ResearchStatus&RESBITS);
psSaveResearch->currentPoints[player] = asPlayerResList[player][i].currentPoints;
}

View File

@ -24,6 +24,8 @@
#ifndef __INCLUDED_RESEARCHDEF_H__
#define __INCLUDED_RESEARCHDEF_H__
#include "lib/framework/frame.h"
/* Research struct type definitions */
typedef enum
{
@ -92,6 +94,7 @@ typedef struct _player_research
UBYTE ResearchStatus; // Bit flags ... see below
bool possible; ///< is the research possible ... so can enable topics vis scripts
// UBYTE possible; /* Flag to specify whether the research is possible - so
@ -104,11 +107,17 @@ typedef struct _player_research
#define CANCELLED_RESEARCH 0x02 // research has been canceled
#define RESEARCHED 0x04 // research is complete
#define RESBITS (STARTED_RESEARCH|CANCELLED_RESEARCH|RESEARCHED)
#define POSSIBLE 0x80 // is the research possible ... so can enable topics vis scripts
static inline bool IsResearchPossible(const PLAYER_RESEARCH* research)
{
return research->possible;
}
static inline void MakeResearchPossible(PLAYER_RESEARCH* research)
{
research->possible = true;
}
#define IsResearchPossible(x) ((x)->ResearchStatus&POSSIBLE)
#define MakeResearchPossible(x) ((x)->ResearchStatus|=POSSIBLE)
#define IsResearchCompleted(x) ((x)->ResearchStatus&RESEARCHED)
#define MakeResearchCompleted(x) ((x)->ResearchStatus=((x)->ResearchStatus&(~RESBITS))|RESEARCHED )