summaryrefslogtreecommitdiff
path: root/src/birth.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/birth.cc')
-rw-r--r--src/birth.cc363
1 files changed, 180 insertions, 183 deletions
diff --git a/src/birth.cc b/src/birth.cc
index f677e6e1..c29f7eed 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -14,7 +14,6 @@
#include "cmd5.hpp"
#include "dungeon_flag.hpp"
#include "dungeon_info_type.hpp"
-#include "files.h"
#include "files.hpp"
#include "game.hpp"
#include "gods.hpp"
@@ -48,20 +47,24 @@
#include "tables.hpp"
#include "town_type.hpp"
#include "util.hpp"
-#include "util.h"
-#include "variable.h"
#include "variable.hpp"
#include "wilderness_map.hpp"
#include "xtra1.hpp"
#include "xtra2.hpp"
+#include "z-form.hpp"
#include "z-rand.hpp"
+#include "z-util.hpp"
#include <algorithm>
+#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
+#include <fcntl.h>
#include <fmt/format.h>
#include <numeric>
#include <string>
+using boost::algorithm::equals;
+
/*
* How often the autoroller will update the display and pause
* to check for user interuptions.
@@ -149,7 +152,7 @@ static std::string create_random_name()
}
-void print_desc_aux(cptr txt, int y, int xx)
+void print_desc_aux(const char *txt, int y, int xx)
{
int i = -1, x = xx;
@@ -168,7 +171,7 @@ void print_desc_aux(cptr txt, int y, int xx)
}
}
-void print_desc(cptr txt)
+void print_desc(const char *txt)
{
print_desc_aux(txt, 12, 1);
}
@@ -207,7 +210,7 @@ static void save_prev_data()
/*
* Load the previous data
*/
-static void load_prev_data(bool_ save)
+static void load_prev_data(bool save)
{
auto &previous_char = game->previous_char;
birther temp;
@@ -265,7 +268,7 @@ static void load_prev_data(bool_ save)
*
* The "p_ptr->maximize" code is important -BEN-
*/
-static int adjust_stat(int value, int amount, int auto_roll)
+static int adjust_stat(int value, int amount)
{
int i;
@@ -330,7 +333,7 @@ static void get_stats()
/* Roll and verify some stats */
- while (TRUE)
+ while (true)
{
/* Roll some dice */
for (j = i = 0; i < 18; i++)
@@ -484,7 +487,7 @@ static errr init_randart()
ra.name_full = get_line("rart_f.txt", ANGBAND_DIR_FILE, buf, i);
ra.attr = randint(15);
ra.activation = rand_int(MAX_T_ACT);
- ra.generated = FALSE;
+ ra.generated = false;
ra.cost = cost;
// Push
@@ -630,16 +633,11 @@ static void player_wipe()
}
/* Reset the "objects" */
- for (auto &k_ref: k_info)
+ for (auto &k_entry: k_info)
{
- /* Reset "tried" */
- k_ref.tried = FALSE;
-
- /* Reset "aware" */
- k_ref.aware = FALSE;
-
- /* Reset "artifact" */
- k_ref.artifact = 0;
+ auto k_ptr = k_entry.second;
+ k_ptr->aware = false;
+ k_ptr->artifact = false;
}
@@ -661,7 +659,7 @@ static void player_wipe()
r_ptr->r_pkills = 0;
/* Clear saved flag */
- r_ptr->on_saved = FALSE;
+ r_ptr->on_saved = false;
}
@@ -673,30 +671,30 @@ static void player_wipe()
/* Assume no winning game */
total_winner = 0;
- has_won = FALSE;
+ has_won = false;
/* Assume no cheating */
noscore = 0;
- wizard = 0;
+ wizard = false;
/* Clear the fate */
for (std::size_t i = 0; i < MAX_FATES; i++)
{
fates[i].fate = 0;
}
- p_ptr->no_mortal = FALSE;
+ p_ptr->no_mortal = false;
/* Player don't have the black breath from the beginning !*/
- p_ptr->black_breath = FALSE;
+ p_ptr->black_breath = false;
/* Default pet command settings */
p_ptr->pet_follow_distance = 6;
- p_ptr->pet_open_doors = FALSE;
- p_ptr->pet_pickup_items = FALSE;
+ p_ptr->pet_open_doors = false;
+ p_ptr->pet_pickup_items = false;
/* Body changing initialisation */
p_ptr->body_monster = 0;
- p_ptr->disembodied = FALSE;
+ p_ptr->disembodied = false;
/* Wipe xtra hp */
p_ptr->hp_mod = 0;
@@ -719,18 +717,15 @@ static void player_wipe()
inscription_known = false;
}
- /* Reset wild_mode to FALSE */
- p_ptr->wild_mode = FALSE;
- p_ptr->old_wild_mode = FALSE;
+ /* Reset wild_mode to false */
+ p_ptr->wild_mode = false;
+ p_ptr->old_wild_mode = false;
/* Initialize allow_one_death */
p_ptr->allow_one_death = 0;
/* Wipe the power list */
- for (std::size_t i = 0; i < POWER_MAX; i++)
- {
- p_ptr->powers_mod[i] = 0;
- }
+ p_ptr->powers_mod.clear();
/* No companions killed */
p_ptr->companion_killed = 0;
@@ -762,12 +757,9 @@ static void outfit_obj(object_proto const *proto)
}
/* These objects are "storebought" */
- q_ptr->ident |= IDENT_MENTAL;
q_ptr->number = damroll(proto->dd, proto->ds);
- object_aware(q_ptr);
- object_known(q_ptr);
- inven_carry(q_ptr, FALSE);
+ inven_carry(q_ptr, false);
}
@@ -789,23 +781,27 @@ static void player_outfit_object(int qty, int tval, int sval)
object_type *q_ptr = &forge;
object_prep(q_ptr, lookup_kind(tval, sval));
q_ptr->number = qty;
- object_aware(q_ptr);
- object_known(q_ptr);
- inven_carry(q_ptr, FALSE);
+ inven_carry(q_ptr, false);
}
/*
* Give player a spell book.
*/
-static void player_outfit_spellbook(cptr spell_name)
+static void player_outfit_spellbook(const char *spell_name)
{
- object_type forge;
- object_type *q_ptr = &forge;
- object_prep(q_ptr, lookup_kind(TV_BOOK, 255));
- q_ptr->pval = find_spell(spell_name);
- q_ptr->ident |= IDENT_MENTAL | IDENT_KNOWN;
- inven_carry(q_ptr, FALSE);
+ if (auto spell_idx = find_spell(spell_name))
+ {
+ object_type forge;
+ object_type *q_ptr = &forge;
+ object_prep(q_ptr, lookup_kind(TV_BOOK, 255));
+ q_ptr->pval = *spell_idx;
+ inven_carry(q_ptr, false);
+ }
+ else
+ {
+ quit_fmt("Couldn't find spell '%s'\n");
+ }
}
@@ -817,7 +813,7 @@ static void player_outfit_spellbook(cptr spell_name)
static void player_outfit()
{
// Shorthand names for convenience
- cptr class_name = spp_ptr->title;
+ const char *class_name = spp_ptr->title;
auto const &subrace_name = rmp_ptr->title;
/*
@@ -834,51 +830,51 @@ static void player_outfit()
*/
if (game_module_idx == MODULE_TOME)
{
- if (streq(class_name, "Ranger"))
+ if (equals(class_name, "Ranger"))
{
player_outfit_spellbook("Phase Door");
}
}
- if (streq(class_name, "Geomancer"))
+ if (equals(class_name, "Geomancer"))
{
player_outfit_spellbook("Geyser");
}
- if (streq(class_name, "Priest(Eru)"))
+ if (equals(class_name, "Priest(Eru)"))
{
player_outfit_spellbook("See the Music");
}
- if (streq(class_name, "Priest(Manwe)"))
+ if (equals(class_name, "Priest(Manwe)"))
{
player_outfit_spellbook("Manwe's Blessing");
}
- if (streq(class_name, "Druid"))
+ if (equals(class_name, "Druid"))
{
player_outfit_spellbook("Charm Animal");
}
- if (streq(class_name, "Dark-Priest"))
+ if (equals(class_name, "Dark-Priest"))
{
player_outfit_spellbook("Curse");
}
- if (streq(class_name, "Paladin"))
+ if (equals(class_name, "Paladin"))
{
player_outfit_spellbook("Divine Aim");
}
if (game_module_idx == MODULE_THEME)
{
/* Priests */
- if (streq(class_name, "Stonewright"))
+ if (equals(class_name, "Stonewright"))
{
player_outfit_spellbook("Firebrand");
}
- if (streq(class_name, "Priest(Varda)"))
+ if (equals(class_name, "Priest(Varda)"))
{
player_outfit_spellbook("Light of Valinor");
}
- if (streq(class_name, "Priest(Ulmo)"))
+ if (equals(class_name, "Priest(Ulmo)"))
{
player_outfit_spellbook("Song of Belegaer");
}
- if (streq(class_name, "Priest(Mandos)"))
+ if (equals(class_name, "Priest(Mandos)"))
{
player_outfit_spellbook("Tears of Luthien");
}
@@ -920,36 +916,32 @@ static void player_outfit()
}
/* Peace-mages */
- if (streq(class_name, "Peace-mage"))
+ if (equals(class_name, "Peace-mage"))
{
player_outfit_spellbook("Phase Door");
}
/* Wainriders */
- if (streq(class_name, "Wainrider"))
+ if (equals(class_name, "Wainrider"))
{
player_outfit_spellbook("Curse");
}
}
- if (streq(class_name, "Mimic"))
+ if (equals(class_name, "Mimic"))
{
object_type forge;
object_type *q_ptr = &forge;
object_prep(q_ptr, lookup_kind(TV_CLOAK, SV_MIMIC_CLOAK));
q_ptr->pval2 = resolve_mimic_name("Mouse");
- q_ptr->ident |= IDENT_MENTAL | IDENT_KNOWN;
- inven_carry(q_ptr, FALSE);
+ inven_carry(q_ptr, false);
}
if (game_module_idx == MODULE_THEME)
{
/* Give everyone a scroll of WoR. */
player_outfit_object(1, TV_SCROLL, SV_SCROLL_WORD_OF_RECALL);
-
- /* Identify everything in pack. */
- identify_pack_fully();
}
if (rmp_ptr->title == "Vampire")
@@ -975,9 +967,7 @@ static void player_outfit()
object_prep(q_ptr, lookup_kind(TV_LITE, SV_LITE_TORCH));
q_ptr->number = (byte)rand_range(3, 7);
q_ptr->timeout = rand_range(3, 7) * 500;
- object_aware(q_ptr);
- object_known(q_ptr);
- inven_carry(q_ptr, FALSE);
+ inven_carry(q_ptr, false);
}
/* Outfit the player with starting items */
@@ -1001,7 +991,7 @@ static void dump_classes(std::vector<u16b> const &classes, int sel, u32b *restri
for (int n = 0; n < n_max; n++)
{
- cptr mod = "";
+ const char *mod = "";
char p2 = ')', p1 = ' ';
/* Analyze */
@@ -1240,7 +1230,7 @@ static int dump_gods(int sel, int *choice, int max)
{
int i, j;
char buf[80];
- cptr str;
+ const char *str;
/* Clean up */
clear_from(12);
@@ -1277,10 +1267,17 @@ static int dump_gods(int sel, int *choice, int max)
{
/* Display the first four lines of the god description */
for (j = 0; j < 4; j++)
- if (strcmp(g_ptr->desc[j], ""))
+ {
+ if (!equals(g_ptr->desc[j], ""))
+ {
print_desc_aux(g_ptr->desc[j], 12 + j, 1);
+ }
+ }
+ }
+ else
+ {
+ print_desc("You can begin as an atheist and still convert to a god later.");
}
- else print_desc("You can begin as an atheist and still convert to a god later.");
c_put_str(TERM_L_BLUE, buf, 20 + (i / 4), 1 + 20 * (i % 4));
}
@@ -1293,11 +1290,9 @@ static int dump_gods(int sel, int *choice, int max)
return (max);
}
+static bool do_quick_start = false;
-/* Ask questions */
-static bool_ do_quick_start = FALSE;
-
-static bool_ player_birth_aux_ask()
+static bool player_birth_aux_ask()
{
auto &class_info = game->edit_data.class_info;
auto const &race_info = game->edit_data.race_info;
@@ -1350,20 +1345,20 @@ static bool_ player_birth_aux_ask()
if (game->previous_char.quick_ok)
{
/* Choose */
- while (1)
+ while (true)
{
put_str("Use same character as last time (y/n)? ", 20, 2);
c = inkey();
if (c == 'Q') quit(NULL);
- else if (c == 'S') return (FALSE);
+ else if (c == 'S') return false;
else if ((c == 'y') || (c == 'Y'))
{
- do_quick_start = TRUE;
+ do_quick_start = true;
break;
}
else
{
- do_quick_start = FALSE;
+ do_quick_start = false;
break;
}
}
@@ -1399,7 +1394,7 @@ static bool_ player_birth_aux_ask()
n = dump_races(sel);
/* Choose */
- while (1)
+ while (true)
{
strnfmt(buf, 200, "Choose a race (%c-%c), * for a random choice, = for options, 8/2/4/6 for movement: ",
I2A(0), I2A(race_info.size() - 1));
@@ -1407,7 +1402,7 @@ static bool_ player_birth_aux_ask()
c = inkey();
if (c == 'Q') quit(NULL);
- if (c == 'S') return (FALSE);
+ if (c == 'S') return false;
if (c == '*')
{
k = rand_int(race_info.size());
@@ -1422,7 +1417,7 @@ static bool_ player_birth_aux_ask()
else if (c == '=')
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
else if (c == '2')
@@ -1528,14 +1523,14 @@ static bool_ player_birth_aux_ask()
n = dump_rmods(sel, racem, max_racem);
/* Choose */
- while (1)
+ while (true)
{
strnfmt(buf, 200, "Choose a race modifier (%c-%c), * for a random choice, = for options: ",
I2A(0), I2A(max_racem - 1));
put_str(buf, 17, 2);
c = inkey();
if (c == 'Q') quit(NULL);
- if (c == 'S') return (FALSE);
+ if (c == 'S') return false;
if (c == '*')
{
// Which choices are legal?
@@ -1565,7 +1560,7 @@ static bool_ player_birth_aux_ask()
else if (c == '=')
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
else if (c == '2')
@@ -1663,13 +1658,13 @@ static bool_ player_birth_aux_ask()
dump_classes(class_types, sel, restrictions);
/* Get a class */
- while (1)
+ while (true)
{
strnfmt(buf, 200, "Choose a class (%c-%c), * for random, = for options, 8/2/4 for up/down/back: ", I2A(0), (n <= 25) ? I2A(n - 1) : I2D(n - 26-1));
put_str(buf, 15, 2);
c = inkey();
if (c == 'Q') quit(NULL);
- if (c == 'S') return (FALSE);
+ if (c == 'S') return false;
if (c == '*')
{
k = randint(n) - 1;
@@ -1684,7 +1679,7 @@ static bool_ player_birth_aux_ask()
else if (c == '=')
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
else if (c == '2')
@@ -1741,13 +1736,13 @@ static bool_ player_birth_aux_ask()
dump_specs(sel);
/* Get a class */
- while (1)
+ while (true)
{
strnfmt(buf, 200, "Choose a class specialisation (%c-%c), * for random, = for options, 8/2/4/6 for up/down/left/right: ", I2A(0), (n <= 25) ? I2A(n - 1) : I2D(n - 26-1));
put_str(buf, 15, 2);
c = inkey();
if (c == 'Q') quit(NULL);
- if (c == 'S') return (FALSE);
+ if (c == 'S') return false;
if (c == '*')
{
k = randint(n) - 1;
@@ -1762,7 +1757,7 @@ static bool_ player_birth_aux_ask()
else if (c == '=')
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
else if (c == '2')
@@ -1850,7 +1845,7 @@ static bool_ player_birth_aux_ask()
n = dump_gods(sel, choice, max);
/* Choose */
- while (1)
+ while (true)
{
strnfmt(buf, 200, "Choose a god (%c-%c), * for a random choice, "
"= for options, 8/2/4/6 for movement: ",
@@ -1861,7 +1856,7 @@ static bool_ player_birth_aux_ask()
if (c == 'Q') quit(NULL);
if (c == 'S')
{
- return (FALSE);
+ return false;
}
if (c == '*')
{
@@ -1881,7 +1876,7 @@ static bool_ player_birth_aux_ask()
else if (c == '=')
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
else if (c == '2')
@@ -1946,13 +1941,13 @@ static bool_ player_birth_aux_ask()
if (get_check("Do you want to modify the options"))
{
screen_save();
- do_cmd_options_aux(6, "Startup Options", FALSE);
+ do_cmd_options_aux(6, "Startup Options", false);
screen_load();
}
}
/* Is the player an "astral" being? */
- p_ptr->astral = (race_flags_p(PR_ASTRAL)) ? TRUE : FALSE;
+ p_ptr->astral = race_flags_p(PR_ASTRAL);
/*
* A note by pelpel. (remove this please)
@@ -2001,13 +1996,13 @@ static bool_ player_birth_aux_ask()
"If you do not want any optional quests, enter 0.");
/* Ask the number of additional quests */
- while (TRUE)
+ while (true)
{
put_str(format("Number of quests? (0-%u) ",
MAX_RANDOM_QUEST - 1), 20, 2);
/* Get a the number of additional quest */
- while (TRUE)
+ while (true)
{
/* Move the cursor */
put_str("", 20, 27);
@@ -2038,7 +2033,7 @@ static bool_ player_birth_aux_ask()
}
/* Set the quest monster hook */
- get_mon_num_hook = monster_quest;
+ get_monster_hook = monster_quest;
/* Prepare allocation table */
get_mon_num_prep();
@@ -2075,7 +2070,7 @@ static bool_ player_birth_aux_ask()
quest_random_init_hook();
/* Ok */
- return (TRUE);
+ return true;
}
@@ -2104,7 +2099,7 @@ static const int birth_stat_costs[(18-10) + 1] =
*
* Taken from V 2.9.0
*/
-static bool_ player_birth_aux_point()
+static bool player_birth_aux_point()
{
int i;
@@ -2139,7 +2134,7 @@ static bool_ player_birth_aux_point()
p_ptr->luck_max = p_ptr->luck_base;
/* Interact */
- while (1)
+ while (true)
{
/* Reset cost */
cost = 0;
@@ -2214,7 +2209,7 @@ static bool_ player_birth_aux_point()
if (ch == 'Q') quit(NULL);
/* Start over */
- if (ch == 'S') return (FALSE);
+ if (ch == 'S') return false;
/* Done */
if (ch == ESCAPE) break;
@@ -2246,19 +2241,17 @@ static bool_ player_birth_aux_point()
/* Done */
- return (TRUE);
+ return true;
}
/*
* Use the autoroller or not to generate a char
*/
-static bool_ player_birth_aux_auto()
+static bool player_birth_aux_auto()
{
int i, j, m, v;
- bool_ flag = FALSE;
-
- bool_ prev = FALSE;
+ bool prev = false;
char c;
@@ -2299,7 +2292,7 @@ static bool_ player_birth_aux_auto()
j = rp_ptr->ps.adj[i] + rmp_ptr->ps.adj[i] + cp_ptr->ps.adj[i];
/* Obtain the "maximal" stat */
- m = adjust_stat(17, j, TRUE);
+ m = adjust_stat(17, j);
/* Save the maximum */
@@ -2321,7 +2314,7 @@ static bool_ player_birth_aux_auto()
for (i = 0; i < 6; i++)
{
/* Get a minimum stat */
- while (TRUE)
+ while (true)
{
char *s;
@@ -2372,7 +2365,7 @@ static bool_ player_birth_aux_auto()
}
/* Roll */
- while (TRUE)
+ while (true)
{
/* Feedback */
if (options->autoroll)
@@ -2417,7 +2410,7 @@ static bool_ player_birth_aux_auto()
/* Auto-roll */
while (options->autoroll)
{
- bool_ accept = TRUE;
+ bool accept = true;
/* Get a new character */
get_stats();
@@ -2440,7 +2433,7 @@ static bool_ player_birth_aux_auto()
/* This stat is not okay */
else
{
- accept = FALSE;
+ accept = false;
}
}
@@ -2448,7 +2441,7 @@ static bool_ player_birth_aux_auto()
if (accept) break;
/* Take note every 25 rolls */
- flag = (!(auto_round % AUTOROLLER_STEP));
+ bool flag = (!(auto_round % AUTOROLLER_STEP));
/* Update display occasionally */
if (flag || (auto_round < last_round + 100))
@@ -2480,7 +2473,7 @@ static bool_ player_birth_aux_auto()
get_money();
/* Input loop */
- while (TRUE)
+ while (true)
{
/* Calculate the bonuses and hitpoints */
p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_BODY);
@@ -2512,7 +2505,7 @@ static bool_ player_birth_aux_auto()
if (c == 'Q') quit(NULL);
/* Start over */
- if (c == 'S') return (FALSE);
+ if (c == 'S') return false;
/* Escape accepts the roll */
if (c == ESCAPE) break;
@@ -2523,7 +2516,7 @@ static bool_ player_birth_aux_auto()
/* Previous character */
if (prev && (c == 'p'))
{
- load_prev_data(TRUE);
+ load_prev_data(true);
continue;
}
@@ -2545,13 +2538,13 @@ static bool_ player_birth_aux_auto()
save_prev_data();
/* Note that a previous roll exists */
- prev = TRUE;
+ prev = true;
}
/* Clear prompt */
clear_from(23);
- return (TRUE);
+ return true;
}
@@ -2562,7 +2555,7 @@ static bool_ player_birth_aux_auto()
* from continuously rolling up characters, which can be VERY
* expensive CPU wise. And it cuts down on player stupidity.
*/
-static bool_ player_birth_aux()
+static bool player_birth_aux()
{
auto const &s_descriptors = game->edit_data.s_descriptors;
auto &s_info = game->s_info;
@@ -2570,7 +2563,10 @@ static bool_ player_birth_aux()
char c;
/* Ask */
- if (!player_birth_aux_ask()) return (FALSE);
+ if (!player_birth_aux_ask())
+ {
+ return false;
+ }
for (std::size_t i = 1; i < s_descriptors.size(); i++)
{
@@ -2606,7 +2602,7 @@ static bool_ player_birth_aux()
if (do_quick_start)
{
- load_prev_data(FALSE);
+ load_prev_data(false);
/* Roll for base hitpoints */
get_extra();
@@ -2628,12 +2624,12 @@ static bool_ player_birth_aux()
/* Point based */
if (options->point_based)
{
- if (!player_birth_aux_point()) return FALSE;
+ if (!player_birth_aux_point()) return false;
}
/* Auto-roll */
else
{
- if (!player_birth_aux_auto()) return FALSE;
+ if (!player_birth_aux_auto()) return false;
}
/*** Finish up ***/
@@ -2649,18 +2645,24 @@ static bool_ player_birth_aux()
c = inkey();
/* Quit */
- if (c == 'Q') quit(NULL);
+ if (c == 'Q')
+ {
+ quit(NULL);
+ }
/* Start over */
- if (c == 'S') return (FALSE);
+ if (c == 'S')
+ {
+ return false;
+ }
}
/* Save this for the next character */
- game->previous_char.quick_ok = TRUE;
+ game->previous_char.quick_ok = true;
save_prev_data();
/* Accept */
- return (TRUE);
+ return true;
}
@@ -2697,7 +2699,7 @@ void player_birth()
std::size_t rtown = TOWN_RANDOM;
/* Create a new character */
- while (1)
+ while (true)
{
/* Wipe the player */
player_wipe();
@@ -2710,7 +2712,7 @@ void player_birth()
p_ptr->skill_points = 0;
p_ptr->skill_last_level = 1;
- recalc_skills(FALSE);
+ recalc_skills(false);
/* grab level 1 abilities */
p_ptr->abilities.clear();
@@ -2720,7 +2722,7 @@ void player_birth()
{
byte i = p_ptr->pgod;
p_ptr->pgod = 0;
- follow_god(i, TRUE);
+ follow_god(i, true);
}
/* Select the default melee type */
@@ -2761,9 +2763,9 @@ void player_birth()
d_ptr->t_idx[num] = rtown;
rtown++;
- while (TRUE)
+ while (true)
{
- bool_ ok = TRUE;
+ bool ok = true;
lev = rand_range(d_ptr->mindepth, d_ptr->maxdepth - 1);
@@ -2772,12 +2774,15 @@ void player_birth()
{
if (d_ptr->t_level[j] == lev)
{
- ok = FALSE;
+ ok = false;
}
}
/* Ok found one */
- if (ok) break;
+ if (ok)
+ {
+ break;
+ }
}
d_ptr->t_level[num] = lev;
@@ -2802,7 +2807,7 @@ void player_birth()
for (std::size_t i = 1; i < max_towns; i++)
{
/* Not destroyed ! yet .. ;) */
- town_info[i].destroyed = FALSE;
+ town_info[i].destroyed = false;
/* Ignore non-existent towns */
if (!(town_info[i].flags & (TOWN_REAL))) continue;
@@ -2826,7 +2831,7 @@ void player_birth()
auto &w = wilderness(x, y);
w.seed = seed_t::system();
w.entrance = 0;
- w.known = FALSE;
+ w.known = false;
}
}
}
@@ -2837,7 +2842,7 @@ void player_birth()
static char savefile_module[46][80];
static char savefile_names[46][30];
static char savefile_desc[46][80];
-static bool_ savefile_alive[46];
+static bool savefile_alive[46];
static int savefile_idx[46];
/*
@@ -2863,10 +2868,6 @@ int load_savefile_names()
if (!fff) return (0);
- /* Save the current 'player_base' */
- player_base_save = game->player_base;
-
-
/*
* Parse, use '@' intead of ':' as a separator because it cannot exists
* in savefiles
@@ -2908,8 +2909,7 @@ int load_savefile_names()
savefile_module[max][4] = '\0';
}
- if (buf[i] == '0') savefile_alive[max] = FALSE;
- else if (buf[i] == '1') savefile_alive[max] = TRUE;
+ savefile_alive[max] = (buf[i] == '1');
i++;
start = i;
@@ -2923,11 +2923,10 @@ int load_savefile_names()
strcpy(savefile_desc[max], buf + i);
/* Build platform-dependent savefile name */
- game->player_base = savefile_names[max];
- process_player_name(TRUE);
+ auto player_base = process_player_name(savefile_names[max]);
/* Try to open the savefile */
- fd = fd_open(savefile, O_RDONLY);
+ fd = fd_open(name_file_save(player_base).c_str(), O_RDONLY);
/* Still existing ? */
if (fd >= 0)
@@ -2939,10 +2938,6 @@ int load_savefile_names()
my_fclose(fff);
- /* Restore the values of 'player_base' and 'savefile' */
- game->player_base = player_base_save;
- process_player_name(TRUE);
-
return (max);
}
@@ -2981,9 +2976,13 @@ void save_savefile_names()
for (i = 0; i < max; i++)
{
- if (!strcmp(savefile_names[i], game->player_base.c_str())) continue;
+ if (equals(savefile_names[i], game->player_base.c_str()))
+ {
+ continue;
+ }
+
fprintf(fff, "%s@%c%s@%s\n", savefile_module[i],
- (savefile_alive[i]) ? '1' : '0', savefile_names[i], savefile_desc[i]);
+ savefile_alive[i] ? '1' : '0', savefile_names[i], savefile_desc[i]);
}
my_fclose(fff);
@@ -3037,9 +3036,9 @@ static void dump_savefiles(int sel, int max)
/* Asks for new game or load game */
-bool_ no_begin_screen = FALSE;
+bool no_begin_screen = false;
-bool_ begin_screen()
+bool begin_screen()
{
int m, k, sel, max;
@@ -3063,7 +3062,7 @@ savefile_try_again:
max = m + 2;
if (max > 2) sel = 2;
- while (TRUE)
+ while (true)
{
/* Clear screen */
Term_clear();
@@ -3114,19 +3113,11 @@ savefile_try_again:
{
if (!get_check(format("Really delete '%s'?", savefile_names[savefile_idx[sel - 2]]))) continue;
- /* Save current 'player_base' */
- std::string player_base_save = game->player_base;
-
/* Build platform-dependent save file name */
- game->player_base = savefile_names[savefile_idx[sel - 2]];
- process_player_name(TRUE);
+ auto player_base = process_player_name(savefile_names[savefile_idx[sel - 2]]);
/* Remove the savefile */
- fd_kill(savefile);
-
- /* Restore 'player_base' and 'savefile' */
- game->player_base = player_base_save;
- process_player_name(TRUE);
+ fd_kill(name_file_save(player_base).c_str());
/* Reload, gods I hate using goto .. */
goto savefile_try_again;
@@ -3144,15 +3135,19 @@ savefile_try_again:
prt("Enter the name of the savefile that will hold this character: ", 23, 0);
/* Ask the user for a string */
- if (!askfor_aux(&game->player_base, 15)) continue;
+ auto tmp = game->player_base;
+ if (!askfor_aux(&tmp, 15))
+ {
+ continue;
+ }
/* Process the player name */
- process_player_name(TRUE);
+ set_player_base(tmp);
// If the savefile already exists, we do *NOT* want to
- // create a new game, so we'll need to return FALSE for
+ // create a new game, so we'll need to return false for
// that.
- if (boost::filesystem::exists(savefile))
+ if (boost::filesystem::exists(name_file_save()))
{
// Show a message so user doesn't get confused.
msg_print(NULL);
@@ -3170,12 +3165,12 @@ savefile_try_again:
prt("", 0, 0);
// Load character
- return FALSE;
+ return false;
}
else
{
// Start new game
- return TRUE;
+ return true;
}
}
if (k == 'b')
@@ -3184,12 +3179,16 @@ savefile_try_again:
prt("Enter the name of a savefile: ", 23, 0);
/* Ask the user for a string */
- if (!askfor_aux(&game->player_base, 15)) continue;
+ auto tmp = game->player_base;
+ if (!askfor_aux(&tmp, 15))
+ {
+ continue;
+ }
/* Process the player name */
- process_player_name(TRUE);
+ set_player_base(tmp);
- return (FALSE);
+ return false;
}
else
{
@@ -3200,15 +3199,13 @@ savefile_try_again:
if ((x < 2) || (x >= max)) continue;
- game->player_base = savefile_names[savefile_idx[x - 2]];
-
/* Process the player name */
- process_player_name(TRUE);
+ set_player_base(savefile_names[savefile_idx[x - 2]]);
- return (FALSE);
+ return false;
}
}
/* Shouldnt happen */
- return (FALSE);
+ return false;
}