From 4d68cfb67dbd5e3c343fe21f118d9dbb21a18c61 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 20 Jun 2016 22:49:05 +0200 Subject: Change monster_ego to non-POD struct --- src/init2.cc | 2 +- src/monster_ego.hpp | 123 ++++++++++++++++++++++++++++------------------------ 2 files changed, 67 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/init2.cc b/src/init2.cc index 9c643257..1f6a1907 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -420,7 +420,7 @@ namespace { static void allocate() { - re_info = make_array(max_re_idx); + re_info = new monster_ego[max_re_idx]; } static errr parse(FILE *fp) diff --git a/src/monster_ego.hpp b/src/monster_ego.hpp index 00464c2e..873c642f 100644 --- a/src/monster_ego.hpp +++ b/src/monster_ego.hpp @@ -8,74 +8,83 @@ */ struct monster_ego { - const char *name; /* Name */ - bool_ before; /* Display ego before or after */ + const char *name = nullptr; /* Name */ + bool_ before = false; /* Display ego before or after */ - monster_blow blow[4]; /* Up to four blows per round */ - byte blowm[4][2]; + 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 blowm[4][2] = { + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } + }; - s16b hdice; /* Creatures hit dice count */ - s16b hside; /* Creatures hit dice sides */ + s16b hdice = 0; /* Creatures hit dice count */ + s16b hside = 0; /* Creatures hit dice sides */ - s16b ac; /* Armour Class */ + s16b ac = 0; /* Armour Class */ - s16b sleep; /* Inactive counter (base) */ - s16b aaf; /* Area affect radius (1-100) */ - s16b speed; /* Speed (normally 110) */ + s16b sleep = 0; /* Inactive counter (base) */ + s16b aaf = 0; /* Area affect radius (1-100) */ + s16b 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 */ /* Ego flags */ - u32b flags1; /* Flags 1 */ - u32b flags2; /* Flags 1 */ - u32b flags3; /* Flags 1 */ - u32b flags7; /* Flags 1 */ - u32b flags8; /* Flags 1 */ - u32b flags9; /* Flags 1 */ - u32b hflags1; /* Flags 1 */ - u32b hflags2; /* Flags 1 */ - u32b hflags3; /* Flags 1 */ - u32b hflags7; /* Flags 1 */ - u32b hflags8; /* Flags 1 */ - u32b hflags9; /* Flags 1 */ + u32b flags1 = 0; + u32b flags2 = 0; + u32b flags3 = 0; + u32b flags7 = 0; + u32b flags8 = 0; + u32b flags9 = 0; + u32b hflags1 = 0; + u32b hflags2 = 0; + u32b hflags3 = 0; + u32b hflags7 = 0; + u32b hflags8 = 0; + u32b hflags9 = 0; /* Monster flags */ - u32b mflags1; /* Flags 1 (general) */ - u32b mflags2; /* Flags 2 (abilities) */ - u32b mflags3; /* Flags 3 (race/resist) */ - u32b mflags4; /* Flags 4 (inate/breath) */ - u32b mflags5; /* Flags 5 (normal spells) */ - u32b mflags6; /* Flags 6 (special spells) */ - u32b mflags7; /* Flags 7 (movement related abilities) */ - u32b mflags8; /* Flags 8 (wilderness info) */ - u32b mflags9; /* Flags 9 (drops info) */ + u32b mflags1 = 0; + u32b mflags2 = 0; + u32b mflags3 = 0; + u32b mflags4 = 0; + u32b mflags5 = 0; + u32b mflags6 = 0; + u32b mflags7 = 0; + u32b mflags8 = 0; + u32b mflags9 = 0; /* Negative Flags, to be removed from the monster flags */ - u32b nflags1; /* Flags 1 (general) */ - u32b nflags2; /* Flags 2 (abilities) */ - u32b nflags3; /* Flags 3 (race/resist) */ - u32b nflags4; /* Flags 4 (inate/breath) */ - u32b nflags5; /* Flags 5 (normal spells) */ - u32b nflags6; /* Flags 6 (special spells) */ - u32b nflags7; /* Flags 7 (movement related abilities) */ - u32b nflags8; /* Flags 8 (wilderness info) */ - u32b nflags9; /* Flags 9 (drops info) */ - - s16b level; /* Level of creature */ - s16b rarity; /* Rarity of creature */ - - - byte d_attr; /* Default monster attribute */ - char d_char; /* Default monster character */ - - byte g_attr; /* Overlay graphic attribute */ - char g_char; /* Overlay graphic character */ - - char r_char[5]; /* Monster race allowed */ - char nr_char[5]; /* Monster race not allowed */ + u32b nflags1 = 0; + u32b nflags2 = 0; + u32b nflags3 = 0; + u32b nflags4 = 0; + u32b nflags5 = 0; + u32b nflags6 = 0; + u32b nflags7 = 0; + u32b nflags8 = 0; + u32b nflags9 = 0; + + s16b level = 0; /* Level of creature */ + s16b rarity = 0; /* Rarity of creature */ + + byte d_attr = 0; /* Default monster attribute */ + char d_char = '\0'; /* Default monster character */ + + byte g_attr = 0; /* Overlay graphic attribute */ + char g_char = '\0'; /* Overlay graphic character */ + + char r_char[5] = { '\0' }; /* Monster race allowed */ + char nr_char[5] = { '\0' }; /* Monster race not allowed */ }; -- cgit v1.2.3