From fc06bedef3f5521a97989ebb6c7160744c640a19 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Change set_type to non-POD type --- src/init1.cc | 7 +++---- src/init2.cc | 2 +- src/set_component.hpp | 20 ++++++++++++++++++++ src/set_type.hpp | 24 +++++++----------------- 4 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 src/set_component.hpp (limited to 'src') 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(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 +#include + +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 pval; /* Pval for each combination */ + std::array flags1; /* Flags */ + std::array flags2; /* Flags */ + std::array flags3; /* Flags */ + std::array flags4; /* Flags */ + std::array flags5; /* Flags */ + std::array 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 +#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 arts; }; -- cgit v1.2.3