summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-06-20 22:49:05 +0200
committerBardur Arantsson <bardur@scientician.net>2016-06-20 22:49:05 +0200
commitca8819a0307ab785766b3b4a5e2031b6db33ed1c (patch)
tree859cdab8ad364433fb916f135c39aaba644fa1ba
parentdb149f696b2c063df0e5b5bdd66dc0931760b3ec (diff)
Change monster_race to non-POD struct
-rw-r--r--src/init2.cc2
-rw-r--r--src/monster_race.hpp82
2 files changed, 44 insertions, 40 deletions
diff --git a/src/init2.cc b/src/init2.cc
index b921ddc9..9c643257 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -404,7 +404,7 @@ namespace {
static void allocate()
{
- r_info = make_array<monster_race>(max_r_idx);
+ r_info = new monster_race[max_r_idx];
}
static errr parse(FILE *fp)
diff --git a/src/monster_race.hpp b/src/monster_race.hpp
index ad44aef0..1cb2742a 100644
--- a/src/monster_race.hpp
+++ b/src/monster_race.hpp
@@ -26,66 +26,70 @@
*/
struct monster_race
{
- const char *name; /* Name */
- char *text; /* Text */
+ const char *name = nullptr; /* Name */
+ char *text = nullptr; /* Text */
- u16b hdice; /* Creatures hit dice count */
- u16b hside; /* Creatures hit dice sides */
+ u16b hdice = 0; /* Creatures hit dice count */
+ u16b hside = 0; /* Creatures hit dice sides */
- s16b ac; /* Armour Class */
+ s16b ac = 0; /* Armour Class */
- s16b sleep; /* Inactive counter (base) */
- byte aaf; /* Area affect radius (1-100) */
- byte speed; /* Speed (normally 110) */
+ s16b sleep = 0; /* Inactive counter (base) */
+ byte aaf = 0; /* Area affect radius (1-100) */
+ byte speed = 0; /* Speed (normally 110) */
- s32b mexp; /* Exp value for kill */
+ s32b mexp = 0; /* Exp value for kill */
- s32b weight; /* Weight of the monster */
+ s32b weight = 0; /* Weight of the monster */
- byte freq_inate; /* Inate spell frequency */
- byte freq_spell; /* Other spell frequency */
+ byte freq_inate = 0; /* Inate spell frequency */
+ byte freq_spell = 0; /* Other spell frequency */
- u32b flags1; /* Flags 1 (general) */
- u32b flags2; /* Flags 2 (abilities) */
- u32b flags3; /* Flags 3 (race/resist) */
- u32b flags4; /* Flags 4 (inate/breath) */
- u32b flags5; /* Flags 5 (normal spells) */
- u32b flags6; /* Flags 6 (special spells) */
- u32b flags7; /* Flags 7 (movement related abilities) */
- u32b flags8; /* Flags 8 (wilderness info) */
- u32b flags9; /* Flags 9 (drops info) */
+ u32b flags1 = 0; /* Flags 1 (general) */
+ u32b flags2 = 0; /* Flags 2 (abilities) */
+ u32b flags3 = 0; /* Flags 3 (race/resist) */
+ u32b flags4 = 0; /* Flags 4 (inate/breath) */
+ u32b flags5 = 0; /* Flags 5 (normal spells) */
+ u32b flags6 = 0; /* Flags 6 (special spells) */
+ u32b flags7 = 0; /* Flags 7 (movement related abilities) */
+ u32b flags8 = 0; /* Flags 8 (wilderness info) */
+ u32b flags9 = 0; /* Flags 9 (drops info) */
- monster_blow blow[4]; /* Up to four blows per round */
- byte body_parts[BODY_MAX]; /* To help to decide what to use when body changing */
+ monster_blow blow[4] = { /* Up to four blows per round */
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ };
- byte artifact_idx; /* Artifact index of standard artifact dropped; 0 if none. */
- int artifact_chance; /* Percentage chance of dropping the artifact. */
+ byte body_parts[BODY_MAX] = { 0 }; /* To help to decide what to use when body changing */
- byte level; /* Level of creature */
- byte rarity; /* Rarity of creature */
+ byte artifact_idx = 0; /* Artifact index of standard artifact dropped; 0 if none. */
+ int artifact_chance = 0; /* Percentage chance of dropping the artifact. */
+ byte level = 0; /* Level of creature */
+ byte rarity = 0; /* Rarity of creature */
- byte d_attr; /* Default monster attribute */
- char d_char; /* Default monster character */
+ byte d_attr = 0; /* Default monster attribute */
+ char d_char = 0; /* Default monster character */
- byte x_attr; /* Desired monster attribute */
- char x_char; /* Desired monster character */
+ byte x_attr = 0; /* Desired monster attribute */
+ char x_char = 0; /* Desired monster character */
+ s16b max_num = 0; /* Maximum population allowed per level */
+ byte cur_num = 0; /* Monster population on current level */
- s16b max_num; /* Maximum population allowed per level */
+ s16b r_pkills = 0; /* Count monsters killed in this life */
- byte cur_num; /* Monster population on current level */
+ bool_ on_saved = 0; /* Is the (unique) on a saved level ? */
+ byte total_visible = 0; /* Amount of this race that are visible */
- s16b r_pkills; /* Count monsters killed in this life */
+ obj_theme drops = obj_theme /* The drops type */
+ { 0, 0, 0, 0 };
- bool_ on_saved; /* Is the (unique) on a saved level ? */
-
- byte total_visible; /* Amount of this race that are visible */
-
- obj_theme drops; /* The drops type */
};