diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init1.cc | 7 | ||||
-rw-r--r-- | src/init2.cc | 2 | ||||
-rw-r--r-- | src/set_component.hpp | 20 | ||||
-rw-r--r-- | src/set_type.hpp | 24 |
4 files changed, 31 insertions, 22 deletions
diff --git a/src/init1.cc b/src/init1.cc index 327faca6..38736f0e 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -3728,8 +3728,6 @@ errr init_set_info_txt(FILE *fp) /* Process 'N' for "New/Number/Name" */ if (buf[0] == 'N') { - int z, y; - /* Find the colon before the name */ s = strchr(buf + 2, ':'); @@ -3764,11 +3762,12 @@ errr init_set_info_txt(FILE *fp) /* Initialize */ set_ptr->num = 0; set_ptr->num_use = 0; - for (z = 0; z < 6; z++) + + for (std::size_t z = 0; z < SET_MAX_SIZE; z++) { set_ptr->arts[z].a_idx = 0; set_ptr->arts[z].present = FALSE; - for (y = 0; y < 6; y++) + for (std::size_t y = 0; y < SET_MAX_SIZE; y++) { set_ptr->arts[z].flags1[y] = 0; set_ptr->arts[z].flags2[y] = 0; diff --git a/src/init2.cc b/src/init2.cc index 54f455e3..8bb9a25e 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -309,7 +309,7 @@ namespace { static void allocate() { - set_info = make_array<set_type>(max_set_idx); + set_info = new set_type[max_set_idx]; } static errr parse(FILE *fp) diff --git a/src/set_component.hpp b/src/set_component.hpp new file mode 100644 index 00000000..ceb82cbd --- /dev/null +++ b/src/set_component.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "h-basic.h" + +#include <array> +#include <cstdint> + +constexpr std::size_t SET_MAX_SIZE = 6; + +struct set_component { + bool_ present = FALSE; /* Is it actually wore ? */ + s16b a_idx = 0; /* What artifact? */ + std::array<s16b, SET_MAX_SIZE> pval; /* Pval for each combination */ + std::array<u32b, SET_MAX_SIZE> flags1; /* Flags */ + std::array<u32b, SET_MAX_SIZE> flags2; /* Flags */ + std::array<u32b, SET_MAX_SIZE> flags3; /* Flags */ + std::array<u32b, SET_MAX_SIZE> flags4; /* Flags */ + std::array<u32b, SET_MAX_SIZE> flags5; /* Flags */ + std::array<u32b, SET_MAX_SIZE> esp; /* Flags */ +}; diff --git a/src/set_type.hpp b/src/set_type.hpp index 827c23ac..0a04b384 100644 --- a/src/set_type.hpp +++ b/src/set_type.hpp @@ -1,28 +1,18 @@ #pragma once -#include "h-basic.h" +#include <array> +#include "set_component.hpp" /** * Item set descriptor and runtime information. */ struct set_type { - const char *name; /* Name */ - char *desc; /* Desc */ + const char *name = nullptr; /* Name */ + char *desc = nullptr; /* Desc */ - byte num; /* Number of artifacts used */ - byte num_use; /* Number actually wore */ + byte num = 0; /* Number of artifacts used */ + byte num_use = 0; /* Number actually worn */ - struct /* the various items */ - { - bool_ present; /* Is it actually wore ? */ - s16b a_idx; /* What artifact ? */ - s16b pval[6]; /* Pval for each combination */ - u32b flags1[6]; /* Flags */ - u32b flags2[6]; /* Flags */ - u32b flags3[6]; /* Flags */ - u32b flags4[6]; /* Flags */ - u32b flags5[6]; /* Flags */ - u32b esp[6]; /* Flags */ - } arts[6]; + std::array<set_component, SET_MAX_SIZE> arts; }; |