diff --git a/src/faction.c b/src/faction.c index 0049887..236f2db 100644 --- a/src/faction.c +++ b/src/faction.c @@ -25,6 +25,11 @@ #define CHUNK_SIZE 32 /**< Size of chunk for allocation. */ +#define FACTION_STATIC (1<<0) /**< Faction doesn't change standing with player. */ + +#define faction_setFlag(fa, f) ((fa)->flags |= (f)) +#define faction_isFlag(fa, f) ((fa)->flags & (f)) + /** * @struct Faction. * @@ -47,6 +52,8 @@ typedef struct Faction_ { double player_def; /**< Default player standing. */ double player; /**< Standing with player - from -100 to 100. */ + + unsigned int flags; /**< Flags affecting the faction. */ } Faction; static Faction* faction_stack = NULL; /**< Faction stack. */ @@ -195,6 +202,10 @@ void faction_modPlayer(int f, double mod) { faction = &faction_stack[f]; + /* Make sure it's not static. */ + if(faction_isFlag(faction, FACTION_STATIC)) + return; + /* Faction in question gets direct increment. */ faction->player += mod; faction_sanitizePlayer(faction); @@ -245,6 +256,10 @@ void faction_modPlayerRaw(int f, double mod) { faction = &faction_stack[f]; + /* Make sure it's not static. */ + if(faction_isFlag(faction, FACTION_STATIC)) + return; + faction->player += mod; faction_sanitizePlayer(faction); } @@ -495,6 +510,11 @@ static int faction_parse(Faction* tmp, xmlNodePtr parent) { tmp->logo_small = gl_newImage(buf, 0); continue; } + + if(xml_isNode(node, "static")) { + faction_setFlag(tmp, FACTION_STATIC); + continue; + } } while(xml_nextNode(node)); if(player == 0) WARN("Faction '%s' missing player tag", tmp->name);