diff options
author | Bardur Arantsson <bardur@scientician.net> | 2017-05-02 19:20:57 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2017-05-02 19:20:57 +0200 |
commit | 598c5887ae589059e4f4a9801ff1e4f7f8385f00 (patch) | |
tree | b6b7a18919e7808b030ed10f7d5ea5eec407d28a | |
parent | 0f37adeca0e2facfcb32f30e285048fac23c8845 (diff) |
Move previous_char to Game struct
-rw-r--r-- | src/birth.cc | 41 | ||||
-rw-r--r-- | src/game.hpp | 6 | ||||
-rw-r--r-- | src/loadsave.cc | 4 | ||||
-rw-r--r-- | src/variable.cc | 5 | ||||
-rw-r--r-- | src/variable.hpp | 1 |
5 files changed, 27 insertions, 30 deletions
diff --git a/src/birth.cc b/src/birth.cc index 3b8c9fda..f18c87fa 100644 --- a/src/birth.cc +++ b/src/birth.cc @@ -177,8 +177,7 @@ void print_desc(cptr txt) */ static void save_prev_data(void) { - int i; - + auto &previous_char = game->previous_char; /*** Save the current data ***/ @@ -196,14 +195,14 @@ static void save_prev_data(void) previous_char.au = p_ptr->au; /* Save the stats */ - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { previous_char.stat[i] = p_ptr->stat_max[i]; } previous_char.luck = p_ptr->luck_base; /* Save the history */ - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { strcpy(previous_char.history[i], history[i]); } @@ -215,8 +214,7 @@ static void save_prev_data(void) */ static void load_prev_data(bool_ save) { - int i; - + auto &previous_char = game->previous_char; birther temp; @@ -226,14 +224,14 @@ static void load_prev_data(bool_ save) temp.au = p_ptr->au; /* Save the stats */ - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { temp.stat[i] = p_ptr->stat_max[i]; } temp.luck = p_ptr->luck_base; /* Save the history */ - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { strcpy(temp.history[i], history[i]); } @@ -245,7 +243,7 @@ static void load_prev_data(bool_ save) p_ptr->au = previous_char.au; /* Load the stats */ - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { p_ptr->stat_max[i] = previous_char.stat[i]; p_ptr->stat_cur[i] = previous_char.stat[i]; @@ -254,7 +252,7 @@ static void load_prev_data(bool_ save) p_ptr->luck_max = previous_char.luck; /* Load the history */ - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { strcpy(history[i], previous_char.history[i]); } @@ -267,14 +265,14 @@ static void load_prev_data(bool_ save) previous_char.au = temp.au; /* Save the stats */ - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { previous_char.stat[i] = temp.stat[i]; } previous_char.luck = temp.luck; /* Save the history */ - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { strcpy(previous_char.history[i], temp.history[i]); } @@ -1484,7 +1482,7 @@ static bool_ player_birth_aux_ask() /*** Quick Start ***/ - if (previous_char.quick_ok) + if (game->previous_char.quick_ok) { /* Choose */ while (1) @@ -1514,10 +1512,9 @@ static bool_ player_birth_aux_ask() /*** Player race ***/ - if (do_quick_start) { - k = previous_char.race; + k = game->previous_char.race; } else { @@ -1621,7 +1618,7 @@ static bool_ player_birth_aux_ask() /*** Player race mod ***/ if (do_quick_start) { - k = previous_char.rmod; + k = game->previous_char.rmod; p_ptr->pracem = k; rmp_ptr = &race_mod_info[p_ptr->pracem]; } @@ -1748,10 +1745,10 @@ static bool_ player_birth_aux_ask() /*** Player class ***/ if (do_quick_start) { - k = previous_char.pclass; + k = game->previous_char.pclass; p_ptr->pclass = k; cp_ptr = &class_info[p_ptr->pclass]; - k = previous_char.spec; + k = game->previous_char.spec; p_ptr->pspec = k; spp_ptr = &class_info[p_ptr->pclass].spec[p_ptr->pspec]; } @@ -1943,9 +1940,9 @@ static bool_ player_birth_aux_ask() /*** Player god ***/ if (do_quick_start) { - k = previous_char.god; + k = game->previous_char.god; p_ptr->pgod = k; - set_grace(previous_char.grace); + set_grace(game->previous_char.grace); } else if (race_flags_p(PR_NO_GOD)) { @@ -2120,7 +2117,7 @@ static bool_ player_birth_aux_ask() { if (do_quick_start) { - v = previous_char.quests; + v = game->previous_char.quests; } else { @@ -2895,7 +2892,7 @@ static bool_ player_birth_aux() } /* Save this for the next character */ - previous_char.quick_ok = TRUE; + game->previous_char.quick_ok = TRUE; save_prev_data(); /* Accept */ diff --git a/src/game.hpp b/src/game.hpp index 00a0c8d5..20ca0f86 100644 --- a/src/game.hpp +++ b/src/game.hpp @@ -2,6 +2,7 @@ #include "game_fwd.hpp" +#include "birther.hpp" #include "game_edit_data.hpp" #include "grid.hpp" #include "h-basic.h" @@ -30,6 +31,11 @@ struct Game { std::string died_from; /** + * Previous character + */ + birther previous_char; + + /** * Wilderness map */ grid<wilderness_map> wilderness; diff --git a/src/loadsave.cc b/src/loadsave.cc index 6e7ae7ff..ad824536 100644 --- a/src/loadsave.cc +++ b/src/loadsave.cc @@ -385,7 +385,7 @@ static void do_seed(seed_t *seed, ls_flag_t flag) /* * Load/Save quick start data */ -static void do_quick_start(ls_flag_t flag) +static void do_quick_start(ls_flag_t flag, birther &previous_char) { do_s16b(&previous_char.race, flag); do_s16b(&previous_char.rmod, flag); @@ -567,7 +567,7 @@ static bool_ do_extra(ls_flag_t flag) do_bool(&generate_special_feeling, flag); /* Load the quick start data */ - do_quick_start(flag); + do_quick_start(flag, game->previous_char); /* Load/save the special subrace */ do_subrace(flag); diff --git a/src/variable.cc b/src/variable.cc index 32f3bbc7..8395a75e 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -623,11 +623,6 @@ bool_ generate_special_feeling = FALSE; DECLARE_FLAG_ZERO_IMPL(dungeon_flag_set, dungeon_flags); /* - * The last character displayed - */ -birther previous_char; - -/* * The spell list of schools */ s16b schools_count = 0; diff --git a/src/variable.hpp b/src/variable.hpp index a752b3f1..a4678bae 100644 --- a/src/variable.hpp +++ b/src/variable.hpp @@ -179,7 +179,6 @@ extern random_quest random_quests[MAX_RANDOM_QUEST]; extern bool_ *special_lvl[MAX_DUNGEON_DEPTH]; extern bool_ generate_special_feeling; DECLARE_FLAG_ZERO_INTF(dungeon_flag_set, dungeon_flags); -extern birther previous_char; extern s16b schools_count; extern school_type schools[SCHOOLS_MAX]; extern int project_time; |