From da3cb1dff79632a0d8663a73562286764d34b332 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 12 Dec 2013 23:22:42 +0000 Subject: [PATCH] [Fix] Fixed new player inheriting last loaded players faction standings. --- src/faction.c | 14 +++++++++++++- src/faction.h | 1 + src/land.c | 4 +++- src/player.c | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/faction.c b/src/faction.c index 771ba44..4364200 100644 --- a/src/faction.c +++ b/src/faction.c @@ -43,6 +43,7 @@ typedef struct Faction_ { int* allies; /**< Allies by ID of the faction. */ int nallies; /**< Number of allies. */ + int player_def; /**< Default player standing. */ int player; /**< Standing with player - from -100 to 100. */ } Faction; @@ -438,7 +439,7 @@ static Faction* faction_parse(xmlNodePtr parent) { do { /* Can be 0 or negative, so we have to take that into account. */ if(xml_isNode(node, "player")) { - tmp->player = xml_getInt(node); + tmp->player_def = xml_getInt(node); player = 1; continue; } @@ -497,6 +498,17 @@ static void faction_parseSocial(xmlNodePtr parent) { } while(xml_nextNode(node)); } +/** + * @fn void factions_reset(void) + * + * @brief Reset the players standing with the factions to default. + */ +void factions_reset(void) { + int i; + for(i = 0; i < faction_nstack; i++) + faction_stack[i].player = faction_stack[i].player_def; +} + /** * @fn int factions_load(void) * diff --git a/src/faction.h b/src/faction.h index 05500a1..7af5bd9 100644 --- a/src/faction.h +++ b/src/faction.h @@ -24,4 +24,5 @@ int areAllies(int a, int b); /* Load/Free. */ int factions_load(void); void factions_free(void); +void factions_reset(void); diff --git a/src/land.c b/src/land.c index 32b66d9..7e21904 100644 --- a/src/land.c +++ b/src/land.c @@ -1305,7 +1305,9 @@ void takeoff(void) { } /** - * @fn + * @fn void land_cleanup(void) + * + * @brief Cleans up some land-related variables. */ void land_cleanup(void) { /* Clean up default stuff. */ diff --git a/src/player.c b/src/player.c index ba4e41b..35bc5c0 100644 --- a/src/player.c +++ b/src/player.c @@ -243,6 +243,7 @@ void player_new(void) { space_clearKnown(); land_cleanup(); diff_clear(); + factions_reset(); player_name = dialogue_input("Player Name", 3, 20, "Please tell me your name:");