diff options
Diffstat (limited to 'src/monster2.cc')
-rw-r--r-- | src/monster2.cc | 783 |
1 files changed, 348 insertions, 435 deletions
diff --git a/src/monster2.cc b/src/monster2.cc index 3debb27a..624dca53 100644 --- a/src/monster2.cc +++ b/src/monster2.cc @@ -11,8 +11,10 @@ #include "artifact_type.hpp" #include "cave.hpp" #include "cave_type.hpp" +#include "dungeon_flag.hpp" #include "dungeon_info_type.hpp" #include "files.hpp" +#include "game.hpp" #include "hook_new_monster_in.hpp" #include "hook_new_monster_end_in.hpp" #include "hooks.hpp" @@ -21,12 +23,16 @@ #include "monster3.hpp" #include "monster_ego.hpp" #include "monster_race.hpp" +#include "monster_race_flag.hpp" +#include "monster_spell_flag.hpp" #include "monster_type.hpp" #include "object1.hpp" #include "object2.hpp" +#include "object_flag.hpp" #include "object_kind.hpp" #include "object_type.hpp" #include "options.hpp" +#include "player_race_flag.hpp" #include "player_type.hpp" #include "randart.hpp" #include "spells1.hpp" @@ -59,8 +65,10 @@ s32b monster_exp(s16b level) /* Monster gain a few levels ? */ void monster_check_experience(int m_idx, bool_ silent) { + auto const &r_info = game->edit_data.r_info; + monster_type *m_ptr = &m_list[m_idx]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; + auto r_ptr = &r_info[m_ptr->r_idx]; char m_name[80]; /* Get the name */ @@ -166,25 +174,17 @@ s32b modify_aux(s32b a, s32b b, char mod) /* Is this ego ok for this monster ? */ bool_ mego_ok(monster_race const *r_ptr, int ego) { - monster_ego *re_ptr = &re_info[ego]; + const auto &re_info = game->edit_data.re_info; + + auto re_ptr = &re_info[ego]; bool_ ok = FALSE; int i; /* needed flags */ - if (re_ptr->flags1 && ((re_ptr->flags1 & r_ptr->flags1) != re_ptr->flags1)) return FALSE; - if (re_ptr->flags2 && ((re_ptr->flags2 & r_ptr->flags2) != re_ptr->flags2)) return FALSE; - if (re_ptr->flags3 && ((re_ptr->flags3 & r_ptr->flags3) != re_ptr->flags3)) return FALSE; - if (re_ptr->flags7 && ((re_ptr->flags7 & r_ptr->flags7) != re_ptr->flags7)) return FALSE; - if (re_ptr->flags8 && ((re_ptr->flags8 & r_ptr->flags8) != re_ptr->flags8)) return FALSE; - if (re_ptr->flags9 && ((re_ptr->flags9 & r_ptr->flags9) != re_ptr->flags9)) return FALSE; + if (re_ptr->flags && ((re_ptr->flags & r_ptr->flags) != re_ptr->flags)) return FALSE; /* unwanted flags */ - if (re_ptr->hflags1 && (re_ptr->hflags1 & r_ptr->flags1)) return FALSE; - if (re_ptr->hflags2 && (re_ptr->hflags2 & r_ptr->flags2)) return FALSE; - if (re_ptr->hflags3 && (re_ptr->hflags3 & r_ptr->flags3)) return FALSE; - if (re_ptr->hflags7 && (re_ptr->hflags7 & r_ptr->flags7)) return FALSE; - if (re_ptr->hflags8 && (re_ptr->hflags8 & r_ptr->flags8)) return FALSE; - if (re_ptr->hflags9 && (re_ptr->hflags9 & r_ptr->flags9)) return FALSE; + if (re_ptr->hflags && (re_ptr->hflags & r_ptr->flags)) return FALSE; /* Need good race -- IF races are specified */ if (re_ptr->r_char[0]) @@ -210,12 +210,13 @@ bool_ mego_ok(monster_race const *r_ptr, int ego) /* Choose an ego type */ static int pick_ego_monster(monster_race const *r_ptr) { + const auto &re_info = game->edit_data.re_info; + /* Assume no ego */ int ego = 0, lvl; - int tries = max_re_idx + 10; - monster_ego *re_ptr; + int tries = re_info.size() + 10; - if ((!(dungeon_flags2 & DF2_ELVEN)) && (!(dungeon_flags2 & DF2_DWARVEN))) + if ((!(dungeon_flags & DF_ELVEN)) && (!(dungeon_flags & DF_DWARVEN))) { /* No townspeople ego */ if (!r_ptr->level) return 0; @@ -227,8 +228,8 @@ static int pick_ego_monster(monster_race const *r_ptr) while (tries--) { /* Pick one */ - ego = rand_range(1, max_re_idx - 1); - re_ptr = &re_info[ego]; + ego = rand_range(1, re_info.size() - 1); + auto re_ptr = &re_info[ego]; /* No hope so far */ if (!mego_ok(r_ptr, ego)) continue; @@ -250,9 +251,9 @@ static int pick_ego_monster(monster_race const *r_ptr) /* Bypass restrictions for themed townspeople */ else { - if (dungeon_flags2 & DF2_ELVEN) + if (dungeon_flags & DF_ELVEN) ego = test_mego_name("Elven"); - else if (dungeon_flags2 & DF2_DWARVEN) + else if (dungeon_flags & DF_DWARVEN) ego = test_mego_name("Dwarven"); if (mego_ok(r_ptr, ego)) @@ -269,7 +270,10 @@ static int pick_ego_monster(monster_race const *r_ptr) */ std::shared_ptr<monster_race> race_info_idx(int r_idx, int ego) { - monster_race *r_ptr = &r_info[r_idx]; + auto const &re_info = game->edit_data.re_info; + auto &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[r_idx]; /* We don't need to allocate anything if it's an ordinary monster. */ if (!ego) { @@ -283,7 +287,7 @@ std::shared_ptr<monster_race> race_info_idx(int r_idx, int ego) *nr_ptr = *r_ptr; /* Get a reference to the ego monster modifiers */ - monster_ego *re_ptr = &re_info[ego]; + auto re_ptr = &re_info[ego]; /* Adjust the values */ for (int i = 0; i < 4; i++) @@ -329,26 +333,12 @@ std::shared_ptr<monster_race> race_info_idx(int r_idx, int ego) MODIFY(nr_ptr->level, re_ptr->level, 1); /* Take off some flags */ - nr_ptr->flags1 &= ~(re_ptr->nflags1); - nr_ptr->flags2 &= ~(re_ptr->nflags2); - nr_ptr->flags3 &= ~(re_ptr->nflags3); - nr_ptr->flags4 &= ~(re_ptr->nflags4); - nr_ptr->flags5 &= ~(re_ptr->nflags5); - nr_ptr->flags6 &= ~(re_ptr->nflags6); - nr_ptr->flags7 &= ~(re_ptr->nflags7); - nr_ptr->flags8 &= ~(re_ptr->nflags8); - nr_ptr->flags9 &= ~(re_ptr->nflags9); + nr_ptr->flags &= ~re_ptr->nflags; + nr_ptr->spells &= ~(re_ptr->nspells); /* Add some flags */ - nr_ptr->flags1 |= re_ptr->mflags1; - nr_ptr->flags2 |= re_ptr->mflags2; - nr_ptr->flags3 |= re_ptr->mflags3; - nr_ptr->flags4 |= re_ptr->mflags4; - nr_ptr->flags5 |= re_ptr->mflags5; - nr_ptr->flags6 |= re_ptr->mflags6; - nr_ptr->flags7 |= re_ptr->mflags7; - nr_ptr->flags8 |= re_ptr->mflags8; - nr_ptr->flags9 |= re_ptr->mflags9; + nr_ptr->flags |= re_ptr->mflags; + nr_ptr->spells |= re_ptr->mspells; /* Change the char/attr is needed */ if (re_ptr->d_char != MEGO_CHAR_ANY) @@ -440,6 +430,10 @@ static cptr funny_comments[MAX_COMMENT] = */ void delete_monster_idx(int i) { + auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; + auto &random_artifacts = game->random_artifacts; + /* Get location */ monster_type *m_ptr = &m_list[i]; int y = m_ptr->fy; @@ -451,11 +445,11 @@ void delete_monster_idx(int i) r_ptr->on_saved = FALSE; /* Hack -- count the number of "reproducers" */ - if (r_ptr->flags4 & (RF4_MULTIPLY)) num_repro--; + if (r_ptr->spells & SF_MULTIPLY) num_repro--; /* XXX XXX XXX remove monster light source */ bool_ had_lite = FALSE; - if (r_ptr->flags9 & (RF9_HAS_LITE)) had_lite = TRUE; + if (r_ptr->flags & RF_HAS_LITE) had_lite = TRUE; /* Hack -- remove target monster */ @@ -495,7 +489,7 @@ void delete_monster_idx(int i) /* Hack -- efficiency */ o_ptr->held_m_idx = 0; - if ( p_ptr->preserve ) + if (options->preserve) { /* Hack -- Preserve unknown artifacts */ if (artifact_p(o_ptr) && !object_known_p(o_ptr)) @@ -505,7 +499,7 @@ void delete_monster_idx(int i) { random_artifacts[o_ptr->sval].generated = FALSE; } - else if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART) + else if (k_info[o_ptr->k_idx].flags & TR_NORM_ART) { k_info[o_ptr->k_idx].artifact = FALSE; } @@ -681,7 +675,7 @@ void compact_monsters(int size) if ((m_ptr->mflag & MFLAG_QUEST) && (cnt < 1000)) chance = 100; /* Try not to compact Unique Monsters */ - if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 99; + if (r_ptr->flags & RF_UNIQUE) chance = 99; /* All monsters get a saving throw */ if (rand_int(100) < chance) continue; @@ -718,7 +712,7 @@ void compact_monsters(int size) * This is an efficient method of simulating multiple calls to the * "delete_monster()" function, with no visual effects. */ -void wipe_m_list(void) +void wipe_m_list() { int i; @@ -730,8 +724,6 @@ void wipe_m_list(void) /* Skip dead monsters */ if (!m_ptr->r_idx) continue; - /* Mega-Hack -- preserve Unique's XXX XXX XXX */ - /* Hack -- Reduce the racial counter */ auto r_ptr = m_ptr->race(); r_ptr->cur_num--; @@ -768,7 +760,7 @@ void wipe_m_list(void) * * This routine should almost never fail, but it *can* happen. */ -s16b m_pop(void) +s16b m_pop() { int i; @@ -822,29 +814,26 @@ s16b m_pop(void) /* * Apply a "monster restriction function" to the "monster allocation table" */ -errr get_mon_num_prep(void) +errr get_mon_num_prep() { - int i; + auto &alloc = game->alloc; /* Scan the allocation table */ - for (i = 0; i < alloc_race_size; i++) + for (auto &&entry: alloc.race_table) { - /* Get the entry */ - alloc_entry *entry = &alloc_race_table[i]; - /* Accept monsters which pass the restriction, if any */ - if ((!get_mon_num_hook || (*get_mon_num_hook)(entry->index)) && - (!get_mon_num2_hook || (*get_mon_num2_hook)(entry->index))) + if ((!get_mon_num_hook || (*get_mon_num_hook)(entry.index)) && + (!get_mon_num2_hook || (*get_mon_num2_hook)(entry.index))) { /* Accept this monster */ - entry->prob2 = entry->prob1; + entry.prob2 = entry.prob1; } /* Do not use this monster */ else { /* Decline this monster */ - entry->prob2 = 0; + entry.prob2 = 0; } } @@ -856,9 +845,11 @@ errr get_mon_num_prep(void) * Some dungeon types restrict the possible monsters. * Return TRUE is the monster is OK and FALSE otherwise */ -bool_ apply_rule(monster_race *r_ptr, byte rule) +static bool_ apply_rule(monster_race const *r_ptr, byte rule) { - dungeon_info_type *d_ptr = &d_info[dungeon_type]; + auto const &d_info = game->edit_data.d_info; + + auto d_ptr = &d_info[dungeon_type]; if (d_ptr->rules[rule].mode == DUNGEON_MODE_NONE) { @@ -868,49 +859,14 @@ bool_ apply_rule(monster_race *r_ptr, byte rule) { int a; - if (d_ptr->rules[rule].mflags1) - { - if ((d_ptr->rules[rule].mflags1 & r_ptr->flags1) != d_ptr->rules[rule].mflags1) - return FALSE; - } - if (d_ptr->rules[rule].mflags2) - { - if ((d_ptr->rules[rule].mflags2 & r_ptr->flags2) != d_ptr->rules[rule].mflags2) - return FALSE; - } - if (d_ptr->rules[rule].mflags3) - { - if ((d_ptr->rules[rule].mflags3 & r_ptr->flags3) != d_ptr->rules[rule].mflags3) - return FALSE; - } - if (d_ptr->rules[rule].mflags4) + if (d_ptr->rules[rule].mflags) { - if ((d_ptr->rules[rule].mflags4 & r_ptr->flags4) != d_ptr->rules[rule].mflags4) + if ((d_ptr->rules[rule].mflags & r_ptr->flags) != d_ptr->rules[rule].mflags) return FALSE; } - if (d_ptr->rules[rule].mflags5) + if (d_ptr->rules[rule].mspells) { - if ((d_ptr->rules[rule].mflags5 & r_ptr->flags5) != d_ptr->rules[rule].mflags5) - return FALSE; - } - if (d_ptr->rules[rule].mflags6) - { - if ((d_ptr->rules[rule].mflags6 & r_ptr->flags6) != d_ptr->rules[rule].mflags6) - return FALSE; - } - if (d_ptr->rules[rule].mflags7) - { - if ((d_ptr->rules[rule].mflags7 & r_ptr->flags7) != d_ptr->rules[rule].mflags7) - return FALSE; - } - if (d_ptr->rules[rule].mflags8) - { - if ((d_ptr->rules[rule].mflags8 & r_ptr->flags8) != d_ptr->rules[rule].mflags8) - return FALSE; - } - if (d_ptr->rules[rule].mflags9) - { - if ((d_ptr->rules[rule].mflags9 & r_ptr->flags9) != d_ptr->rules[rule].mflags9) + if ((d_ptr->rules[rule].mspells & r_ptr->spells) != d_ptr->rules[rule].mspells) return FALSE; } for (a = 0; a < 5; a++) @@ -925,15 +881,8 @@ bool_ apply_rule(monster_race *r_ptr, byte rule) { int a; - if (d_ptr->rules[rule].mflags1 && (r_ptr->flags1 & d_ptr->rules[rule].mflags1)) return TRUE; - if (d_ptr->rules[rule].mflags2 && (r_ptr->flags2 & d_ptr->rules[rule].mflags2)) return TRUE; - if (d_ptr->rules[rule].mflags3 && (r_ptr->flags3 & d_ptr->rules[rule].mflags3)) return TRUE; - if (d_ptr->rules[rule].mflags4 && (r_ptr->flags4 & d_ptr->rules[rule].mflags4)) return TRUE; - if (d_ptr->rules[rule].mflags5 && (r_ptr->flags5 & d_ptr->rules[rule].mflags5)) return TRUE; - if (d_ptr->rules[rule].mflags6 && (r_ptr->flags6 & d_ptr->rules[rule].mflags6)) return TRUE; - if (d_ptr->rules[rule].mflags7 && (r_ptr->flags7 & d_ptr->rules[rule].mflags7)) return TRUE; - if (d_ptr->rules[rule].mflags8 && (r_ptr->flags8 & d_ptr->rules[rule].mflags8)) return TRUE; - if (d_ptr->rules[rule].mflags9 && (r_ptr->flags9 & d_ptr->rules[rule].mflags9)) return TRUE; + if (d_ptr->rules[rule].mflags && (r_ptr->flags & d_ptr->rules[rule].mflags)) return TRUE; + if (d_ptr->rules[rule].mspells && (r_ptr->spells & d_ptr->rules[rule].mspells)) return TRUE; for (a = 0; a < 5; a++) if (d_ptr->rules[rule].r_char[a] == r_ptr->d_char) return TRUE; @@ -948,8 +897,11 @@ bool_ apply_rule(monster_race *r_ptr, byte rule) bool_ restrict_monster_to_dungeon(int r_idx) { - dungeon_info_type *d_ptr = &d_info[dungeon_type]; - monster_race *r_ptr = &r_info[r_idx]; + auto const &d_info = game->edit_data.d_info; + auto const &r_info = game->edit_data.r_info; + + auto d_ptr = &d_info[dungeon_type]; + auto r_ptr = &r_info[r_idx]; /* Select a random rule */ byte rule = d_ptr->rule_percents[rand_int(100)]; @@ -994,15 +946,13 @@ bool_ summon_hack = FALSE; */ s16b get_mon_num(int level) { - int i, j, p; - - int r_idx; - - long value, total; - - monster_race *r_ptr; + auto const &r_info = game->edit_data.r_info; + auto &alloc = game->alloc; - alloc_entry *table = alloc_race_table; + std::size_t i, j; + int p; + int r_idx; + long value, total; int in_tome; @@ -1038,59 +988,52 @@ s16b get_mon_num(int level) in_tome = strcmp(game_module, "ToME") == 0; /* Process probabilities */ - for (i = 0; i < alloc_race_size; i++) + for (i = 0; i < alloc.race_table.size(); i++) { + auto &entry = alloc.race_table[i]; + /* Monsters are sorted by depth */ - if (table[i].level > level) break; + if (entry.level > level) break; /* Default */ - table[i].prob3 = 0; + entry.prob3 = 0; /* Access the "r_idx" of the chosen monster */ - r_idx = table[i].index; + r_idx = entry.index; /* Access the actual race */ - r_ptr = &r_info[r_idx]; + auto r_ptr = &r_info[r_idx]; /* Hack -- "unique" monsters must be "unique" */ - if ((r_ptr->flags1 & (RF1_UNIQUE)) && + if ((r_ptr->flags & RF_UNIQUE) && (r_ptr->cur_num >= r_ptr->max_num)) { continue; } /* Depth Monsters never appear out of depth */ - if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (r_ptr->level > dun_level)) + if ((r_ptr->flags & RF_FORCE_DEPTH) && (r_ptr->level > dun_level)) { continue; } /* Depth Monsters never appear out of their depth */ - if ((r_ptr->flags9 & (RF9_ONLY_DEPTH)) && (r_ptr->level != dun_level)) + if ((r_ptr->flags & RF_ONLY_DEPTH) && (r_ptr->level != dun_level)) { continue; } - if(in_tome) - { - /* Zangbandish monsters not allowed */ - if (r_ptr->flags8 & RF8_ZANGBAND) continue; - - /* Lovecraftian monsters not allowed */ - if (r_ptr->flags8 & RF8_CTHANGBAND) continue; - } - /* Joke monsters allowed ? or not ? */ - if (!joke_monsters && (r_ptr->flags8 & RF8_JOKEANGBAND)) continue; + if (!options->joke_monsters && (r_ptr->flags & RF_JOKEANGBAND)) continue; /* Some dungeon types restrict the possible monsters */ if (!summon_hack && !restrict_monster_to_dungeon(r_idx) && dun_level) continue; /* Accept */ - table[i].prob3 = table[i].prob2; + entry.prob3 = entry.prob2; /* Total */ - total += table[i].prob3; + total += entry.prob3; } /* No legal monsters */ @@ -1101,19 +1044,24 @@ s16b get_mon_num(int level) value = rand_int(total); /* Find the monster */ - for (i = 0; i < alloc_race_size; i++) + for (i = 0; i < alloc.race_table.size(); i++) { + auto &entry = alloc.race_table[i]; + /* Found the entry */ - if (value < table[i].prob3) break; + if (value < entry.prob3) break; /* Decrement */ - value = value - table[i].prob3; + value = value - entry.prob3; } /* Power boost */ p = rand_int(100); + /* Shorthand */ + auto &table = alloc.race_table; + /* Try for a "harder" monster once (50%) or twice (10%) */ if (p < 60) { @@ -1124,7 +1072,7 @@ s16b get_mon_num(int level) value = rand_int(total); /* Find the monster */ - for (i = 0; i < alloc_race_size; i++) + for (i = 0; i < table.size(); i++) { /* Found the entry */ if (value < table[i].prob3) break; @@ -1147,7 +1095,7 @@ s16b get_mon_num(int level) value = rand_int(total); /* Find the monster */ - for (i = 0; i < alloc_race_size; i++) + for (i = 0; i < table.size(); i++) { /* Found the entry */ if (value < table[i].prob3) break; @@ -1217,6 +1165,9 @@ s16b get_mon_num(int level) */ void monster_desc(char *desc, monster_type *m_ptr, int mode) { + auto const &re_info = game->edit_data.re_info; + auto const &r_info = game->edit_data.r_info; + auto r_ptr = m_ptr->race(); char silly_name[80], name[100]; bool_ seen, pron; @@ -1224,13 +1175,15 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) if (m_ptr->ego) { - if (re_info[m_ptr->ego].before) + auto const &monster_ego = re_info[m_ptr->ego]; + + if (monster_ego.before) { - sprintf(name, "%s %s", re_info[m_ptr->ego].name, r_ptr->name); + sprintf(name, "%s %s", monster_ego.name, r_ptr->name); } else { - sprintf(name, "%s %s", r_ptr->name, re_info[m_ptr->ego].name); + sprintf(name, "%s %s", r_ptr->name, monster_ego.name); } } else @@ -1246,13 +1199,13 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) { if (rand_int(2) == 0) { - monster_race *hallu_race; + monster_race const *hallu_race; do { - hallu_race = &r_info[randint(max_r_idx - 2)]; + hallu_race = &*uniform_element(r_info); } - while (hallu_race->flags1 & RF1_UNIQUE); + while ((!hallu_race->name) || (hallu_race->flags & RF_UNIQUE)); strcpy(silly_name, hallu_race->name); } @@ -1277,8 +1230,8 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) int kind = 0x00; /* Extract the gender (if applicable) */ - if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20; - else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10; + if (r_ptr->flags & RF_FEMALE) kind = 0x20; + else if (r_ptr->flags & RF_MALE) kind = 0x10; /* Ignore the gender (if desired) */ if (!m_ptr || !pron) kind = 0x00; @@ -1370,7 +1323,7 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) } /* Copy the result */ - (void)strcpy(desc, res); + strcpy(desc, res); } @@ -1378,8 +1331,8 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) else if ((mode & 0x02) && (mode & 0x01)) { /* The monster is visible, so use its gender */ - if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "herself"); - else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "himself"); + if (r_ptr->flags & RF_FEMALE) strcpy(desc, "herself"); + else if (r_ptr->flags & RF_MALE) strcpy(desc, "himself"); else strcpy(desc, "itself"); } @@ -1388,10 +1341,10 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) else { /* It could be a Unique */ - if ((r_ptr->flags1 & (RF1_UNIQUE)) && !(p_ptr->image)) + if ((r_ptr->flags & RF_UNIQUE) && !(p_ptr->image)) { /* Start with the name (thus nominative and objective) */ - (void)strcpy(desc, name); + strcpy(desc, name); } /* It could be an indefinite monster */ @@ -1400,8 +1353,8 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) /* XXX Check plurality for "some" */ /* Indefinite monsters need an indefinite article */ - (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a "); - (void)strcat(desc, name); + strcpy(desc, is_a_vowel(name[0]) ? "an " : "a "); + strcat(desc, name); } /* It could be a normal, definite, monster */ @@ -1409,11 +1362,11 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) { /* Definite monsters need a definite article */ if (m_ptr->status >= MSTATUS_PET) - (void)strcpy(desc, "your "); + strcpy(desc, "your "); else - (void)strcpy(desc, "the "); + strcpy(desc, "the "); - (void)strcat(desc, name); + strcat(desc, name); } /* Handle the Possessive as a special afterthought */ @@ -1422,25 +1375,30 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode) /* XXX Check for trailing "s" */ /* Simply append "apostrophe" and "s" */ - (void)strcat(desc, "'s"); + strcat(desc, "'s"); } } } void monster_race_desc(char *desc, int r_idx, int ego) { - monster_race *r_ptr = &r_info[r_idx]; + auto const &re_info = game->edit_data.re_info; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[r_idx]; char name[80]; if (ego) { - if (re_info[ego].before) + auto const &monster_ego = re_info[ego]; + + if (monster_ego.before) { - sprintf(name, "%s %s", re_info[ego].name, r_ptr->name); + sprintf(name, "%s %s", monster_ego.name, r_ptr->name); } else { - sprintf(name, "%s %s", r_ptr->name, re_info[ego].name); + sprintf(name, "%s %s", r_ptr->name, monster_ego.name); } } else @@ -1449,79 +1407,19 @@ void monster_race_desc(char *desc, int r_idx, int ego) } /* It could be a Unique */ - if (r_ptr->flags1 & RF1_UNIQUE) + if (r_ptr->flags & RF_UNIQUE) { /* Start with the name (thus nominative and objective) */ - (void)strcpy(desc, name); + strcpy(desc, name); } /* It could be a normal, definite, monster */ else { /* Definite monsters need a definite article */ - (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a "); - - (void)strcat(desc, name); - } -} - + strcpy(desc, is_a_vowel(name[0]) ? "an " : "a "); - -/* - * Learn about a monster (by "probing" it) - */ -void lore_do_probe(int m_idx) -{ - monster_type *m_ptr = &m_list[m_idx]; - - monster_race *r_ptr = &r_info[m_ptr->r_idx]; - - /* Hack -- Memorize some flags */ - r_ptr->r_flags1 = r_ptr->flags1; - r_ptr->r_flags2 = r_ptr->flags2; - r_ptr->r_flags3 = r_ptr->flags3; - - /* Update monster recall window */ - if (monster_race_idx == m_ptr->r_idx) - { - /* Window stuff */ - p_ptr->window |= (PW_MONSTER); - } -} - - -/* - * Take note that the given monster just dropped some treasure - * - * Note that learning the "GOOD"/"GREAT" flags gives information - * about the treasure (even when the monster is killed for the first - * time, such as uniques, and the treasure has not been examined yet). - * - * This "indirect" method is used to prevent the player from learning - * exactly how much treasure a monster can drop from observing only - * a single example of a drop. This method actually observes how much - * gold and items are dropped, and remembers that information to be - * described later by the monster recall code. - */ -void lore_treasure(int m_idx, int num_item, int num_gold) -{ - monster_type *m_ptr = &m_list[m_idx]; - - monster_race *r_ptr = &r_info[m_ptr->r_idx]; - - /* Note the number of things dropped */ - if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item; - if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold; - - /* Hack -- memorize the good/great flags */ - if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD); - if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT); - - /* Update monster recall window */ - if (monster_race_idx == m_ptr->r_idx) - { - /* Window stuff */ - p_ptr->window |= (PW_MONSTER); + strcat(desc, name); } } @@ -1547,9 +1445,9 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro) char m_name[80]; monster_desc(m_name, m_ptr, 0); - if (!(r_ptr->flags1 & RF1_UNIQUE)) + if (!(r_ptr->flags & RF_UNIQUE)) { - if (r_ptr->flags1 & RF1_FRIENDS) + if (r_ptr->flags & RF_FRIENDS) power /= 2; } else power *= 2; @@ -1560,7 +1458,7 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro) if (!(m_ptr->ml)) return ; /* Cannot see it for some reason */ - if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR)) + if (!(r_ptr->flags & RF_ELDRITCH_HORROR)) return ; /* oops */ @@ -1591,13 +1489,10 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro) /* Something frightening happens... */ msg_format("You behold the %s visage of %s!", horror_desc[(randint(MAX_HORROR)) - 1], m_name); - - r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR; - } /* Undead characters are 50% likely to be unaffected */ - if ((race_flags1_p(PR1_UNDEAD)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire"))) + if ((race_flags_p(PR_UNDEAD)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire"))) { if (randint(100) < (25 + (p_ptr->lev))) return; } @@ -1611,11 +1506,11 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro) { if (!p_ptr->resist_conf) { - (void)set_confused(p_ptr->confused + rand_int(4) + 4); + set_confused(p_ptr->confused + rand_int(4) + 4); } if ((!p_ptr->resist_chaos) && (randint(3) == 1)) { - (void) set_image(p_ptr->image + rand_int(250) + 150); + set_image(p_ptr->image + rand_int(250) + 150); } return; } @@ -1632,19 +1527,19 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro) { if (!p_ptr->resist_conf) { - (void)set_confused(p_ptr->confused + rand_int(4) + 4); + set_confused(p_ptr->confused + rand_int(4) + 4); } if (!p_ptr->free_act) { - (void)set_paralyzed(rand_int(4) + 4); + set_paralyzed(rand_int(4) + 4); } while (rand_int(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_INT, STAT_DEC_NORMAL); + do_dec_stat(A_INT, STAT_DEC_NORMAL); while (rand_int(100) > p_ptr->skill_sav) - (void)do_dec_stat(A_WIS, STAT_DEC_NORMAL); + do_dec_stat(A_WIS, STAT_DEC_NORMAL); if (!p_ptr->resist_chaos) { - (void) set_image(p_ptr->image + rand_int(250) + 150); + set_image(p_ptr->image + rand_int(250) + 150); } return; } @@ -1741,15 +1636,6 @@ void update_mon(int m_idx, bool_ full) /* Seen by vision */ bool_ easy = FALSE; - /* Seen by telepathy */ - bool_ hard = FALSE; - - /* Various extra flags */ - bool_ do_empty_mind = FALSE; - bool_ do_weird_mind = FALSE; - bool_ do_invisible = FALSE; - bool_ do_cold_blood = FALSE; - auto const r_ptr = m_ptr->race(); /* Calculate distance */ @@ -1788,61 +1674,59 @@ void update_mon(int m_idx, bool_ full) { /* Infravision only works on "warm" creatures */ /* Below, we will need to know that infravision failed */ - if (r_ptr->flags2 & (RF2_COLD_BLOOD)) do_cold_blood = TRUE; - - /* Infravision works */ - if (!do_cold_blood) easy = flag = TRUE; + if (!(r_ptr->flags & RF_COLD_BLOOD)) + { + /* Infravision works */ + easy = flag = TRUE; + } } /* Use "illumination" */ if (player_can_see_bold(fy, fx)) { - /* Take note of invisibility */ - if (r_ptr->flags2 & (RF2_INVISIBLE)) do_invisible = TRUE; - /* Visible, or detectable, monsters get seen */ - if (!do_invisible || p_ptr->see_inv) easy = flag = TRUE; + if (p_ptr->see_inv || !(r_ptr->flags & RF_INVISIBLE)) + { + easy = flag = TRUE; + } } } /* Telepathy can see all "nearby" monsters with "minds" */ - if (p_ptr->telepathy) { /* Assume we cant see */ - bool_ can_esp = FALSE; + bool can_esp = false; /* Different ESP */ - if ((p_ptr->telepathy & ESP_ORC) && (r_ptr->flags3 & RF3_ORC)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_SPIDER) && (r_ptr->flags7 & RF7_SPIDER)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_TROLL) && (r_ptr->flags3 & RF3_TROLL)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_DRAGON) && (r_ptr->flags3 & RF3_DRAGON)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_GIANT) && (r_ptr->flags3 & RF3_GIANT)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_DEMON) && (r_ptr->flags3 & RF3_DEMON)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_UNDEAD) && (r_ptr->flags3 & RF3_UNDEAD)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_EVIL) && (r_ptr->flags3 & RF3_EVIL)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_ANIMAL) && (r_ptr->flags3 & RF3_ANIMAL)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_THUNDERLORD) && (r_ptr->flags3 & RF3_THUNDERLORD)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_GOOD) && (r_ptr->flags3 & RF3_GOOD)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_NONLIVING) && (r_ptr->flags3 & RF3_NONLIVING)) can_esp = TRUE; - if ((p_ptr->telepathy & ESP_UNIQUE) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags3 & RF3_UNIQUE_4))) can_esp = TRUE; - if (p_ptr->telepathy & ESP_ALL) can_esp = TRUE; + can_esp |= ((p_ptr->computed_flags & ESP_ORC) && (r_ptr->flags & RF_ORC)); + can_esp |= ((p_ptr->computed_flags & ESP_SPIDER) && (r_ptr->flags & RF_SPIDER)); + can_esp |= ((p_ptr->computed_flags & ESP_TROLL) && (r_ptr->flags & RF_TROLL)); + can_esp |= ((p_ptr->computed_flags & ESP_DRAGON) && (r_ptr->flags & RF_DRAGON)); + can_esp |= ((p_ptr->computed_flags & ESP_GIANT) && (r_ptr->flags & RF_GIANT)); + can_esp |= ((p_ptr->computed_flags & ESP_DEMON) && (r_ptr->flags & RF_DEMON)); + can_esp |= ((p_ptr->computed_flags & ESP_UNDEAD) && (r_ptr->flags & RF_UNDEAD)); + can_esp |= ((p_ptr->computed_flags & ESP_EVIL) && (r_ptr->flags & RF_EVIL)); + can_esp |= ((p_ptr->computed_flags & ESP_ANIMAL) && (r_ptr->flags & RF_ANIMAL)); + can_esp |= ((p_ptr->computed_flags & ESP_THUNDERLORD) && (r_ptr->flags & RF_THUNDERLORD)); + can_esp |= ((p_ptr->computed_flags & ESP_GOOD) && (r_ptr->flags & RF_GOOD)); + can_esp |= ((p_ptr->computed_flags & ESP_NONLIVING) && (r_ptr->flags & RF_NONLIVING)); + can_esp |= ((p_ptr->computed_flags & ESP_UNIQUE) && ((r_ptr->flags & RF_UNIQUE))); + can_esp |= bool(p_ptr->computed_flags & ESP_ALL); /* Only do this when we can really detect monster */ if (can_esp) { /* Empty mind, no telepathy */ - if (r_ptr->flags2 & (RF2_EMPTY_MIND)) + if (r_ptr->flags & RF_EMPTY_MIND) { - do_empty_mind = TRUE; + /* No telepathy */ } /* Weird mind, occasional telepathy */ - else if (r_ptr->flags2 & (RF2_WEIRD_MIND)) + else if (r_ptr->flags & RF_WEIRD_MIND) { - do_weird_mind = TRUE; if (rand_int(100) < 10) { - hard = TRUE; flag = TRUE; } } @@ -1850,7 +1734,6 @@ void update_mon(int m_idx, bool_ full) /* Normal mind, allow telepathy */ else { - hard = TRUE; flag = TRUE; } } @@ -1882,29 +1765,15 @@ void update_mon(int m_idx, bool_ full) /* Update monster list window */ p_ptr->window |= (PW_M_LIST); - /* Hack -- Count "fresh" sightings */ - if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++; - /* Disturb on appearance */ - if (disturb_move) + if (options->disturb_move) { - if (disturb_pets || (is_friend(m_ptr) <= 0)) disturb(1); + if (options->disturb_pets || (is_friend(m_ptr) <= 0)) + { + disturb(); + } } } - - /* Apply telepathy */ - if (hard) - { - /* Hack -- Memorize mental flags */ - if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART); - if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID); - } - - /* Memorize various observable flags */ - if (do_empty_mind) r_ptr->r_flags2 |= (RF2_EMPTY_MIND); - if (do_weird_mind) r_ptr->r_flags2 |= (RF2_WEIRD_MIND); - if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD); - if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE); } /* The monster is not visible */ @@ -1926,9 +1795,12 @@ void update_mon(int m_idx, bool_ full) p_ptr->window |= (PW_M_LIST); /* Disturb on disappearance*/ - if (disturb_move) + if (options->disturb_move) { - if (disturb_pets || (is_friend(m_ptr) <= 0)) disturb(1); + if (options->disturb_pets || (is_friend(m_ptr) <= 0)) + { + disturb(); + } } } } @@ -1940,7 +1812,7 @@ void update_mon(int m_idx, bool_ full) if (m_ptr->ml != old_ml) { - if (r_ptr->flags2 & RF2_ELDRITCH_HORROR) + if (r_ptr->flags & RF_ELDRITCH_HORROR) { sanity_blast(m_ptr, FALSE); } @@ -1953,9 +1825,12 @@ void update_mon(int m_idx, bool_ full) m_ptr->mflag |= (MFLAG_VIEW); /* Disturb on appearance */ - if (disturb_near) + if (options->disturb_near) { - if (disturb_pets || (is_friend(m_ptr) <= 0)) disturb(1); + if (options->disturb_pets || (is_friend(m_ptr) <= 0)) + { + disturb(); + } } } @@ -1974,9 +1849,12 @@ void update_mon(int m_idx, bool_ full) p_ptr->window |= (PW_M_LIST); /* Disturb on disappearance */ - if (disturb_near) + if (options->disturb_near) { - if (disturb_pets || (is_friend(m_ptr) <= 0)) disturb(1); + if (options->disturb_pets || (is_friend(m_ptr) <= 0)) + { + disturb(); + } } } } @@ -2008,7 +1886,9 @@ void update_monsters(bool_ full) void monster_carry(monster_type *m_ptr, int m_idx, object_type *q_ptr) { - object_type *o_ptr; + auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; + auto &random_artifacts = game->random_artifacts; /* Get new object */ int o_idx = o_pop(); @@ -2016,7 +1896,7 @@ void monster_carry(monster_type *m_ptr, int m_idx, object_type *q_ptr) if (o_idx) { /* Get the item */ - o_ptr = &o_list[o_idx]; + object_type *o_ptr = &o_list[o_idx]; /* Structure copy */ object_copy(o_ptr, q_ptr); @@ -2036,7 +1916,7 @@ void monster_carry(monster_type *m_ptr, int m_idx, object_type *q_ptr) { a_info[q_ptr->name1].cur_num = 0; } - else if (k_info[q_ptr->k_idx].flags3 & TR3_NORM_ART) + else if (k_info[q_ptr->k_idx].flags & TR_NORM_ART) { k_info[q_ptr->k_idx].artifact = 0; } @@ -2074,8 +1954,10 @@ static int possible_randart[] = bool_ kind_is_randart(int k_idx) { + auto const &k_info = game->edit_data.k_info; + int max; - object_kind *k_ptr = &k_info[k_idx]; + auto k_ptr = &k_info[k_idx]; if (!kind_is_legal(k_idx)) return (FALSE); @@ -2111,6 +1993,9 @@ bool_ place_monster_one_no_drop = FALSE; static s16b hack_m_idx_ii = 0; s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) { + auto &r_info = game->edit_data.r_info; + auto &alloc = game->alloc; + int i; char dummy[5]; bool_ add_level = FALSE; @@ -2180,7 +2065,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) /* Check for original monster race flags */ { - monster_race *r_ptr = &r_info[r_idx]; + auto r_ptr = &r_info[r_idx]; /* Paranoia */ if (!r_ptr->name) @@ -2198,7 +2083,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Ego Uniques are NOT to be created */ - if ((r_ptr->flags1 & RF1_UNIQUE) && ego) + if ((r_ptr->flags & RF_UNIQUE) && ego) { return 0; } @@ -2215,28 +2100,28 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Unallow some uniques to be generated outside of their quests/special levels/dungeons */ - if ((r_ptr->flags9 & RF9_SPECIAL_GENE) && (!m_allow_special[r_idx])) + if ((r_ptr->flags & RF_SPECIAL_GENE) && (!m_allow_special[r_idx])) { if (wizard) cmsg_format(TERM_L_RED, "WARNING: Refused monster(%d): SPECIAL_GENE", r_idx); return 0; } /* Disallow Spirits in The Void, now this *IS* an ugly hack, I hate to do it ... */ - if ((r_ptr->flags7 & RF7_SPIRIT) && (dungeon_type != DUNGEON_VOID)) + if ((r_ptr->flags & RF_SPIRIT) && (dungeon_type != DUNGEON_VOID)) { if (wizard) cmsg_format(TERM_L_RED, "WARNING: Refused monster(%d): SPIRIT in non VOID", r_idx); return 0; } /* Fully forbid it */ - if (r_ptr->flags9 & RF9_NEVER_GENE) + if (r_ptr->flags & RF_NEVER_GENE) { if (wizard) cmsg_print(TERM_L_RED, "WARNING: Refused monster: NEVER_GENE"); return 0; } /* Hack -- "unique" monsters must be "unique" */ - if ((r_ptr->flags1 & (RF1_UNIQUE)) && (r_ptr->max_num == -1) && (!m_allow_special[r_idx])) + if ((r_ptr->flags & RF_UNIQUE) && (r_ptr->max_num == -1) && (!m_allow_special[r_idx])) { /* Cannot create */ if (wizard) cmsg_format(TERM_L_RED, "WARNING: Refused monster %d: unique not unique", r_idx); @@ -2251,7 +2136,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Hack -- "unique" monsters must be "unique" */ - if ((r_ptr->flags1 & (RF1_UNIQUE)) && (r_ptr->cur_num >= r_ptr->max_num) && (r_ptr->max_num != -1) && (!bypass_r_ptr_max_num)) + if ((r_ptr->flags & RF_UNIQUE) && (r_ptr->cur_num >= r_ptr->max_num) && (r_ptr->max_num != -1) && (!bypass_r_ptr_max_num)) { /* Cannot create */ if (wizard) cmsg_format(TERM_L_RED, "WARNING: Refused monster %d: cur_num >= max_num", r_idx); @@ -2259,7 +2144,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Depth monsters may NOT be created out of depth */ - if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level)) + if ((r_ptr->flags & RF_FORCE_DEPTH) && (dun_level < r_ptr->level)) { /* Cannot create */ if (wizard) cmsg_print(TERM_L_RED, "WARNING: FORCE_DEPTH"); @@ -2270,10 +2155,13 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) if (r_ptr->level > dun_level) { /* Unique monsters */ - if (r_ptr->flags1 & (RF1_UNIQUE)) + if (r_ptr->flags & RF_UNIQUE) { /* Message for cheaters */ - if ((cheat_hear) || (p_ptr->precognition)) msg_format("Deep Unique (%s).", r_ptr->name); + if (options->cheat_hear || p_ptr->precognition) + { + msg_format("Deep Unique (%s).", r_ptr->name); + } /* Boost rating by twice delta-depth */ rating += (r_ptr->level - dun_level) * 2; @@ -2283,7 +2171,10 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) else { /* Message for cheaters */ - if ((cheat_hear) || (p_ptr->precognition)) msg_format("Deep Monster (%s).", r_ptr->name); + if (options->cheat_hear || p_ptr->precognition) + { + msg_format("Deep Monster (%s).", r_ptr->name); + } /* Boost rating by delta-depth */ rating += (r_ptr->level - dun_level); @@ -2291,10 +2182,13 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Note the monster */ - else if (r_ptr->flags1 & (RF1_UNIQUE)) + else if (r_ptr->flags & RF_UNIQUE) { /* Unique monsters induce message */ - if ((cheat_hear) || (p_ptr->precognition)) msg_format("Unique (%s).", r_ptr->name); + if (options->cheat_hear || p_ptr->precognition) + { + msg_format("Unique (%s).", r_ptr->name); + } } @@ -2346,11 +2240,11 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) m_ptr->status = status; /* Friendly? */ - if (m_ptr->status < MSTATUS_FRIEND && r_ptr->flags7 & RF7_PET) + if (m_ptr->status < MSTATUS_FRIEND && r_ptr->flags & RF_PET) { m_ptr->status = MSTATUS_FRIEND; } - if (m_ptr->status < MSTATUS_NEUTRAL && r_ptr->flags7 & RF7_NEUTRAL) + if (m_ptr->status < MSTATUS_NEUTRAL && r_ptr->flags & RF_NEUTRAL) { m_ptr->status = MSTATUS_NEUTRAL; } @@ -2369,12 +2263,12 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) /* Only if not fated to die */ if ((dungeon_type != DUNGEON_DEATH) && (!place_monster_one_no_drop)) { - const bool_ good = (r_ptr->flags1 & (RF1_DROP_GOOD)) ? TRUE : FALSE; - const bool_ great = (r_ptr->flags1 & (RF1_DROP_GREAT)) ? TRUE : FALSE; + const bool_ good = (r_ptr->flags & RF_DROP_GOOD) ? TRUE : FALSE; + const bool_ great = (r_ptr->flags & RF_DROP_GREAT) ? TRUE : FALSE; - const bool_ do_gold = (!(r_ptr->flags1 & (RF1_ONLY_ITEM))); - const bool_ do_item = (!(r_ptr->flags1 & (RF1_ONLY_GOLD))); - const bool_ do_mimic = (r_ptr->flags9 & (RF9_MIMIC)); + auto const do_gold = (r_ptr->flags & RF_ONLY_ITEM).empty(); + auto const do_item = (r_ptr->flags & RF_ONLY_GOLD).empty(); + auto const do_mimic = bool(r_ptr->flags & RF_MIMIC); const int force_coin = get_coin_type(r_ptr); @@ -2389,31 +2283,25 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) object_level = (dun_level + r_ptr->level) / 2; /* Determine how much we can drop */ - if ((r_ptr->flags1 & (RF1_DROP_60)) && (rand_int(100) < 60)) number++; - if ((r_ptr->flags1 & (RF1_DROP_90)) && (rand_int(100) < 90)) number++; - if (r_ptr->flags1 & (RF1_DROP_1D2)) number += damroll(1, 2); - if (r_ptr->flags1 & (RF1_DROP_2D2)) number += damroll(2, 2); - if (r_ptr->flags1 & (RF1_DROP_3D2)) number += damroll(3, 2); - if (r_ptr->flags1 & (RF1_DROP_4D2)) number += damroll(4, 2); - if (r_ptr->flags9 & (RF9_MIMIC)) number = 1; + if ((r_ptr->flags & RF_DROP_60) && (rand_int(100) < 60)) number++; + if ((r_ptr->flags & RF_DROP_90) && (rand_int(100) < 90)) number++; + if (r_ptr->flags & RF_DROP_1D2) number += damroll(1, 2); + if (r_ptr->flags & RF_DROP_2D2) number += damroll(2, 2); + if (r_ptr->flags & RF_DROP_3D2) number += damroll(3, 2); + if (r_ptr->flags & RF_DROP_4D2) number += damroll(4, 2); + if (r_ptr->flags & RF_MIMIC) number = 1; /* Hack -- handle creeping coins */ coin_type = force_coin; - if (r_ptr->flags7 & RF7_DROP_RANDART) + if (r_ptr->flags & RF_DROP_RANDART) { int tries = 1000; - obj_theme theme; - /* Get local object */ q_ptr = &forge; - theme.treasure = 101; - theme.combat = 101; - theme.magic = 101; - theme.tools = 101; - - init_match_theme(theme); + /* No theme */ + init_match_theme(obj_theme::no_theme()); /* Apply restriction */ get_obj_num_hook = kind_is_legal; @@ -2433,7 +2321,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } /* Invalidate the cached allocation table */ - alloc_kind_table_valid = FALSE; + alloc.kind_table_valid = false; if (tries) { @@ -2511,7 +2399,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) /* Assign maximal hitpoints */ - if (r_ptr->flags1 & (RF1_FORCE_MAXHP)) + if (r_ptr->flags & RF_FORCE_MAXHP) { m_ptr->maxhp = maxroll(r_ptr->hdice, r_ptr->hside); } @@ -2540,7 +2428,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) m_ptr->mspeed = m_ptr->speed; /* Hack -- small racial variety */ - if (!(r_ptr->flags1 & (RF1_UNIQUE))) + if (!(r_ptr->flags & RF_UNIQUE)) { /* Allow some small variation per monster */ i = extract_energy[m_ptr->speed] / 10; @@ -2548,18 +2436,18 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) } - if (dungeon_flags2 & DF2_ADJUST_LEVEL_1_2) + if (dungeon_flags & DF_ADJUST_LEVEL_1_2) { min_level = max_level = dun_level / 2; add_level = TRUE; } - if (dungeon_flags1 & DF1_ADJUST_LEVEL_1) + if (dungeon_flags & DF_ADJUST_LEVEL_1) { if (!min_level) min_level = dun_level; max_level = dun_level; add_level = TRUE; } - if (dungeon_flags1 & DF1_ADJUST_LEVEL_2) + if (dungeon_flags & DF_ADJUST_LEVEL_2) { if (!min_level) min_level = dun_level * 2; max_level = dun_level * 2; @@ -2571,7 +2459,7 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) m_ptr->energy = (byte)rand_int(100); /* Force monster to wait for player */ - if (r_ptr->flags1 & (RF1_FORCE_SLEEP)) + if (r_ptr->flags & RF_FORCE_SLEEP) { /* Monster is still being nice */ m_ptr->mflag |= (MFLAG_NICE); @@ -2593,23 +2481,23 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) /* Hack -- Count the number of "reproducers" */ - if (r_ptr->flags4 & (RF4_MULTIPLY)) num_repro++; + if (r_ptr->spells & SF_MULTIPLY) num_repro++; /* Hack -- Notice new multi-hued monsters */ - if (r_ptr->flags1 & (RF1_ATTR_MULTI)) shimmer_monsters = TRUE; + if (r_ptr->flags & RF_ATTR_MULTI) shimmer_monsters = TRUE; /* Count monsters on the level */ { /* Hack -- we need to modify the REAL r_info, not the fake one */ - monster_race *r_ptr = &r_info[r_idx]; + auto r_ptr = &r_info[r_idx]; /* Hack -- Count the monsters on the level */ r_ptr->cur_num++; } /* Unique monsters on saved levels should be "marked" */ - if ((r_ptr->flags1 & RF1_UNIQUE) && get_dungeon_save(dummy)) + if ((r_ptr->flags & RF_UNIQUE) && get_dungeon_save(dummy)) { r_ptr->on_saved = TRUE; } @@ -2636,7 +2524,9 @@ s16b place_monster_one(int y, int x, int r_idx, int ego, bool_ slp, int status) */ static bool_ place_monster_group(int y, int x, int r_idx, bool_ slp, int status) { - monster_race *r_ptr = &r_info[r_idx]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[r_idx]; int old, n, i; int total = 0, extra = 0; @@ -2731,9 +2621,10 @@ static int place_monster_idx = 0; */ static bool_ place_monster_okay(int r_idx) { - monster_race *r_ptr = &r_info[place_monster_idx]; + auto const &r_info = game->edit_data.r_info; - monster_race *z_ptr = &r_info[r_idx]; + auto r_ptr = &r_info[place_monster_idx]; + auto z_ptr = &r_info[r_idx]; /* Hack - Escorts have to have the same dungeon flag */ if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE); @@ -2745,7 +2636,7 @@ static bool_ place_monster_okay(int r_idx) if (z_ptr->level > r_ptr->level) return (FALSE); /* Skip unique monsters */ - if (z_ptr->flags1 & (RF1_UNIQUE)) return (FALSE); + if (z_ptr->flags & RF_UNIQUE) return (FALSE); /* Paranoia -- Skip identical monsters */ if (place_monster_idx == r_idx) return (FALSE); @@ -2775,8 +2666,10 @@ static bool_ place_monster_okay(int r_idx) */ bool_ place_monster_aux(int y, int x, int r_idx, bool_ slp, bool_ grp, int status) { + auto const &r_info = game->edit_data.r_info; + int i; - monster_race *r_ptr = &r_info[r_idx]; + auto r_ptr = &r_info[r_idx]; bool_ (*old_get_mon_num_hook)(int r_idx); @@ -2789,15 +2682,15 @@ bool_ place_monster_aux(int y, int x, int r_idx, bool_ slp, bool_ grp, int statu /* Friends for certain monsters */ - if (r_ptr->flags1 & (RF1_FRIENDS)) + if (r_ptr->flags & RF_FRIENDS) { /* Attempt to place a group */ - (void)place_monster_group(y, x, r_idx, slp, status); + place_monster_group(y, x, r_idx, slp, status); } /* Escorts for certain monsters */ - if (r_ptr->flags1 & (RF1_ESCORT)) + if (r_ptr->flags & RF_ESCORT) { old_get_mon_num_hook = get_mon_num_hook; @@ -2842,11 +2735,11 @@ bool_ place_monster_aux(int y, int x, int r_idx, bool_ slp, bool_ grp, int statu place_monster_one(ny, nx, z, pick_ego_monster(&r_info[z]), slp, status); /* Place a "group" of escorts if needed */ - if ((r_info[z].flags1 & (RF1_FRIENDS)) || - (r_ptr->flags1 & (RF1_ESCORTS))) + if ((r_info[z].flags & RF_FRIENDS) || + (r_ptr->flags & RF_ESCORTS)) { /* Place a group of monsters */ - (void)place_monster_group(ny, nx, z, slp, status); + place_monster_group(ny, nx, z, slp, status); } } @@ -2899,9 +2792,11 @@ bool_ place_monster(int y, int x, bool_ slp, bool_ grp) bool_ alloc_horde(int y, int x) { + auto const &r_info = game->edit_data.r_info; + int r_idx = 0; - monster_race * r_ptr = NULL; - monster_type * m_ptr; + monster_race const *r_ptr = NULL; + monster_type *m_ptr; int attempts = 1000; set_mon_num2_hook(y, x); @@ -2919,8 +2814,8 @@ bool_ alloc_horde(int y, int x) r_ptr = &r_info[r_idx]; - if (!(r_ptr->flags1 & (RF1_UNIQUE)) - && !(r_ptr->flags1 & (RF1_ESCORTS))) + if (!(r_ptr->flags & RF_UNIQUE) + && !(r_ptr->flags & RF_ESCORTS)) break; } @@ -2948,7 +2843,7 @@ bool_ alloc_horde(int y, int x) for (attempts = randint(10) + 5; attempts; attempts--) { - (void) summon_specific(m_ptr->fy, m_ptr->fx, dun_level, SUMMON_KIN); + summon_specific(m_ptr->fy, m_ptr->fx, dun_level, SUMMON_KIN); } return TRUE; @@ -2984,7 +2879,7 @@ bool_ alloc_monster(int dis, bool_ slp) if (!attempts_left) { - if (cheat_xtra || cheat_hear) + if (options->cheat_xtra || options->cheat_hear) { msg_print("Warning! Could not allocate a new monster. Small level?"); } @@ -2997,7 +2892,10 @@ bool_ alloc_monster(int dis, bool_ slp) { if (alloc_horde(y, x)) { - if ((cheat_hear) || (p_ptr->precognition)) msg_print("Monster horde."); + if (options->cheat_hear || p_ptr->precognition) + { + msg_print("Monster horde."); + } return (TRUE); } } @@ -3027,7 +2925,9 @@ static int summon_specific_type = 0; */ static bool_ summon_specific_okay(int r_idx) { - monster_race *r_ptr = &r_info[r_idx]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[r_idx]; bool_ okay = FALSE; @@ -3043,56 +2943,56 @@ static bool_ summon_specific_okay(int r_idx) case SUMMON_ANT: { okay = ((r_ptr->d_char == 'a') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_SPIDER: { okay = ((r_ptr->d_char == 'S') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_HOUND: { okay = (((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z')) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_HYDRA: { okay = ((r_ptr->d_char == 'M') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_ANGEL: { okay = ((r_ptr->d_char == 'A') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_DEMON: { - okay = ((r_ptr->flags3 & (RF3_DEMON)) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + okay = ((r_ptr->flags & RF_DEMON) && + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_UNDEAD: { - okay = ((r_ptr->flags3 & (RF3_UNDEAD)) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + okay = ((r_ptr->flags & RF_UNDEAD) && + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_DRAGON: { - okay = ((r_ptr->flags3 & (RF3_DRAGON)) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + okay = ((r_ptr->flags & RF_DRAGON) && + !(r_ptr->flags & RF_UNIQUE)); break; } @@ -3124,40 +3024,40 @@ static bool_ summon_specific_okay(int r_idx) case SUMMON_UNIQUE: { - okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE; + okay = (r_ptr->flags & RF_UNIQUE) ? TRUE : FALSE; break; } case SUMMON_BIZARRE1: { okay = ((r_ptr->d_char == 'm') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_BIZARRE2: { okay = ((r_ptr->d_char == 'b') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_BIZARRE3: { okay = ((r_ptr->d_char == 'Q') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_BIZARRE4: { okay = ((r_ptr->d_char == 'v') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_BIZARRE5: { okay = ((r_ptr->d_char == '$') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } @@ -3168,15 +3068,15 @@ static bool_ summon_specific_okay(int r_idx) (r_ptr->d_char == '=') || (r_ptr->d_char == '$') || (r_ptr->d_char == '|')) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_HI_DEMON: { - okay = ((r_ptr->flags3 & (RF3_DEMON)) && + okay = ((r_ptr->flags & RF_DEMON) && (r_ptr->d_char == 'U') && - !(r_ptr->flags1 & RF1_UNIQUE)); + !(r_ptr->flags & RF_UNIQUE)); break; } @@ -3184,34 +3084,34 @@ static bool_ summon_specific_okay(int r_idx) case SUMMON_KIN: { okay = ((r_ptr->d_char == summon_kin_type) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_DAWN: { okay = ((strstr(r_ptr->name, "the Dawn")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_ANIMAL: { - okay = ((r_ptr->flags3 & (RF3_ANIMAL)) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + okay = ((r_ptr->flags & RF_ANIMAL) && + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_ANIMAL_RANGER: { - okay = ((r_ptr->flags3 & (RF3_ANIMAL)) && + okay = ((r_ptr->flags & RF_ANIMAL) && (strchr("abcflqrwBCIJKMRS", r_ptr->d_char)) && - !(r_ptr->flags3 & (RF3_DRAGON)) && - !(r_ptr->flags3 & (RF3_EVIL)) && - !(r_ptr->flags3 & (RF3_UNDEAD)) && - !(r_ptr->flags3 & (RF3_DEMON)) && - !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_DRAGON) && + !(r_ptr->flags & RF_EVIL) && + !(r_ptr->flags & RF_UNDEAD) && + !(r_ptr->flags & RF_DEMON) && + !r_ptr->spells && + !(r_ptr->flags & RF_UNIQUE)); break; } @@ -3220,87 +3120,87 @@ static bool_ summon_specific_okay(int r_idx) okay = (((r_ptr->d_char == 'L') || (r_ptr->d_char == 'V') || (r_ptr->d_char == 'W')) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_HI_DRAGON_NO_UNIQUES: { okay = ((r_ptr->d_char == 'D') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_NO_UNIQUES: { - okay = (!(r_ptr->flags1 & (RF1_UNIQUE))); + okay = (!(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_PHANTOM: { okay = ((strstr(r_ptr->name, "Phantom")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_ELEMENTAL: { okay = ((strstr(r_ptr->name, "lemental")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_THUNDERLORD: { - okay = (r_ptr->flags3 & RF3_THUNDERLORD) ? TRUE : FALSE; + okay = (r_ptr->flags & RF_THUNDERLORD) ? TRUE : FALSE; break; } case SUMMON_BLUE_HORROR: { okay = ((strstr(r_ptr->name, "lue horror")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_BUG: { okay = ((strstr(r_ptr->name, "Software bug")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_RNG: { okay = ((strstr(r_ptr->name, "Random Number Generator")) && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_MINE: { - okay = (r_ptr->flags1 & RF1_NEVER_MOVE) ? TRUE : FALSE; + okay = (r_ptr->flags & RF_NEVER_MOVE) ? TRUE : FALSE; break; } case SUMMON_HUMAN: { okay = ((r_ptr->d_char == 'p') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_SHADOWS: { okay = ((r_ptr->d_char == 'G') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } case SUMMON_QUYLTHULG: { okay = ((r_ptr->d_char == 'Q') && - !(r_ptr->flags1 & (RF1_UNIQUE))); + !(r_ptr->flags & RF_UNIQUE)); break; } @@ -3602,14 +3502,16 @@ void monster_swap(int y1, int x1, int y2, int x2) */ static bool_ mutate_monster_okay(int r_idx) { - monster_race *r_ptr = &r_info[r_idx]; + auto const &r_info = game->edit_data.r_info; + + auto r_ptr = &r_info[r_idx]; bool_ okay = FALSE; /* Hack - Only summon dungeon monsters */ if (!monster_dungeon(r_idx)) return (FALSE); - okay = ((r_ptr->d_char == summon_kin_type) && !(r_ptr->flags1 & (RF1_UNIQUE)) + okay = ((r_ptr->d_char == summon_kin_type) && !(r_ptr->flags & RF_UNIQUE) && (r_ptr->level >= dun_level)); return okay; @@ -3822,22 +3724,33 @@ void message_pain(int m_idx, int dam) */ void update_smart_learn(int m_idx, int what) { - monster_type *m_ptr = &m_list[m_idx]; - /* Not allowed to learn */ - if (!smart_learn) return; + if (!options->smart_learn) + { + return; + } + + /* Fast path for DRS_NONE */ + if (what == DRS_NONE) + { + return; + } /* Get racial flags */ + auto m_ptr = &m_list[m_idx]; auto const r_ptr = m_ptr->race(); /* Too stupid to learn anything */ - if (r_ptr->flags2 & (RF2_STUPID)) return; + if (r_ptr->flags & RF_STUPID) + { + return; + } /* Not intelligent, only learn sometimes */ - if (!(r_ptr->flags2 & (RF2_SMART)) && magik(50)) return; - - - /* XXX XXX XXX */ + if (!(r_ptr->flags & RF_SMART) && magik(50)) + { + return; + } /* Analyze the knowledge */ switch (what) |