diff options
author | Bardur Arantsson <bardur@scientician.net> | 2019-02-15 19:20:25 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2019-02-15 19:20:25 +0100 |
commit | 29a14fd37f222a0fb47effbabe4b3c3f52bad75a (patch) | |
tree | 451791bdbe56bd8d8334bfd48e73f0494c1cbc4f | |
parent | 5286cd001b32a383e4c0f37ee76eb06f1672295c (diff) |
Use std::array<> and bool
-rw-r--r-- | src/birth.cc | 2 | ||||
-rw-r--r-- | src/birther.hpp | 25 | ||||
-rw-r--r-- | src/corrupt.cc | 2 | ||||
-rw-r--r-- | src/help_info.hpp | 6 | ||||
-rw-r--r-- | src/init1.cc | 15 | ||||
-rw-r--r-- | src/loadsave.cc | 9 | ||||
-rw-r--r-- | src/owner_type.hpp | 7 | ||||
-rw-r--r-- | src/player_race.hpp | 2 | ||||
-rw-r--r-- | src/player_race_mod.hpp | 10 | ||||
-rw-r--r-- | src/player_type.hpp | 16 |
10 files changed, 42 insertions, 52 deletions
diff --git a/src/birth.cc b/src/birth.cc index d9e65026..295337dc 100644 --- a/src/birth.cc +++ b/src/birth.cc @@ -2648,7 +2648,7 @@ static bool player_birth_aux() } /* Save this for the next character */ - game->previous_char.quick_ok = TRUE; + game->previous_char.quick_ok = true; save_prev_data(); /* Accept */ diff --git a/src/birther.hpp b/src/birther.hpp index 0c28b513..05bdae7c 100644 --- a/src/birther.hpp +++ b/src/birther.hpp @@ -2,28 +2,27 @@ #include "h-basic.h" -#include <string> -#include <vector> +#include <array> /** * Player information during the birth process. */ struct birther { - s16b race; - s16b rmod; - s16b pclass; - s16b spec; + s16b race = 0; + s16b rmod = 0; + s16b pclass = 0; + s16b spec = 0; - byte quests; + byte quests = 0; - byte god; - s32b grace; + byte god = 0; + s32b grace = 0; - s32b au; + s32b au = 0; - s16b stat[6]; - s16b luck; + std::array<s16b, 6> stat { }; + s16b luck = 0; - bool_ quick_ok; + bool quick_ok = false; }; diff --git a/src/corrupt.cc b/src/corrupt.cc index 3f8a47c6..d8e95dbe 100644 --- a/src/corrupt.cc +++ b/src/corrupt.cc @@ -90,7 +90,7 @@ static void player_gain_vampire() if (rmp_ptr->title == "Vampire") { - rmp_ptr->place = FALSE; + rmp_ptr->place = false; } else { diff --git a/src/help_info.hpp b/src/help_info.hpp index 1b4a3757..2b8f41a5 100644 --- a/src/help_info.hpp +++ b/src/help_info.hpp @@ -1,5 +1,7 @@ #pragma once +#include <array> + #include "h-basic.h" /** @@ -12,6 +14,6 @@ constexpr int HELP_MAX = 64; */ struct help_info { - bool enabled = false; /* ingame help enabled */ - bool activated[HELP_MAX] = { false }; /* help item #i activated? */ + bool enabled = false; /* ingame help enabled */ + std::array<bool, HELP_MAX> activated { }; /* help item #i activated? */ }; diff --git a/src/init1.cc b/src/init1.cc index afe53b97..9774f323 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -638,7 +638,7 @@ static void strappend(char **s, const char *t) * Grab one race flag from a textual string */ static bool_ unknown_shut_up = FALSE; -static errr grab_one_class_flag(u32b *choice, const char *what) +static errr grab_one_class_flag(std::array<u32b, 2> &choice, const char *what) { auto const &class_info = game->edit_data.class_info; @@ -659,7 +659,7 @@ static errr grab_one_class_flag(u32b *choice, const char *what) return (1); } -static errr grab_one_race_allow_flag(u32b *choice, const char *what) +static errr grab_one_race_allow_flag(std::array<u32b, 2> &choice, const char *what) { auto const &race_info = game->edit_data.race_info; @@ -1208,14 +1208,7 @@ errr init_player_info_txt(FILE *fp) char const *s = buf + 6; /* Place */ - if (buf[4] == 'A') - { - rmp_ptr->place = TRUE; - } - else - { - rmp_ptr->place = FALSE; - } + rmp_ptr->place = (buf[4] == 'A'); /* Description */ if (!rmp_ptr->description.empty()) @@ -1391,7 +1384,7 @@ errr init_player_info_txt(FILE *fp) /* Process 'C' for "Class choice flags" (multiple lines) */ if ((buf[0] == 'S') && (buf[2] == 'C')) { - u32b choice[2] = {0, 0}; + std::array<u32b, 2> choice { }; if (0 != grab_one_class_flag(choice, buf + 6)) { return (5); diff --git a/src/loadsave.cc b/src/loadsave.cc index 8fd388b7..46ec50c9 100644 --- a/src/loadsave.cc +++ b/src/loadsave.cc @@ -480,7 +480,7 @@ static void do_quick_start(ls_flag_t flag, birther &previous_char) } do_s16b(&previous_char.luck, flag); - do_bool(&previous_char.quick_ok, flag); + do_std_bool(&previous_char.quick_ok, flag); } static void do_skill_modifier(skill_modifier *s, ls_flag_t flag) @@ -515,7 +515,7 @@ static void do_subrace(ls_flag_t flag) do_std_string(sr_ptr->title, flag); do_std_string(sr_ptr->description, flag); - do_bool(&sr_ptr->place, flag); + do_std_bool(&sr_ptr->place, flag); for (i = 0; i < 6; i++) { @@ -1664,11 +1664,6 @@ static void do_randomizer(ls_flag_t flag) if (flag == ls_flag_t::LOAD) { set_complex_rng_state(state); - } - - /* Accept */ - if (flag == ls_flag_t::LOAD) - { set_complex_rng(); } } diff --git a/src/owner_type.hpp b/src/owner_type.hpp index 4c47dc48..7fac70e8 100644 --- a/src/owner_type.hpp +++ b/src/owner_type.hpp @@ -1,5 +1,6 @@ #pragma once +#include <array> #include <string> #include "h-basic.h" @@ -27,15 +28,15 @@ struct owner_type /** * Liked/hated races. */ - u32b races[2][2] { }; + std::array<std::array<u32b, 2>, 2> races { }; /** * Liked/hated classes */ - u32b classes[2][2] { }; + std::array<std::array<u32b, 2>, 2> classes { }; /** * Costs for liked people */ - s16b costs[3] { }; + std::array<s16b, 3> costs { }; }; diff --git a/src/player_race.hpp b/src/player_race.hpp index e0b236db..c72c45de 100644 --- a/src/player_race.hpp +++ b/src/player_race.hpp @@ -30,7 +30,7 @@ struct player_race byte infra = 0; /* Infra-vision range */ - u32b choice[2] { }; /* Legal class choices */ + std::array<u32b, 2> choice { }; /* Legal class choices */ byte body_parts[BODY_MAX] { }; /* To help to decide what to use when body changing */ diff --git a/src/player_race_mod.hpp b/src/player_race_mod.hpp index 8eb984b7..fda410f0 100644 --- a/src/player_race_mod.hpp +++ b/src/player_race_mod.hpp @@ -21,7 +21,7 @@ struct player_race_mod std::string title; std::string description; - bool_ place = FALSE; /* TRUE = race race modifier, FALSE = Race modifier race */ + bool place = FALSE; /* TRUE = race race modifier, FALSE = Race modifier race */ char luck = '\0'; /* Luck */ s16b mana = 0; /* Mana % */ @@ -30,12 +30,12 @@ struct player_race_mod char infra = '\0'; /* (+) Infra-vision range */ - u32b choice[2] { }; /* Legal race choices */ + std::array<u32b, 2> choice { }; /* Legal race choices */ - u32b pclass[2] { }; /* Classes allowed */ - u32b mclass[2] { }; /* Classes restricted */ + std::array<u32b, 2> pclass { }; /* Classes allowed */ + std::array<u32b, 2> mclass { }; /* Classes restricted */ - char body_parts[BODY_MAX] { }; /* To help to decide what to use when body changing */ + std::array<char, BODY_MAX> body_parts { }; /* To help to decide what to use when body changing */ player_race_flag_set flags; diff --git a/src/player_type.hpp b/src/player_type.hpp index e09f82b9..b6e457c9 100644 --- a/src/player_type.hpp +++ b/src/player_type.hpp @@ -89,8 +89,8 @@ struct player_type s16b max_plv = 0; /* Max Player Level */ - s16b stat_max[6] = { 0 }; /* Current "maximal" stat values */ - s16b stat_cur[6] = { 0 }; /* Current "natural" stat values */ + std::array<s16b, 6> stat_max { }; /* Current "maximal" stat values */ + std::array<s16b, 6> stat_cur { }; /* Current "natural" stat values */ s16b luck_cur = 0; /* Current "natural" luck value (range -30 <> 30) */ s16b luck_max = 0; /* Current "maximal base" luck value (range -30 <> 30) */ @@ -203,13 +203,13 @@ struct player_type u32b redraw = 0; /* Normal Redraws (bit flags) */ u32b window = 0; /* Window Redraws (bit flags) */ - s16b stat_use[6] = { 0 }; /* Current modified stats */ - s16b stat_top[6] = { 0 }; /* Maximal modified stats */ + std::array<s16b, 6> stat_use { }; /* Current modified stats */ + std::array<s16b, 6> stat_top { }; /* Maximal modified stats */ - s16b stat_add[6] = { 0 }; /* Modifiers to stat values */ - s16b stat_ind[6] = { 0 }; /* Indexes into stat tables */ - s16b stat_cnt[6] = { 0 }; /* Counter for temporary drains */ - s16b stat_los[6] = { 0 }; /* Amount of temporary drains */ + std::array<s16b, 6> stat_add { }; /* Modifiers to stat values */ + std::array<s16b, 6> stat_ind { }; /* Indexes into stat tables */ + std::array<s16b, 6> stat_cnt { }; /* Counter for temporary drains */ + std::array<s16b, 6> stat_los { }; /* Amount of temporary drains */ bool_ immune_acid = FALSE; /* Immunity to acid */ bool_ immune_elec = FALSE; /* Immunity to lightning */ |