[Fix] Fixed new player inheriting last loaded players faction standings.

This commit is contained in:
Allanis 2013-12-12 23:22:42 +00:00
parent 313e3a7488
commit da3cb1dff7
4 changed files with 18 additions and 2 deletions

View File

@ -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)
*

View File

@ -24,4 +24,5 @@ int areAllies(int a, int b);
/* Load/Free. */
int factions_load(void);
void factions_free(void);
void factions_reset(void);

View File

@ -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. */

View File

@ -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:");