diff options
author | Bardur Arantsson <bardur@scientician.net> | 2016-09-17 09:58:13 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2016-09-17 09:58:13 +0200 |
commit | f1898380237c975d07cf98bb25a882085f1e3b95 (patch) | |
tree | 93892b86794fc9d1a8c37912ce4daccda4dd1ce1 /src | |
parent | a303c1a21930025c4f5ec086733f5d936d54f326 (diff) |
Change meta_class_type::classes to std::vector
Diffstat (limited to 'src')
-rw-r--r-- | src/birth.cc | 25 | ||||
-rw-r--r-- | src/init1.cc | 4 | ||||
-rw-r--r-- | src/init2.cc | 4 | ||||
-rw-r--r-- | src/meta_class_type.hpp | 3 |
4 files changed, 15 insertions, 21 deletions
diff --git a/src/birth.cc b/src/birth.cc index dd66e11f..fd515806 100644 --- a/src/birth.cc +++ b/src/birth.cc @@ -1171,16 +1171,16 @@ static void player_outfit(void) } -int dump_classes(s16b *classes, int sel, u32b *restrictions) +static void dump_classes(std::vector<u16b> const &classes, int sel, u32b *restrictions) { - int n = 0; - char buf[80]; /* Clean up */ clear_from(12); - while (classes[n] != -1) + int n_max = static_cast<int>(classes.size()); // Warning avoidance + + for (int n = 0; n < n_max; n++) { cptr mod = ""; char p2 = ')', p1 = ' '; @@ -1226,10 +1226,8 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions) else put_str(buf, 18 + (n / 4), 1 + 20 * (n % 4)); } - n++; - } - return (n); + } } int dump_specs(int sel) @@ -1486,8 +1484,6 @@ static bool_ player_birth_aux_ask() int const RACE_ROW = 3; int const CLASS_ROW = 4; - s16b *class_types; - /*** Intro ***/ /* Clear screen */ @@ -1824,21 +1820,24 @@ static bool_ player_birth_aux_ask() { k = 0; } - class_types = meta_class_info[k].classes; + clear_from(15); + auto const &class_types = meta_class_info[k].classes; + /* Count classes */ - n = 0; - while (class_types[n] != -1) n++; + n = class_types.size(); /* Only one choice = instant choice */ if (n == 1) + { k = 0; + } else { /* Dump classes */ sel = 0; - n = dump_classes(class_types, sel, restrictions); + dump_classes(class_types, sel, restrictions); /* Get a class */ while (1) diff --git a/src/init1.cc b/src/init1.cc index ed173481..05a4f857 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -2039,8 +2039,6 @@ errr init_player_info_txt(FILE *fp) /* Append chars to the name */ strcpy(mc_ptr->name, s + 2); mc_ptr->color = color_char_to_attr(s[0]); - for (powers = 0; powers < max_c_idx; powers++) - mc_ptr->classes[powers] = -1; powers = 0; /* Next... */ @@ -2066,7 +2064,7 @@ errr init_player_info_txt(FILE *fp) if (i == max_c_idx) return (6); - mc_ptr->classes[powers++] = i; + mc_ptr->classes.push_back(i); /* Next... */ continue; diff --git a/src/init2.cc b/src/init2.cc index 67c9d37f..ac69b760 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -556,10 +556,6 @@ namespace { class_info = new player_class[max_c_idx]; bg = make_array<hist_type>(max_bg_idx); meta_class_info = new meta_class_type[max_mc_idx]; - for (std::size_t i = 0; i < max_mc_idx; i++) - { - meta_class_info[i].classes = make_array<s16b>(max_c_idx); - } } static errr parse(FILE *fp) diff --git a/src/meta_class_type.hpp b/src/meta_class_type.hpp index 243b0ad4..bd47f998 100644 --- a/src/meta_class_type.hpp +++ b/src/meta_class_type.hpp @@ -1,10 +1,11 @@ #pragma once #include "h-basic.h" +#include <vector> struct meta_class_type { char name[80] = ""; /* Name */ byte color = 0; - s16b *classes = nullptr; /* List of classes */ + std::vector<u16b> classes; /* List of classes */ }; |