summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-03-29 20:32:55 +0200
committerBardur Arantsson <bardur@scientician.net>2016-03-29 20:32:55 +0200
commit493333206ea94eb0592e52629a0a628fa34eb266 (patch)
tree07ca2bb9191220c6b33f8687334ff625011dd6ec /src
parent168767170d481b9cc5fad6abe84af36e022fbf83 (diff)
Change dungeon_info_type to non-POD type
Diffstat (limited to 'src')
-rw-r--r--src/dungeon_info_type.hpp116
-rw-r--r--src/init2.cc2
-rw-r--r--src/rule_type.hpp24
3 files changed, 74 insertions, 68 deletions
diff --git a/src/dungeon_info_type.hpp b/src/dungeon_info_type.hpp
index b7b61a53..77c037a7 100644
--- a/src/dungeon_info_type.hpp
+++ b/src/dungeon_info_type.hpp
@@ -4,6 +4,8 @@
#include "rule_type.hpp"
#include "obj_theme.hpp"
+#include <array>
+
/**
* Maximum number of towns per dungeon
*/
@@ -12,60 +14,64 @@ constexpr int TOWN_DUNGEON = 4;
/* A structure for the != dungeon types */
struct dungeon_info_type
{
- const char *name; /* Name */
- char *text; /* Description */
- char short_name[3]; /* Short name */
-
- char generator[30]; /* Name of the level generator */
-
- s16b floor1; /* Floor tile 1 */
- byte floor_percent1[2]; /* Chance of type 1 */
- s16b floor2; /* Floor tile 2 */
- byte floor_percent2[2]; /* Chance of type 2 */
- s16b floor3; /* Floor tile 3 */
- byte floor_percent3[2]; /* Chance of type 3 */
- s16b outer_wall; /* Outer wall tile */
- s16b inner_wall; /* Inner wall tile */
- s16b fill_type1; /* Cave tile 1 */
- byte fill_percent1[2]; /* Chance of type 1 */
- s16b fill_type2; /* Cave tile 2 */
- byte fill_percent2[2]; /* Chance of type 2 */
- s16b fill_type3; /* Cave tile 3 */
- byte fill_percent3[2]; /* Chance of type 3 */
- byte fill_method; /* Smoothing parameter for the above */
-
- s16b mindepth; /* Minimal depth */
- s16b maxdepth; /* Maximal depth */
-
- bool_ principal; /* If it's a part of the main dungeon */
- byte min_plev; /* Minimal plev needed to enter -- it's an anti-cheating mesure */
-
- int min_m_alloc_level; /* Minimal number of monsters per level */
- int max_m_alloc_chance; /* There is a 1/max_m_alloc_chance chance per round of creating a new monster */
-
- u32b flags1; /* Flags 1 */
- u32b flags2; /* Flags 1 */
-
- int size_x, size_y; /* Desired numers of panels */
-
- byte rule_percents[100]; /* Flat rule percents */
- rule_type rules[5]; /* Monster generation rules */
-
- int final_object; /* The object you'll find at the bottom */
- int final_artifact; /* The artifact you'll find at the bottom */
- int final_guardian; /* The artifact's guardian. If an artifact is specified, then it's NEEDED */
-
- int ix, iy, ox, oy; /* Wilderness coordinates of the entrance/output of the dungeon */
-
- obj_theme objs; /* The drops type */
-
- int d_dice[4]; /* Number of dices */
- int d_side[4]; /* Number of sides */
- int d_frequency[4]; /* Frequency of damage (1 is the minimum) */
- int d_type[4]; /* Type of damage */
-
- s16b t_idx[TOWN_DUNGEON]; /* The towns */
- s16b t_level[TOWN_DUNGEON]; /* The towns levels */
- s16b t_num; /* Number of towns */
+ const char *name = nullptr; /* Name */
+ char *text = nullptr; /* Description */
+ char short_name[3] = { 0 }; /* Short name */
+
+ char generator[30] = { 0 }; /* Name of the level generator */
+
+ s16b floor1 = 0; /* Floor tile 1 */
+ byte floor_percent1[2] = { 0 }; /* Chance of type 1 */
+ s16b floor2 = 0; /* Floor tile 2 */
+ byte floor_percent2[2] = { 0 }; /* Chance of type 2 */
+ s16b floor3 = 0; /* Floor tile 3 */
+ byte floor_percent3[2] = { 0 }; /* Chance of type 3 */
+ s16b outer_wall = 0; /* Outer wall tile */
+ s16b inner_wall = 0; /* Inner wall tile */
+ s16b fill_type1 = 0; /* Cave tile 1 */
+ byte fill_percent1[2] = { 0 }; /* Chance of type 1 */
+ s16b fill_type2 = 0; /* Cave tile 2 */
+ byte fill_percent2[2] = { 0 }; /* Chance of type 2 */
+ s16b fill_type3 = 0; /* Cave tile 3 */
+ byte fill_percent3[2] = { 0 }; /* Chance of type 3 */
+ byte fill_method = 0; /* Smoothing parameter for the above */
+
+ s16b mindepth = 0; /* Minimal depth */
+ s16b maxdepth = 0; /* Maximal depth */
+
+ bool_ principal = 0; /* If it's a part of the main dungeon */
+ byte min_plev = 0; /* Minimal plev needed to enter -- it's an anti-cheating mesure */
+
+ int min_m_alloc_level = 0; /* Minimal number of monsters per level */
+ int max_m_alloc_chance = 0; /* There is a 1/max_m_alloc_chance chance per round of creating a new monster */
+
+ u32b flags1 = 0; /* Dungeon flags 1 */
+ u32b flags2 = 0; /* Dungeon flags 2 */
+
+ int size_x = 0;
+ int size_y = 0;
+
+ byte rule_percents[100] = {0}; /* Flat rule percents */
+ std::array<rule_type, 5> rules { }; /* Monster generation rules */
+
+ int final_object = 0; /* The object you'll find at the bottom */
+ int final_artifact = 0; /* The artifact you'll find at the bottom */
+ int final_guardian = 0; /* The artifact's guardian. If an artifact is specified, then it's NEEDED */
+
+ int ix = 0; /* Wilderness coordinates of entrance */
+ int iy = 0; /* Wilderness coordinates of entrance */
+ int ox = 0; /* Wilderness coordinates of exit */
+ int oy = 0; /* Wilderness coordinates of exit */
+
+ obj_theme objs = obj_theme { 0, 0, 0, 0 }; /* The drops type */
+
+ int d_dice[4] = { 0 }; /* Number of dices */
+ int d_side[4] = { 0 }; /* Number of sides */
+ int d_frequency[4] = { 0 }; /* Frequency of damage (1 is the minimum) */
+ int d_type[4] = { 0 }; /* Type of damage */
+
+ s16b t_idx[TOWN_DUNGEON] = { 0 }; /* The towns */
+ s16b t_level[TOWN_DUNGEON] = { 0 }; /* The towns levels */
+ s16b t_num = 0; /* Number of towns */
};
diff --git a/src/init2.cc b/src/init2.cc
index ea85cb29..b921ddc9 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -436,7 +436,7 @@ namespace {
static void allocate()
{
- d_info = make_array<dungeon_info_type>(max_d_idx);
+ d_info = new dungeon_info_type[max_d_idx];
}
static errr parse(FILE *fp)
diff --git a/src/rule_type.hpp b/src/rule_type.hpp
index a8b35ffa..d2e510a7 100644
--- a/src/rule_type.hpp
+++ b/src/rule_type.hpp
@@ -5,18 +5,18 @@
/* Define monster generation rules */
struct rule_type
{
- byte mode; /* Mode of combination of the monster flags */
- byte percent; /* Percent of monsters affected by the rule */
+ byte mode = 0; /* Mode of combination of the monster flags */
+ byte percent = 0; /* Percent of monsters affected by the rule */
- u32b mflags1; /* The monster flags that are allowed */
- u32b mflags2;
- u32b mflags3;
- u32b mflags4;
- u32b mflags5;
- u32b mflags6;
- u32b mflags7;
- u32b mflags8;
- u32b mflags9;
+ u32b mflags1 = 0; /* The monster flags that are allowed */
+ u32b mflags2 = 0;
+ u32b mflags3 = 0;
+ u32b mflags4 = 0;
+ u32b mflags5 = 0;
+ u32b mflags6 = 0;
+ u32b mflags7 = 0;
+ u32b mflags8 = 0;
+ u32b mflags9 = 0;
- char r_char[5]; /* Monster race allowed */
+ char r_char[5] = { 0 }; /* Monster race allowed */
};