diff --git a/configure.ac b/configure.ac index 254fa4cb1a..346cca6654 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(hengband, 3.0.1.15-Beta) +AC_INIT(hengband, 3.0.1.16-Beta) AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_HEADERS(src/autoconf.h) diff --git a/doxygen/Hengband.doxyfile b/doxygen/Hengband.doxyfile index fe4f12aa64..7ab6bca5f4 100644 --- a/doxygen/Hengband.doxyfile +++ b/doxygen/Hengband.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = Hengband # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0.1.15-Beta +PROJECT_NUMBER = 3.0.1.16-Beta # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/src/autopick/autopick-entry.cpp b/src/autopick/autopick-entry.cpp index 19cd79553f..a3d50faf2f 100644 --- a/src/autopick/autopick-entry.cpp +++ b/src/autopick/autopick-entry.cpp @@ -457,12 +457,12 @@ void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, co auto realm_except_class = pc.equals(PlayerClassType::SORCERER) || pc.equals(PlayerClassType::RED_MAGE); PlayerRealm pr(player_ptr); - if ((pr.get_realm1_book() == tval) && !realm_except_class) { + if ((pr.realm1().get_book() == tval) && !realm_except_class) { entry->add(FLG_REALM1); name = false; } - if ((pr.get_realm2_book() == tval) && !realm_except_class) { + if ((pr.realm2().get_book() == tval) && !realm_except_class) { entry->add(FLG_REALM2); name = false; } diff --git a/src/autopick/autopick-matcher.cpp b/src/autopick/autopick-matcher.cpp index 3d024fabd1..ae98c8f8d9 100644 --- a/src/autopick/autopick-matcher.cpp +++ b/src/autopick/autopick-matcher.cpp @@ -317,11 +317,11 @@ bool is_autopick_match(PlayerType *player_ptr, const ItemEntity *o_ptr, const au auto realm_except_class = pc.equals(PlayerClassType::SORCERER) || pc.equals(PlayerClassType::RED_MAGE); PlayerRealm pr(player_ptr); - if (entry.has(FLG_REALM1) && ((pr.get_realm1_book() != tval) || realm_except_class)) { + if (entry.has(FLG_REALM1) && ((pr.realm1().get_book() != tval) || realm_except_class)) { return false; } - if (entry.has(FLG_REALM2) && ((pr.get_realm2_book() != tval) || realm_except_class)) { + if (entry.has(FLG_REALM2) && ((pr.realm2().get_book() != tval) || realm_except_class)) { return false; } diff --git a/src/birth/birth-select-realm.cpp b/src/birth/birth-select-realm.cpp index a8a3ca4358..d5d09fa0b1 100644 --- a/src/birth/birth-select-realm.cpp +++ b/src/birth/birth-select-realm.cpp @@ -28,77 +28,6 @@ struct birth_realm_type { int os; }; -static byte count_realm_selection(const uint32_t choices, int *count) -{ - byte auto_select = REALM_NONE; - if (choices & CH_LIFE) { - (*count)++; - auto_select = REALM_LIFE; - } - - if (choices & CH_SORCERY) { - (*count)++; - auto_select = REALM_SORCERY; - } - - if (choices & CH_NATURE) { - (*count)++; - auto_select = REALM_NATURE; - } - - if (choices & CH_CHAOS) { - (*count)++; - auto_select = REALM_CHAOS; - } - - if (choices & CH_DEATH) { - (*count)++; - auto_select = REALM_DEATH; - } - - if (choices & CH_TRUMP) { - (*count)++; - auto_select = REALM_TRUMP; - } - - if (choices & CH_ARCANE) { - (*count)++; - auto_select = REALM_ARCANE; - } - - if (choices & CH_ENCHANT) { - (*count)++; - auto_select = REALM_CRAFT; - } - - if (choices & CH_DAEMON) { - (*count)++; - auto_select = REALM_DAEMON; - } - - if (choices & CH_CRUSADE) { - (*count)++; - auto_select = REALM_CRUSADE; - } - - if (choices & CH_MUSIC) { - (*count)++; - auto_select = REALM_MUSIC; - } - - if (choices & CH_HISSATSU) { - (*count)++; - auto_select = REALM_HISSATSU; - } - - if (choices & CH_HEX) { - (*count)++; - auto_select = REALM_HEX; - } - - return auto_select; -} - static birth_realm_type *initialize_birth_realm_type(birth_realm_type *birth_realm_ptr) { birth_realm_ptr->cs = 0; @@ -112,7 +41,7 @@ static birth_realm_type *initialize_birth_realm_type(birth_realm_type *birth_rea return birth_realm_ptr; } -static void impose_first_realm(PlayerType *player_ptr, uint32_t *choices) +static void impose_first_realm(PlayerType *player_ptr, RealmChoices &choices) { if (player_ptr->realm2 == REALM_SELECT_CANCEL) { return; @@ -122,21 +51,21 @@ static void impose_first_realm(PlayerType *player_ptr, uint32_t *choices) return; } - if (is_good_realm(player_ptr->realm1)) { - *choices &= ~(CH_DEATH | CH_DAEMON); + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { + choices.reset({ REALM_DEATH, REALM_DAEMON }); } else { - *choices &= ~(CH_LIFE | CH_CRUSADE); + choices.reset({ REALM_LIFE, REALM_CRUSADE }); } } -static void analyze_realms(const PlayerType *player_ptr, const uint32_t choices, birth_realm_type *birth_realm_ptr) +static void analyze_realms(const PlayerType *player_ptr, const RealmChoices &choices, birth_realm_type *birth_realm_ptr) { - for (int i = 0; i < 32; i++) { - if ((choices & (1UL << i)) == 0) { + for (auto realm : EnumRange(REALM_LIFE, REALM_MAX)) { + if (choices.has_not(realm)) { continue; } - if (player_ptr->realm1 == i + 1) { + if (player_ptr->realm1 == realm) { if (player_ptr->realm2 == REALM_SELECT_CANCEL) { birth_realm_ptr->cs = birth_realm_ptr->n; } else { @@ -144,15 +73,15 @@ static void analyze_realms(const PlayerType *player_ptr, const uint32_t choices, } } - if (player_ptr->realm2 == i + 1) { + if (player_ptr->realm2 == realm) { birth_realm_ptr->cs = birth_realm_ptr->n; } birth_realm_ptr->sym[birth_realm_ptr->n] = I2A(birth_realm_ptr->n); - const auto buf = format("%c%c %s", birth_realm_ptr->sym[birth_realm_ptr->n], birth_realm_ptr->p2, realm_names[i + 1].data()); + const auto buf = format("%c%c %s", birth_realm_ptr->sym[birth_realm_ptr->n], birth_realm_ptr->p2, PlayerRealm::get_name(realm).data()); put_str(buf, 12 + (birth_realm_ptr->n / 5), 2 + 15 * (birth_realm_ptr->n % 5)); - birth_realm_ptr->picks[birth_realm_ptr->n++] = i + 1; + birth_realm_ptr->picks[birth_realm_ptr->n++] = realm; } } @@ -167,9 +96,9 @@ static void move_birth_realm_cursor(birth_realm_type *birth_realm_ptr) if (birth_realm_ptr->cs == birth_realm_ptr->n) { birth_realm_ptr->cur = format("%c%c %s", '*', birth_realm_ptr->p2, _("ランダム", "Random")); } else { + const auto &realm_name = PlayerRealm::get_name(birth_realm_ptr->picks[birth_realm_ptr->cs]); birth_realm_ptr->cur = format("%c%c %s", birth_realm_ptr->sym[birth_realm_ptr->cs], birth_realm_ptr->p2, - realm_names[birth_realm_ptr->picks[birth_realm_ptr->cs]].data()); - const auto &realm_name = realm_names[birth_realm_ptr->picks[birth_realm_ptr->cs]]; + realm_name.data()); c_put_str(TERM_L_BLUE, realm_name, 3, 40); prt(_("の特徴", ": Characteristic"), 3, 40 + realm_name->length()); prt(realm_subinfo[technic2magic(birth_realm_ptr->picks[birth_realm_ptr->cs]) - 1], 4, 40); @@ -271,15 +200,14 @@ static bool get_a_realm(PlayerType *player_ptr, birth_realm_type *birth_realm_pt * @return 選択した魔法領域のID * @details 領域数が0 (戦士等)or 1 (観光客等)なら自動での値を返す */ -static byte select_realm(PlayerType *player_ptr, uint32_t choices, int *count) +static byte select_realm(PlayerType *player_ptr, RealmChoices choices) { - byte auto_select = count_realm_selection(choices, count); clear_from(10); - if ((*count) < 2) { - return auto_select; + if (choices.count() <= 1) { + return choices.first().value_or(REALM_NONE); } - impose_first_realm(player_ptr, &choices); + impose_first_realm(player_ptr, choices); put_str(_("注意:魔法の領域の選択によりあなたが習得する呪文のタイプが決まります。", "Note: The realm of magic will determine which spells you can learn."), 23, 5); @@ -322,6 +250,21 @@ static bool check_realm_selection(PlayerType *player_ptr, int count) return false; } +static void print_choosed_realms(PlayerType *player_ptr) +{ + put_str(_("魔法 :", "Magic :"), 6, 1); + + PlayerRealm pr(player_ptr); + std::string choosed_realms; + if (player_ptr->realm2 == REALM_NONE) { + choosed_realms = pr.realm1().get_name(); + } else { + choosed_realms = format("%s, %s", pr.realm1().get_name().data(), pr.realm2().get_name().data()); + } + + c_put_str(TERM_L_BLUE, choosed_realms, 6, 15); +} + /*! * @brief 選択した魔法領域の解説を表示する / Choose the magical realms * @return ユーザが魔法領域の確定を選んだらTRUEを返す。 @@ -351,8 +294,8 @@ bool get_player_realms(PlayerType *player_ptr) } while (true) { - int count = 0; - player_ptr->realm1 = select_realm(player_ptr, realm_choices1[enum2i(player_ptr->pclass)], &count); + auto choices = PlayerRealm::get_realm1_choices(player_ptr->pclass); + player_ptr->realm1 = select_realm(player_ptr, choices); if (player_ptr->realm1 == REALM_SELECT_CANCEL) { return false; } @@ -363,7 +306,7 @@ bool get_player_realms(PlayerType *player_ptr) cleanup_realm_selection_window(); display_wrap_around(realm_explanations[technic2magic(player_ptr->realm1) - 1], 74, 12, 3); - if (check_realm_selection(player_ptr, count)) { + if (check_realm_selection(player_ptr, choices.count())) { break; } } @@ -374,14 +317,12 @@ bool get_player_realms(PlayerType *player_ptr) return true; } - /* Print the realm */ - put_str(_("魔法 :", "Magic :"), 6, 1); - c_put_str(TERM_L_BLUE, realm_names[player_ptr->realm1], 6, 15); + print_choosed_realms(player_ptr); /* Select the second realm */ while (true) { - int count = 0; - player_ptr->realm2 = select_realm(player_ptr, realm_choices2[enum2i(player_ptr->pclass)], &count); + auto choices = PlayerRealm::get_realm2_choices(player_ptr->pclass); + player_ptr->realm2 = select_realm(player_ptr, choices); if (player_ptr->realm2 == REALM_SELECT_CANCEL) { return false; @@ -393,15 +334,12 @@ bool get_player_realms(PlayerType *player_ptr) cleanup_realm_selection_window(); display_wrap_around(realm_explanations[technic2magic(player_ptr->realm2) - 1], 74, 12, 3); - if (check_realm_selection(player_ptr, count)) { + if (check_realm_selection(player_ptr, choices.count())) { break; } } - if (player_ptr->realm2) { - /* Print the realm */ - c_put_str(TERM_L_BLUE, format("%s, %s", realm_names[player_ptr->realm1].data(), realm_names[player_ptr->realm2].data()), 6, 15); - } + print_choosed_realms(player_ptr); return true; } diff --git a/src/birth/character-builder.cpp b/src/birth/character-builder.cpp index 7367d8b9f3..67c2ffa325 100644 --- a/src/birth/character-builder.cpp +++ b/src/birth/character-builder.cpp @@ -31,9 +31,9 @@ #include "player-info/race-types.h" #include "player/patron.h" #include "player/player-personality.h" +#include "player/player-realm.h" #include "player/player-sex.h" #include "player/race-info-table.h" -#include "realm/realm-names-table.h" #include "store/store-owners.h" #include "store/store.h" #include "system/player-type-definition.h" @@ -66,9 +66,10 @@ static void write_birth_diary(PlayerType *player_ptr) exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, mes_race); const auto mes_class = format(_("%s職業に%sを選択した。", "%schose %s class."), indent, class_info.at(player_ptr->pclass).title.data()); exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, mes_class); + PlayerRealm pr(player_ptr); if (player_ptr->realm1) { - const auto mes_realm2 = player_ptr->realm2 ? format(_("と%s", " and %s realms"), realm_names[player_ptr->realm2].data()) : _("", " realm"); - const auto mes_realm = format(_("%s魔法の領域に%s%sを選択した。", "%schose %s%s."), indent, realm_names[player_ptr->realm1].data(), mes_realm2.data()); + const auto mes_realm2 = player_ptr->realm2 ? format(_("と%s", " and %s realms"), pr.realm2().get_name().data()) : _("", " realm"); + const auto mes_realm = format(_("%s魔法の領域に%s%sを選択した。", "%schose %s%s."), indent, pr.realm1().get_name().data(), mes_realm2.data()); exe_write_diary(floor, DiaryKind::DESCRIPTION, 1, mes_realm); } diff --git a/src/cmd-action/cmd-spell.cpp b/src/cmd-action/cmd-spell.cpp index 07f2a264cd..7abfb92e21 100644 --- a/src/cmd-action/cmd-spell.cpp +++ b/src/cmd-action/cmd-spell.cpp @@ -699,7 +699,7 @@ static void change_realm2(PlayerType *player_ptr, int16_t next_realm) player_ptr->spell_forgotten2 = 0L; constexpr auto fmt_realm = _("魔法の領域を%sから%sに変更した。", "changed magic realm from %s to %s."); - const auto mes = format(fmt_realm, realm_names[player_ptr->realm2].data(), realm_names[next_realm].data()); + const auto mes = format(fmt_realm, PlayerRealm(player_ptr).realm2().get_name().data(), PlayerRealm::get_name(next_realm).data()); exe_write_diary(*player_ptr->current_floor_ptr, DiaryKind::DESCRIPTION, 0, mes); player_ptr->old_realm |= 1U << (player_ptr->realm2 - 1); player_ptr->realm2 = next_realm; @@ -770,9 +770,9 @@ void do_cmd_study(PlayerType *player_ptr) const auto tval = o_ptr->bi_key.tval(); const auto sval = *o_ptr->bi_key.sval(); PlayerRealm pr(player_ptr); - if (tval == pr.get_realm2_book()) { + if (tval == pr.realm2().get_book()) { increment = 32; - } else if (tval != pr.get_realm1_book()) { + } else if (tval != pr.realm1().get_book()) { if (!input_check(_("本当に魔法の領域を変更しますか?", "Really, change magic realm? "))) { return; } @@ -1003,7 +1003,7 @@ bool do_cmd_cast(PlayerType *player_ptr) const auto tval = o_ptr->bi_key.tval(); const auto sval = *o_ptr->bi_key.sval(); - if (!is_every_magic && (tval == PlayerRealm(player_ptr).get_realm2_book())) { + if (!is_every_magic && (tval == PlayerRealm(player_ptr).realm2().get_book())) { increment = 32; } diff --git a/src/cmd-item/cmd-destroy.cpp b/src/cmd-item/cmd-destroy.cpp index c4970438fb..a5e5f44547 100644 --- a/src/cmd-item/cmd-destroy.cpp +++ b/src/cmd-item/cmd-destroy.cpp @@ -25,9 +25,9 @@ #include "player-info/samurai-data-type.h" #include "player-status/player-energy.h" #include "player/attack-defense-types.h" +#include "player/player-realm.h" #include "player/special-defense-types.h" #include "racial/racial-android.h" -#include "realm/realm-names-table.h" #include "status/action-setter.h" #include "status/experience.h" #include "system/baseitem-info.h" @@ -129,7 +129,7 @@ static bool decide_magic_book_exp(PlayerType *player_ptr, const ItemEntity &dest } auto is_good_magic_realm = (tval == ItemKindType::LIFE_BOOK) || (tval == ItemKindType::CRUSADE_BOOK); - if (is_good_realm(player_ptr->realm1)) { + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { return !is_good_magic_realm; } else { return is_good_magic_realm; diff --git a/src/effect/effect-monster.cpp b/src/effect/effect-monster.cpp index e49cd78318..c85574c6bb 100644 --- a/src/effect/effect-monster.cpp +++ b/src/effect/effect-monster.cpp @@ -657,7 +657,7 @@ static void postprocess_by_effected_pet(PlayerType *player_ptr, EffectMonster *e * @param player_ptr プレイヤーへの参照ポインタ * @param em_ptr モンスター効果構造体への参照ポインタ */ -static void postprocess_by_riding_pet_effected(PlayerType *player_ptr, EffectMonster *em_ptr) +static void postprocess_by_riding_pet_effected(PlayerType *player_ptr, EffectMonster *em_ptr, FallOffHorseEffect *fall_off_horse_effect) { if (!player_ptr->riding || (player_ptr->riding != em_ptr->g_ptr->m_idx) || (em_ptr->dam <= 0)) { return; @@ -667,7 +667,9 @@ static void postprocess_by_riding_pet_effected(PlayerType *player_ptr, EffectMon em_ptr->dam = (em_ptr->dam + 1) / 2; } - rakubadam_m = (em_ptr->dam > 200) ? 200 : em_ptr->dam; + if (fall_off_horse_effect) { + fall_off_horse_effect->set_shake_off(em_ptr->dam); + } } /*! @@ -693,10 +695,10 @@ static void postprocess_by_taking_photo(PlayerType *player_ptr, EffectMonster *e * @param player_ptr プレイヤーへの参照ポインタ * @param em_ptr モンスター効果構造体への参照ポインタ */ -static void exe_affect_monster_postprocess(PlayerType *player_ptr, EffectMonster *em_ptr) +static void exe_affect_monster_postprocess(PlayerType *player_ptr, EffectMonster *em_ptr, FallOffHorseEffect *fall_off_horse_effect) { postprocess_by_effected_pet(player_ptr, em_ptr); - postprocess_by_riding_pet_effected(player_ptr, em_ptr); + postprocess_by_riding_pet_effected(player_ptr, em_ptr, fall_off_horse_effect); postprocess_by_taking_photo(player_ptr, em_ptr); project_m_n++; project_m_x = em_ptr->x; @@ -723,7 +725,7 @@ static void exe_affect_monster_postprocess(PlayerType *player_ptr, EffectMonster */ bool affect_monster( PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITION y, POSITION x, int dam, AttributeType attribute, BIT_FLAGS flag, bool see_s_msg, - std::optional cap_mon_ptr) + std::optional cap_mon_ptr, FallOffHorseEffect *fall_off_horse_effect) { EffectMonster tmp_effect(player_ptr, src_idx, r, y, x, dam, attribute, flag, see_s_msg); auto *em_ptr = &tmp_effect; @@ -757,6 +759,6 @@ bool affect_monster( RedrawingFlagsUpdater::get_instance().set_flag(SubWindowRedrawingFlag::MONSTER_LORE); } - exe_affect_monster_postprocess(player_ptr, em_ptr); + exe_affect_monster_postprocess(player_ptr, em_ptr, fall_off_horse_effect); return em_ptr->obvious; } diff --git a/src/effect/effect-monster.h b/src/effect/effect-monster.h index 28f8f6ffa8..15ce412d80 100644 --- a/src/effect/effect-monster.h +++ b/src/effect/effect-monster.h @@ -5,5 +5,6 @@ #include class CapturedMonsterType; +class FallOffHorseEffect; class PlayerType; -bool affect_monster(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, bool see_s_msg, std::optional cap_mon_ptr = std::nullopt); +bool affect_monster(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, bool see_s_msg, std::optional cap_mon_ptr = std::nullopt, FallOffHorseEffect *fall_off_horse_effect = nullptr); diff --git a/src/effect/effect-player.cpp b/src/effect/effect-player.cpp index 51feb37ceb..2ed49d60de 100644 --- a/src/effect/effect-player.cpp +++ b/src/effect/effect-player.cpp @@ -192,7 +192,7 @@ static void describe_effect_source(PlayerType *player_ptr, EffectPlayerType *ep_ * @return 何か一つでも効力があればTRUEを返す / TRUE if any "effects" of the projection were observed, else FALSE */ bool affect_player(MONSTER_IDX src_idx, PlayerType *player_ptr, concptr src_name, int r, POSITION y, POSITION x, int dam, AttributeType attribute, - BIT_FLAGS flag, project_func project) + BIT_FLAGS flag, FallOffHorseEffect &fall_off_horse_effect, project_func project) { EffectPlayerType tmp_effect(src_idx, dam, attribute, flag); auto *ep_ptr = &tmp_effect; @@ -219,8 +219,8 @@ bool affect_player(MONSTER_IDX src_idx, PlayerType *player_ptr, concptr src_name } } - if (player_ptr->riding && ep_ptr->dam > 0) { - rakubadam_p = (ep_ptr->dam > 200) ? 200 : ep_ptr->dam; + if (player_ptr->riding) { + fall_off_horse_effect.set_fall_off(ep_ptr->dam); } disturb(player_ptr, true, true); diff --git a/src/effect/effect-player.h b/src/effect/effect-player.h index c2a65295dd..0ad1242f7c 100644 --- a/src/effect/effect-player.h +++ b/src/effect/effect-player.h @@ -5,6 +5,7 @@ #include class MonsterEntity; +class FallOffHorseEffect; class EffectPlayerType { public: DEPTH rlev; // モンスターのレベル (但し0のモンスターは1になる). @@ -27,4 +28,4 @@ using project_func = ProjectResult (*)( PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION rad, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, std::optional cap_mon_ptr); bool affect_player(MONSTER_IDX src_idx, PlayerType *player_ptr, concptr src_name, int r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, - project_func project); + FallOffHorseEffect &fall_off_horse_effect, project_func project); diff --git a/src/effect/effect-processor.cpp b/src/effect/effect-processor.cpp index 820b2fe213..7f26d42d06 100644 --- a/src/effect/effect-processor.cpp +++ b/src/effect/effect-processor.cpp @@ -70,8 +70,6 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX src_idx, POSITIO POSITION gx[1024]{}; POSITION gy[1024]{}; POSITION gm[32]{}; - rakubadam_p = 0; - rakubadam_m = 0; monster_target_y = player_ptr->y; monster_target_x = player_ptr->x; @@ -352,6 +350,7 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX src_idx, POSITIO } } + FallOffHorseEffect fall_off_horse_effect(player_ptr); if (flag & (PROJECT_KILL)) { project_m_n = 0; project_m_x = 0; @@ -474,7 +473,7 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX src_idx, POSITIO } } - if (affect_monster(player_ptr, src_idx, effective_dist, pos.y, pos.x, dam, typ, flag, see_s_msg, cap_mon_ptr)) { + if (affect_monster(player_ptr, src_idx, effective_dist, pos.y, pos.x, dam, typ, flag, see_s_msg, cap_mon_ptr, &fall_off_horse_effect)) { res.notice = true; } } @@ -552,27 +551,14 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX src_idx, POSITIO who_name = monster_desc(player_ptr, &floor.m_list[src_idx], MD_WRONGDOER_NAME); } - if (affect_player(src_idx, player_ptr, who_name.data(), effective_dist, pos.y, pos.x, dam, typ, flag, project)) { + if (affect_player(src_idx, player_ptr, who_name.data(), effective_dist, pos.y, pos.x, dam, typ, flag, fall_off_horse_effect, project)) { res.notice = true; res.affected_player = true; } } } - if (player_ptr->riding) { - const auto m_name = monster_desc(player_ptr, &floor.m_list[player_ptr->riding], 0); - if (rakubadam_m > 0) { - if (process_fall_off_horse(player_ptr, rakubadam_m, false)) { - msg_format(_("%s^に振り落とされた!", "%s^ has thrown you off!"), m_name.data()); - } - } - - if (player_ptr->riding && rakubadam_p > 0) { - if (process_fall_off_horse(player_ptr, rakubadam_p, false)) { - msg_format(_("%s^から落ちてしまった!", "You have fallen from %s."), m_name.data()); - } - } - } + fall_off_horse_effect.apply(); return res; } diff --git a/src/effect/spells-effect-util.cpp b/src/effect/spells-effect-util.cpp index b9a23c265f..4faabedb87 100644 --- a/src/effect/spells-effect-util.cpp +++ b/src/effect/spells-effect-util.cpp @@ -1,8 +1,13 @@ #include "effect/spells-effect-util.h" #include "monster-race/race-indice-types.h" +#include "monster/monster-describer.h" +#include "pet/pet-fall-off.h" +#include "system/floor-type-definition.h" +#include "system/monster-entity.h" +#include "system/player-type-definition.h" +#include "view/display-messages.h" +#include -int rakubadam_m; -int rakubadam_p; bool sukekaku; int project_length = 0; @@ -17,3 +22,45 @@ CapturedMonsterType::CapturedMonsterType() : r_idx(MonsterRaceId::PLAYER) { } + +FallOffHorseEffect::FallOffHorseEffect(PlayerType *player_ptr) + : player_ptr(player_ptr) +{ +} + +void FallOffHorseEffect::set_shake_off(int damage) +{ + this->shake_off_damage = std::min(damage, FALL_OFF_DAMAGE_MAX); +} + +void FallOffHorseEffect::set_fall_off(int damage) +{ + this->fall_off_damage = std::min(damage, FALL_OFF_DAMAGE_MAX); +} + +void FallOffHorseEffect::apply() const +{ + if (!this->player_ptr->riding) { + return; + } + + if (this->shake_off_damage <= 0 && this->fall_off_damage <= 0) { + return; + } + + const auto &floor = *this->player_ptr->current_floor_ptr; + const auto m_name = monster_desc(this->player_ptr, &floor.m_list[player_ptr->riding], 0); + + if (this->shake_off_damage > 0) { + if (process_fall_off_horse(this->player_ptr, this->shake_off_damage, false)) { + msg_format(_("%s^に振り落とされた!", "%s^ has thrown you off!"), m_name.data()); + return; + } + } + + if (this->fall_off_damage > 0) { + if (process_fall_off_horse(this->player_ptr, this->fall_off_damage, false)) { + msg_format(_("%s^から落ちてしまった!", "You have fallen from %s."), m_name.data()); + } + } +} diff --git a/src/effect/spells-effect-util.h b/src/effect/spells-effect-util.h index 744138a7c5..d4c76c79be 100644 --- a/src/effect/spells-effect-util.h +++ b/src/effect/spells-effect-util.h @@ -3,10 +3,8 @@ #include "system/angband.h" #include -extern int rakubadam_m; /*!< 振り落とされた際のダメージ量 */ -extern int rakubadam_p; /*!< 落馬した際のダメージ量 */ - enum class MonsterRaceId : int16_t; +class PlayerType; class CapturedMonsterType { public: @@ -18,6 +16,21 @@ class CapturedMonsterType { std::string nickname = ""; }; +class FallOffHorseEffect { +public: + FallOffHorseEffect(PlayerType *player_ptr); + void set_shake_off(int damage); + void set_fall_off(int damage); + void apply() const; + +private: + constexpr static int FALL_OFF_DAMAGE_MAX = 200; + + PlayerType *player_ptr; + int shake_off_damage = 0; /*!< 振り落とされた際のダメージ量 */ + int fall_off_damage = 0; /*!< 落馬した際のダメージ量 */ +}; + extern bool sukekaku; extern int project_length; /*!< 投射の射程距離 */ diff --git a/src/info-reader/fixed-map-parser.cpp b/src/info-reader/fixed-map-parser.cpp index 7cecdc9d9e..95b09f2cff 100644 --- a/src/info-reader/fixed-map-parser.cpp +++ b/src/info-reader/fixed-map-parser.cpp @@ -16,7 +16,7 @@ #include "main/init-error-messages-table.h" #include "player-info/class-info.h" #include "player-info/race-info.h" -#include "realm/realm-names-table.h" +#include "player/player-realm.h" #include "system/angband-exceptions.h" #include "system/angband-system.h" #include "system/floor-type-definition.h" @@ -175,9 +175,9 @@ static std::string parse_fixed_map_expression(PlayerType *player_ptr, char **sp, } else if (streq(b + 1, "CLASS")) { v = cp_ptr->title.en_string(); } else if (streq(b + 1, "REALM1")) { - v = realm_names[player_ptr->realm1].en_string(); + v = PlayerRealm(player_ptr).realm1().get_name().en_string(); } else if (streq(b + 1, "REALM2")) { - v = realm_names[player_ptr->realm2].en_string(); + v = PlayerRealm(player_ptr).realm2().get_name().en_string(); } else if (streq(b + 1, "PLAYER")) { char tmp_player_name[32]; char *pn, *tpn; diff --git a/src/io-dump/character-dump.cpp b/src/io-dump/character-dump.cpp index 83cd42f888..bc337d5e20 100644 --- a/src/io-dump/character-dump.cpp +++ b/src/io-dump/character-dump.cpp @@ -22,6 +22,7 @@ #include "object/object-info.h" #include "pet/pet-util.h" #include "player-info/alignment.h" +#include "player/player-realm.h" #include "player/player-status-flags.h" #include "player/player-status-table.h" #include "player/race-info-table.h" @@ -432,7 +433,7 @@ static void dump_aux_realm_history(PlayerType *player_ptr, FILE *fff) if (!(player_ptr->old_realm & 1UL << i)) { continue; } - fprintf(fff, _("\n あなたはかつて%s魔法を使えた。", "\n You were able to use %s magic before."), realm_names[i + 1].data()); + fprintf(fff, _("\n あなたはかつて%s魔法を使えた。", "\n You were able to use %s magic before."), PlayerRealm::get_name(i + 1).data()); } fputc('\n', fff); diff --git a/src/io/pref-file-expressor.cpp b/src/io/pref-file-expressor.cpp index 0cf85a8c81..c69baa2da5 100644 --- a/src/io/pref-file-expressor.cpp +++ b/src/io/pref-file-expressor.cpp @@ -2,7 +2,7 @@ #include "game-option/runtime-arguments.h" #include "player-info/class-info.h" #include "player-info/race-info.h" -#include "realm/realm-names-table.h" +#include "player/player-realm.h" #include "system/player-type-definition.h" #include "system/system-variables.h" #include "term/z-form.h" @@ -183,9 +183,9 @@ std::string process_pref_file_expr(PlayerType *player_ptr, char **sp, char *fp) *tpn = '\0'; v = tmp_player_name; } else if (streq(b + 1, "REALM1")) { - v = realm_names[player_ptr->realm1].en_string(); + v = PlayerRealm(player_ptr).realm1().get_name().en_string(); } else if (streq(b + 1, "REALM2")) { - v = realm_names[player_ptr->realm2].en_string(); + v = PlayerRealm(player_ptr).realm2().get_name().en_string(); } else if (streq(b + 1, "LEVEL")) { v = format("%02d", player_ptr->lev); } else if (streq(b + 1, "AUTOREGISTER")) { diff --git a/src/io/read-pref-file.cpp b/src/io/read-pref-file.cpp index 02ccfa29b3..ed33aab04e 100644 --- a/src/io/read-pref-file.cpp +++ b/src/io/read-pref-file.cpp @@ -14,7 +14,7 @@ #include "io/pref-file-expressor.h" #include "player-info/class-info.h" #include "player-info/race-info.h" -#include "realm/realm-names-table.h" +#include "player/player-realm.h" #include "system/player-type-definition.h" #include "term/z-form.h" #include "util/angband-files.h" @@ -279,16 +279,18 @@ void close_auto_dump(FILE **fpp, std::string_view mark) void load_all_pref_files(PlayerType *player_ptr) { process_pref_file(player_ptr, "user.prf"); - process_pref_file(player_ptr, std::string("user-").append(ANGBAND_SYS).append(".prf")); - process_pref_file(player_ptr, std::string(rp_ptr->title).append(".prf")); - process_pref_file(player_ptr, std::string(cp_ptr->title).append(".prf")); - process_pref_file(player_ptr, std::string(player_ptr->base_name).append(".prf")); + process_pref_file(player_ptr, format("user-%s.prf", ANGBAND_SYS)); + constexpr auto fmt = "%s.prf"; + process_pref_file(player_ptr, format(fmt, rp_ptr->title.data())); + process_pref_file(player_ptr, format(fmt, cp_ptr->title.data())); + process_pref_file(player_ptr, format(fmt, player_ptr->base_name)); + PlayerRealm pr(player_ptr); if (player_ptr->realm1 != REALM_NONE) { - process_pref_file(player_ptr, std::string(realm_names[player_ptr->realm1]).append(".prf")); + process_pref_file(player_ptr, format(fmt, pr.realm1().get_name().data())); } if (player_ptr->realm2 != REALM_NONE) { - process_pref_file(player_ptr, std::string(realm_names[player_ptr->realm2]).append(".prf")); + process_pref_file(player_ptr, format(fmt, pr.realm2().get_name().data())); } autopick_load_pref(player_ptr, false); diff --git a/src/io/report.cpp b/src/io/report.cpp index 42b530090f..bf90663d23 100644 --- a/src/io/report.cpp +++ b/src/io/report.cpp @@ -19,8 +19,8 @@ #include "player-info/class-info.h" #include "player-info/race-info.h" #include "player/player-personality.h" +#include "player/player-realm.h" #include "player/player-status.h" -#include "realm/realm-names-table.h" #include "system/angband-system.h" #include "system/dungeon-info.h" #include "system/floor-type-definition.h" @@ -271,7 +271,8 @@ bool report_score(PlayerType *player_ptr) std::string personality_desc = ap_ptr->title.string(); personality_desc.append(_(ap_ptr->no ? "の" : "", " ")); - auto realm1_name = PlayerClass(player_ptr).equals(PlayerClassType::ELEMENTALIST) ? get_element_title(player_ptr->element) : realm_names[player_ptr->realm1].data(); + PlayerRealm pr(player_ptr); + auto realm1_name = PlayerClass(player_ptr).equals(PlayerClassType::ELEMENTALIST) ? get_element_title(player_ptr->element) : pr.realm1().get_name().data(); score_ss << format("name: %s\n", player_ptr->name) << format("version: %s\n", AngbandSystem::get_instance().build_version_expression(VersionExpression::FULL).data()) << format("score: %ld\n", calc_score(player_ptr)) @@ -287,7 +288,7 @@ bool report_score(PlayerType *player_ptr) << format("class: %s\n", cp_ptr->title.data()) << format("seikaku: %s\n", personality_desc.data()) << format("realm1: %s\n", realm1_name) - << format("realm2: %s\n", realm_names[player_ptr->realm2].data()) + << format("realm2: %s\n", pr.realm2().get_name().data()) << format("killer: %s\n", player_ptr->died_from.data()) << "-----charcter dump-----\n"; diff --git a/src/knowledge/knowledge-experiences.cpp b/src/knowledge/knowledge-experiences.cpp index 27d0b71528..3d819baf1d 100644 --- a/src/knowledge/knowledge-experiences.cpp +++ b/src/knowledge/knowledge-experiences.cpp @@ -13,7 +13,6 @@ #include "player/player-realm.h" #include "player/player-skill.h" #include "player/player-status.h" -#include "realm/realm-names-table.h" #include "spell/spells-execution.h" #include "spell/technic-info-table.h" #include "sv-definition/sv-bow-types.h" @@ -87,9 +86,9 @@ void do_cmd_knowledge_spell_exp(PlayerType *player_ptr) PlayerRealm pr(player_ptr); if (player_ptr->realm1 != REALM_NONE) { - fprintf(fff, _("%sの魔法書\n", "%s Spellbook\n"), realm_names[player_ptr->realm1].data()); + fprintf(fff, _("%sの魔法書\n", "%s Spellbook\n"), pr.realm1().get_name().data()); for (SPELL_IDX i = 0; i < 32; i++) { - const auto &spell = pr.get_realm1_spell_info(i); + const auto &spell = pr.realm1().get_spell_info(i); if (spell.slevel >= 99) { continue; @@ -123,9 +122,9 @@ void do_cmd_knowledge_spell_exp(PlayerType *player_ptr) } if (player_ptr->realm2 != REALM_NONE) { - fprintf(fff, _("%sの魔法書\n", "\n%s Spellbook\n"), realm_names[player_ptr->realm2].data()); + fprintf(fff, _("%sの魔法書\n", "\n%s Spellbook\n"), pr.realm2().get_name().data()); for (SPELL_IDX i = 0; i < 32; i++) { - const auto &spell = pr.get_realm2_spell_info(i); + const auto &spell = pr.realm2().get_spell_info(i); if (spell.slevel >= 99) { continue; diff --git a/src/knowledge/knowledge-self.cpp b/src/knowledge/knowledge-self.cpp index fcf29ebc54..87a204d0bf 100644 --- a/src/knowledge/knowledge-self.cpp +++ b/src/knowledge/knowledge-self.cpp @@ -15,6 +15,7 @@ #include "player-info/alignment.h" #include "player-info/class-info.h" #include "player/player-personality.h" +#include "player/player-realm.h" #include "player/player-status-table.h" #include "player/race-info-table.h" #include "realm/realm-names-table.h" @@ -81,14 +82,15 @@ static void dump_yourself(PlayerType *player_ptr, FILE *fff) dump_explanation(personality_explanations[player_ptr->ppersonality], fff); fprintf(fff, "\n"); + PlayerRealm pr(player_ptr); if (player_ptr->realm1) { - fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), realm_names[player_ptr->realm1].data()); + fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), pr.realm1().get_name().data()); dump_explanation(realm_explanations[technic2magic(player_ptr->realm1) - 1], fff); } fprintf(fff, "\n"); if (player_ptr->realm2) { - fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), realm_names[player_ptr->realm2].data()); + fprintf(fff, _("魔法: %s\n", "Realm: %s\n"), pr.realm2().get_name().data()); dump_explanation(realm_explanations[technic2magic(player_ptr->realm2) - 1], fff); } } diff --git a/src/locale/localized-string.h b/src/locale/localized-string.h index 3fa8d219b3..4fc5c88b98 100644 --- a/src/locale/localized-string.h +++ b/src/locale/localized-string.h @@ -11,7 +11,8 @@ * 日本語版において日本語の文字列とそれに対応する英語の文字列が * 必要な場合に使用する std::string のラッパー的なクラス */ -struct LocalizedString { +class LocalizedString { +public: LocalizedString() = default; LocalizedString(const std::string &localized, const std::string &english); diff --git a/src/object-hook/hook-magic.cpp b/src/object-hook/hook-magic.cpp index eefb398300..fa885b2f19 100644 --- a/src/object-hook/hook-magic.cpp +++ b/src/object-hook/hook-magic.cpp @@ -60,13 +60,14 @@ bool item_tester_learn_spell(PlayerType *player_ptr, const ItemEntity *o_ptr) return false; } - int32_t choices = realm_choices2[enum2i(player_ptr->pclass)]; + PlayerRealm pr(player_ptr); + auto choices = PlayerRealm::get_realm2_choices(player_ptr->pclass); PlayerClass pc(player_ptr); if (pc.equals(PlayerClassType::PRIEST)) { - if (is_good_realm(player_ptr->realm1)) { - choices &= ~(CH_DEATH | CH_DAEMON); + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { + choices.reset({ REALM_DEATH, REALM_DAEMON }); } else { - choices &= ~(CH_LIFE | CH_CRUSADE); + choices.reset({ REALM_LIFE, REALM_CRUSADE }); } } @@ -75,10 +76,10 @@ bool item_tester_learn_spell(PlayerType *player_ptr, const ItemEntity *o_ptr) return true; } - if (!is_magic(tval2realm(tval))) { + const auto realm = tval2realm(tval); + if (!is_magic(realm)) { return false; } - PlayerRealm pr(player_ptr); - return (pr.get_realm1_book() == tval) || (pr.get_realm2_book() == tval) || (choices & (0x0001U << (tval2realm(tval) - 1))); + return (pr.realm1().get_book() == tval) || (pr.realm2().get_book() == tval) || choices.has(realm); } diff --git a/src/object/object-info.cpp b/src/object/object-info.cpp index 16708f1af8..afc0effe8e 100644 --- a/src/object/object-info.cpp +++ b/src/object/object-info.cpp @@ -119,7 +119,7 @@ bool check_book_realm(PlayerType *player_ptr, const BaseitemKey &bi_key) } PlayerRealm pr(player_ptr); - return (pr.get_realm1_book() == tval) || (pr.get_realm2_book() == tval); + return (pr.realm1().get_book() == tval) || (pr.realm2().get_book() == tval); } ItemEntity *ref_item(PlayerType *player_ptr, INVENTORY_IDX i_idx) diff --git a/src/player-info/class-ability-info.cpp b/src/player-info/class-ability-info.cpp index 27bf3f4de7..9bf12bc349 100644 --- a/src/player-info/class-ability-info.cpp +++ b/src/player-info/class-ability-info.cpp @@ -1,6 +1,6 @@ #include "player-info/class-ability-info.h" #include "player-info/self-info-util.h" -#include "realm/realm-names-table.h" +#include "player/player-realm.h" #include "realm/realm-types.h" #include "system/player-type-definition.h" @@ -26,7 +26,7 @@ void set_class_ability_info(PlayerType *player_ptr, self_info_type *self_ptr) break; case PlayerClassType::PRIEST: - if (is_good_realm(player_ptr->realm1)) { + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { if (player_ptr->lev > 34) { self_ptr->info_list.emplace_back(_("あなたは武器を祝福することができる。(70 MP)", "You can bless a weapon (cost 70).")); } @@ -52,7 +52,7 @@ void set_class_ability_info(PlayerType *player_ptr, self_info_type *self_ptr) break; case PlayerClassType::PALADIN: - if (is_good_realm(player_ptr->realm1)) { + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { if (player_ptr->lev > 29) { self_ptr->info_list.emplace_back(_("あなたは聖なる槍を放つことができる。(30 MP)", "You can fire a holy spear (cost 30).")); } diff --git a/src/player/player-realm.cpp b/src/player/player-realm.cpp index dd2dadc430..94b11be6ea 100644 --- a/src/player/player-realm.cpp +++ b/src/player/player-realm.cpp @@ -1,4 +1,5 @@ #include "player/player-realm.h" +#include "locale/localized-string.h" #include "object/tval-types.h" #include "player-info/class-info.h" #include "realm/realm-types.h" @@ -8,6 +9,23 @@ namespace { +const std::map realm_names = { + { REALM_NONE, { "魔法なし", "none" } }, + { REALM_LIFE, { "生命", "Life" } }, + { REALM_SORCERY, { "仙術", "Sorcery" } }, + { REALM_NATURE, { "自然", "Nature" } }, + { REALM_CHAOS, { "カオス", "Chaos" } }, + { REALM_DEATH, { "暗黒", "Death" } }, + { REALM_TRUMP, { "トランプ", "Trump" } }, + { REALM_ARCANE, { "秘術", "Arcane" } }, + { REALM_CRAFT, { "匠", "Craft" } }, + { REALM_DAEMON, { "悪魔", "Daemon" } }, + { REALM_CRUSADE, { "破邪", "Crusade" } }, + { REALM_MUSIC, { "歌", "Music" } }, + { REALM_HISSATSU, { "武芸", "Kendo" } }, + { REALM_HEX, { "呪術", "Hex" } }, +}; + const std::map realm_books = { { REALM_NONE, ItemKindType::NONE }, { REALM_LIFE, ItemKindType::LIFE_BOOK }, @@ -25,83 +43,52 @@ const std::map realm_books = { { REALM_HEX, ItemKindType::HEX_BOOK }, }; -} - /*! * 職業毎に選択可能な第一領域魔法テーブル */ -const std::vector realm_choices1 = { - (CH_NONE), /* Warrior */ - (CH_LIFE | CH_SORCERY | CH_NATURE | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_ENCHANT | CH_DAEMON | CH_CRUSADE), /* Mage */ - (CH_LIFE | CH_DEATH | CH_DAEMON | CH_CRUSADE), /* Priest */ - (CH_SORCERY | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_ENCHANT), /* Rogue */ - (CH_NATURE), /* Ranger */ - (CH_CRUSADE | CH_DEATH), /* Paladin */ - (CH_ARCANE), /* Warrior-Mage */ - (CH_CHAOS | CH_DAEMON), /* Chaos-Warrior */ - (CH_LIFE | CH_NATURE | CH_DEATH | CH_ENCHANT), /* Monk */ - (CH_NONE), /* Mindcrafter */ - (CH_LIFE | CH_SORCERY | CH_NATURE | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_ENCHANT | CH_DAEMON | CH_CRUSADE | CH_HEX), /* High-Mage */ - (CH_ARCANE), /* Tourist */ - (CH_NONE), /* Imitator */ - (CH_TRUMP), /* Beastmaster */ - (CH_NONE), /* Sorcerer */ - (CH_NONE), /* Archer */ - (CH_NONE), /* Magic eater */ - (CH_MUSIC), /* Bard */ - (CH_NONE), /* Red Mage */ - (CH_HISSATSU), /* Samurai */ - (CH_LIFE | CH_NATURE | CH_DEATH | CH_ENCHANT | CH_CRUSADE), /* ForceTrainer */ - (CH_NONE), /* Blue Mage */ - (CH_NONE), /* Cavalry */ - (CH_NONE), /* Berserker */ - (CH_NONE), /* Weaponsmith */ - (CH_NONE), /* Mirror-master */ - (CH_NONE), /* Ninja */ - (CH_NONE), /* Sniper */ - (CH_NONE), /* Elementalist */ +const std::map realm1_choices = { + { PlayerClassType::MAGE, { REALM_LIFE, REALM_SORCERY, REALM_NATURE, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_CRAFT, REALM_DAEMON, REALM_CRUSADE } }, + { PlayerClassType::PRIEST, { REALM_LIFE, REALM_DEATH, REALM_DAEMON, REALM_CRUSADE } }, + { PlayerClassType::ROGUE, { REALM_SORCERY, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_CRAFT } }, + { PlayerClassType::RANGER, { REALM_NATURE } }, + { PlayerClassType::PALADIN, { REALM_CRUSADE, REALM_DEATH } }, + { PlayerClassType::WARRIOR_MAGE, { REALM_ARCANE } }, + { PlayerClassType::CHAOS_WARRIOR, { REALM_CHAOS, REALM_DAEMON } }, + { PlayerClassType::MONK, { REALM_LIFE, REALM_NATURE, REALM_DEATH, REALM_CRAFT } }, + { PlayerClassType::HIGH_MAGE, { REALM_LIFE, REALM_SORCERY, REALM_NATURE, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_CRAFT, REALM_DAEMON, REALM_CRUSADE, REALM_HEX } }, + { PlayerClassType::TOURIST, { REALM_ARCANE } }, + { PlayerClassType::BEASTMASTER, { REALM_TRUMP } }, + { PlayerClassType::BARD, { REALM_MUSIC } }, + { PlayerClassType::SAMURAI, { REALM_HISSATSU } }, + { PlayerClassType::FORCETRAINER, { REALM_LIFE, REALM_NATURE, REALM_DEATH, REALM_CRAFT, REALM_CRUSADE } }, }; /*! * 職業毎に選択可能な第二領域魔法テーブル */ -const std::vector realm_choices2 = { - (CH_NONE), /* Warrior */ - (CH_LIFE | CH_SORCERY | CH_NATURE | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_ENCHANT | CH_DAEMON | CH_CRUSADE), /* Mage */ - (CH_LIFE | CH_SORCERY | CH_NATURE | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_ENCHANT | CH_DAEMON | CH_CRUSADE), /* Priest */ - (CH_NONE), /* Rogue */ - (CH_SORCERY | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_DAEMON), /* Ranger */ - (CH_NONE), /* Paladin */ - (CH_LIFE | CH_NATURE | CH_CHAOS | CH_DEATH | CH_TRUMP | CH_ARCANE | CH_SORCERY | CH_ENCHANT | CH_DAEMON | CH_CRUSADE), /* Warrior-Mage */ - (CH_NONE), /* Chaos-Warrior */ - (CH_NONE), /* Monk */ - (CH_NONE), /* Mindcrafter */ - (CH_NONE), /* High-Mage */ - (CH_NONE), /* Tourist */ - (CH_NONE), /* Imitator */ - (CH_NONE), /* Beastmanster */ - (CH_NONE), /* Sorcerer */ - (CH_NONE), /* Archer */ - (CH_NONE), /* Magic eater */ - (CH_NONE), /* Bard */ - (CH_NONE), /* Red Mage */ - (CH_NONE), /* Samurai */ - (CH_NONE), /* ForceTrainer */ - (CH_NONE), /* Blue Mage */ - (CH_NONE), /* Cavalry */ - (CH_NONE), /* Berserker */ - (CH_NONE), /* Weaponsmith */ - (CH_NONE), /* Mirror-master */ - (CH_NONE), /* Ninja */ - (CH_NONE), /* Sniper */ - (CH_NONE), /* Elementalist */ +const std::map realm2_choices = { + { PlayerClassType::MAGE, { REALM_LIFE, REALM_SORCERY, REALM_NATURE, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_CRAFT, REALM_DAEMON, REALM_CRUSADE } }, + { PlayerClassType::PRIEST, { REALM_LIFE, REALM_SORCERY, REALM_NATURE, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_CRAFT, REALM_DAEMON, REALM_CRUSADE } }, + { PlayerClassType::RANGER, { REALM_SORCERY, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_DAEMON } }, + { PlayerClassType::WARRIOR_MAGE, { REALM_LIFE, REALM_NATURE, REALM_CHAOS, REALM_DEATH, REALM_TRUMP, REALM_ARCANE, REALM_SORCERY, REALM_CRAFT, REALM_DAEMON, REALM_CRUSADE } }, }; +} PlayerRealm::PlayerRealm(PlayerType *player_ptr) - : player_ptr(player_ptr) + : realm1_(player_ptr->realm1) + , realm2_(player_ptr->realm2) { } +const LocalizedString &PlayerRealm::get_name(int realm) +{ + const auto it = realm_names.find(i2enum(realm)); + if (it == realm_names.end()) { + THROW_EXCEPTION(std::invalid_argument, format("Invalid realm: %d", realm)); + } + return it->second; +} + const magic_type &PlayerRealm::get_spell_info(int realm, int spell_idx) { if (spell_idx < 0 || 32 <= spell_idx) { @@ -129,22 +116,55 @@ ItemKindType PlayerRealm::get_book(int realm) return it->second; } -const magic_type &PlayerRealm::get_realm1_spell_info(int num) const +RealmChoices PlayerRealm::get_realm1_choices(PlayerClassType pclass) +{ + const auto it = realm1_choices.find(pclass); + if (it == realm1_choices.end()) { + return {}; + } + return it->second; +} + +RealmChoices PlayerRealm::get_realm2_choices(PlayerClassType pclass) +{ + const auto it = realm2_choices.find(pclass); + if (it == realm2_choices.end()) { + return {}; + } + return it->second; +} + +const PlayerRealm::Realm &PlayerRealm::realm1() const +{ + return this->realm1_; +} + +const PlayerRealm::Realm &PlayerRealm::realm2() const +{ + return this->realm2_; +} + +PlayerRealm::Realm::Realm(int realm) + : realm(realm) +{ +} + +const LocalizedString &PlayerRealm::Realm::get_name() const { - return PlayerRealm::get_spell_info(this->player_ptr->realm1, num); + return PlayerRealm::get_name(this->realm); } -const magic_type &PlayerRealm::get_realm2_spell_info(int num) const +const magic_type &PlayerRealm::Realm::get_spell_info(int num) const { - return PlayerRealm::get_spell_info(this->player_ptr->realm2, num); + return PlayerRealm::get_spell_info(this->realm, num); } -ItemKindType PlayerRealm::get_realm1_book() const +ItemKindType PlayerRealm::Realm::get_book() const { - return PlayerRealm::get_book(this->player_ptr->realm1); + return PlayerRealm::get_book(this->realm); } -ItemKindType PlayerRealm::get_realm2_book() const +bool PlayerRealm::Realm::is_good_attribute() const { - return PlayerRealm::get_book(this->player_ptr->realm2); + return this->realm == REALM_LIFE || this->realm == REALM_CRUSADE; } diff --git a/src/player/player-realm.h b/src/player/player-realm.h index 14d99c8b38..89e84e101f 100644 --- a/src/player/player-realm.h +++ b/src/player/player-realm.h @@ -1,45 +1,44 @@ #pragma once +#include "realm/realm-types.h" #include "system/angband.h" +#include "util/flag-group.h" +#include #include -/* 職業ごとの選択可能な魔法領域 / Possible realms that can be chosen. */ -enum choosable_realm { - CH_NONE = 0x00, - CH_LIFE = 0x01, - CH_SORCERY = 0x02, - CH_NATURE = 0x04, - CH_CHAOS = 0x08, - CH_DEATH = 0x10, - CH_TRUMP = 0x20, - CH_ARCANE = 0x40, - CH_ENCHANT = 0x80, - CH_DAEMON = 0x100, - CH_CRUSADE = 0x200, - - CH_MUSIC = 0x8000, - CH_HISSATSU = 0x10000, - CH_HEX = 0x20000, -}; +using RealmChoices = FlagGroup; enum class ItemKindType : short; +enum class PlayerClassType : short; class PlayerType; +class LocalizedString; struct magic_type; class PlayerRealm { public: PlayerRealm(PlayerType *player_ptr); + static const LocalizedString &get_name(int realm); static const magic_type &get_spell_info(int realm, int num); static ItemKindType get_book(int realm); + static RealmChoices get_realm1_choices(PlayerClassType pclass); + static RealmChoices get_realm2_choices(PlayerClassType pclass); + + class Realm { + public: + Realm(int realm); + const LocalizedString &get_name() const; + const magic_type &get_spell_info(int num) const; + ItemKindType get_book() const; + bool is_good_attribute() const; - const magic_type &get_realm1_spell_info(int num) const; - const magic_type &get_realm2_spell_info(int num) const; - ItemKindType get_realm1_book() const; - ItemKindType get_realm2_book() const; + private: + int realm; + }; + + const Realm &realm1() const; + const Realm &realm2() const; private: - PlayerType *player_ptr; + Realm realm1_; + Realm realm2_; }; - -extern const std::vector realm_choices1; -extern const std::vector realm_choices2; diff --git a/src/player/player-status.cpp b/src/player/player-status.cpp index 4c868c7646..ab1e0467d1 100644 --- a/src/player/player-status.cpp +++ b/src/player/player-status.cpp @@ -555,8 +555,8 @@ static void update_num_of_spells(PlayerType *player_ptr) continue; } - const auto get_spell_info = (j < 32) ? &PlayerRealm::get_realm1_spell_info : &PlayerRealm::get_realm2_spell_info; - const auto &spell = (pr.*get_spell_info)(j % 32); + const auto &realm = (j < 32) ? pr.realm1() : pr.realm2(); + const auto &spell = realm.get_spell_info(j % 32); if (spell.slevel <= player_ptr->lev) { continue; @@ -651,8 +651,8 @@ static void update_num_of_spells(PlayerType *player_ptr) break; } - const auto get_spell_info = (j < 32) ? &PlayerRealm::get_realm1_spell_info : &PlayerRealm::get_realm2_spell_info; - const auto &spell = (pr.*get_spell_info)(j % 32); + const auto &realm = (j < 32) ? pr.realm1() : pr.realm2(); + const auto &spell = realm.get_spell_info(j % 32); if (spell.slevel > player_ptr->lev) { continue; @@ -692,7 +692,7 @@ static void update_num_of_spells(PlayerType *player_ptr) if (player_ptr->realm2 == REALM_NONE) { int k = 0; for (int j = 0; j < 32; j++) { - const auto &spell = pr.get_realm1_spell_info(j); + const auto &spell = pr.realm1().get_spell_info(j); if (spell.slevel > player_ptr->lev) { continue; diff --git a/src/racial/class-racial-switcher.cpp b/src/racial/class-racial-switcher.cpp index 94bbe1f4a6..07ebdf67f0 100644 --- a/src/racial/class-racial-switcher.cpp +++ b/src/racial/class-racial-switcher.cpp @@ -1,8 +1,8 @@ #include "racial/class-racial-switcher.h" #include "cmd-action/cmd-spell.h" #include "mind/mind-elementalist.h" +#include "player/player-realm.h" #include "racial/racial-util.h" -#include "realm/realm-names-table.h" #include "realm/realm-types.h" #include "system/player-type-definition.h" @@ -43,7 +43,7 @@ void switch_class_racial(PlayerType *player_ptr, rc_type *rc_ptr) rc_ptr->add_power(rpi, RC_IDX_CLASS_0); break; case PlayerClassType::PRIEST: - if (is_good_realm(player_ptr->realm1)) { + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { rpi = rpi_type(_("武器祝福", "Bless Weapon")); rpi.text = _("武器を祝福する。抵抗されることがある。", "Blesses a weapon. Some weapons can resist it."); rpi.min_level = 35; @@ -84,7 +84,7 @@ void switch_class_racial(PlayerType *player_ptr, rc_type *rc_ptr) rc_ptr->add_power(rpi, RC_IDX_CLASS_0); break; case PlayerClassType::PALADIN: - if (is_good_realm(player_ptr->realm1)) { + if (PlayerRealm(player_ptr).realm1().is_good_attribute()) { rpi = rpi_type(_("ホーリー・ランス", "Holy Lance")); rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl * 3); rpi.text = _("聖なる炎のビームを放つ。", "Fires a beam of holy fire."); diff --git a/src/racial/racial-switcher.cpp b/src/racial/racial-switcher.cpp index aa370c8042..9d689fe53d 100644 --- a/src/racial/racial-switcher.cpp +++ b/src/racial/racial-switcher.cpp @@ -52,13 +52,13 @@ #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" #include "player/player-damage.h" +#include "player/player-realm.h" #include "player/player-status.h" #include "racial/racial-android.h" #include "racial/racial-balrog.h" #include "racial/racial-draconian.h" #include "racial/racial-kutar.h" #include "racial/racial-vampire.h" -#include "realm/realm-names-table.h" #include "spell-class/spells-mirror-master.h" #include "spell-kind/spells-beam.h" #include "spell-kind/spells-detection.h" @@ -105,7 +105,7 @@ bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command case PlayerClassType::SORCERER: return eat_magic(player_ptr, player_ptr->lev * 2); case PlayerClassType::PRIEST: - if (!is_good_realm(player_ptr->realm1)) { + if (!PlayerRealm(player_ptr).realm1().is_good_attribute()) { (void)dispel_monsters(player_ptr, player_ptr->lev * 4); turn_monsters(player_ptr, player_ptr->lev * 4); banish_monsters(player_ptr, player_ptr->lev * 4); @@ -125,7 +125,7 @@ bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command return false; } - fire_beam(player_ptr, is_good_realm(player_ptr->realm1) ? AttributeType::HOLY_FIRE : AttributeType::HELL_FIRE, dir, player_ptr->lev * 3); + fire_beam(player_ptr, PlayerRealm(player_ptr).realm1().is_good_attribute() ? AttributeType::HOLY_FIRE : AttributeType::HELL_FIRE, dir, player_ptr->lev * 3); return true; case PlayerClassType::WARRIOR_MAGE: if (command == -3) { diff --git a/src/realm/realm-names-table.cpp b/src/realm/realm-names-table.cpp index d591be4e4c..51e51d04b6 100644 --- a/src/realm/realm-names-table.cpp +++ b/src/realm/realm-names-table.cpp @@ -1,27 +1 @@ #include "realm/realm-names-table.h" - -/*! - * 領域魔法名称 - */ -const std::vector realm_names = { - { "魔法なし", "none" }, - { "生命", "Life" }, - { "仙術", "Sorcery" }, - { "自然", "Nature" }, - { "カオス", "Chaos" }, - { "暗黒", "Death" }, - { "トランプ", "Trump" }, - { "秘術", "Arcane" }, - { "匠", "Craft" }, - { "悪魔", "Daemon" }, - { "破邪", "Crusade" }, - { "不明", "unknown" }, - { "不明", "unknown" }, - { "不明", "unknown" }, - { "不明", "unknown" }, - { "不明", "unknown" }, - { "歌", "Music" }, - { "武芸", "Kendo" }, - { "呪術", "Hex" }, - { "不明", "unknown" }, -}; diff --git a/src/realm/realm-names-table.h b/src/realm/realm-names-table.h index 7a517a4994..3ed7afa022 100644 --- a/src/realm/realm-names-table.h +++ b/src/realm/realm-names-table.h @@ -13,12 +13,9 @@ #include "util/enum-converter.h" #include -#define VALID_REALM (MAX_REALM + MAX_MAGIC - MIN_TECHNIC + 1) +constexpr auto VALID_REALM = std::ssize(MAGIC_REALM_RANGE) + std::ssize(TECHNIC_REALM_RANGE); #define is_magic(A) (((A) > REALM_NONE) && ((A) <= MAX_MAGIC)) enum class ItemKindType : short; -#define tval2realm(A) ((A)-ItemKindType::LIFE_BOOK + 1) +#define tval2realm(A) (i2enum((A)-ItemKindType::LIFE_BOOK + 1)) #define technic2magic(A) (is_magic(A) ? (A) : (A)-MIN_TECHNIC + 1 + MAX_MAGIC) -#define is_good_realm(REALM) ((REALM) == REALM_LIFE || (REALM) == REALM_CRUSADE) - -extern const std::vector realm_names; diff --git a/src/realm/realm-types.h b/src/realm/realm-types.h index 2fbc2bc150..7b3ecc130c 100644 --- a/src/realm/realm-types.h +++ b/src/realm/realm-types.h @@ -19,7 +19,7 @@ enum magic_realm_type { REALM_MUSIC = 16, REALM_HISSATSU = 17, REALM_HEX = 18, - MAX_REALM = 18, + REALM_MAX, }; constexpr auto MAGIC_REALM_RANGE = EnumRangeInclusive(REALM_LIFE, REALM_CRUSADE); diff --git a/src/spell-class/spells-mirror-master.cpp b/src/spell-class/spells-mirror-master.cpp index a0bc750442..ea6c60c6c4 100644 --- a/src/spell-class/spells-mirror-master.cpp +++ b/src/spell-class/spells-mirror-master.cpp @@ -248,8 +248,6 @@ void SpellsMirrorMaster::project_seeker_ray(int target_x, int target_y, int dam) { constexpr auto typ = AttributeType::SEEKER; BIT_FLAGS flag = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM | PROJECT_THRU | PROJECT_MIRROR; - rakubadam_p = 0; - rakubadam_m = 0; monster_target_y = this->player_ptr->y; monster_target_x = this->player_ptr->x; auto &floor = *this->player_ptr->current_floor_ptr; @@ -433,8 +431,6 @@ void SpellsMirrorMaster::project_super_ray(int target_x, int target_y, int dam) POSITION x2; constexpr auto typ = AttributeType::SUPER_RAY; BIT_FLAGS flag = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM | PROJECT_THRU | PROJECT_MIRROR; - rakubadam_p = 0; - rakubadam_m = 0; monster_target_y = this->player_ptr->y; monster_target_x = this->player_ptr->x; const auto &floor = *this->player_ptr->current_floor_ptr; diff --git a/src/spell/spell-info.cpp b/src/spell/spell-info.cpp index 5436953a02..e06239e431 100644 --- a/src/spell/spell-info.cpp +++ b/src/spell/spell-info.cpp @@ -36,7 +36,8 @@ MANA_POINT mod_need_mana(PlayerType *player_ptr, MANA_POINT need_mana, SPELL_IDX #define MANA_CONST 2400 #define MANA_DIV 4 #define DEC_MANA_DIV 3 - if ((realm > REALM_NONE) && (realm <= MAX_REALM)) { + const auto realm_enum = i2enum(realm); + if (MAGIC_REALM_RANGE.contains(realm_enum) || TECHNIC_REALM_RANGE.contains(realm_enum)) { need_mana = need_mana * (MANA_CONST + PlayerSkill::spell_exp_at(PlayerSkillRank::EXPERT) - PlayerSkill(player_ptr).exp_of_spell(realm, spell_id)) + (MANA_CONST - 1); need_mana *= player_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV; need_mana /= MANA_CONST * MANA_DIV; @@ -219,7 +220,8 @@ PERCENTAGE spell_chance(PlayerType *player_ptr, SPELL_IDX spell_id, int16_t use_ */ void print_spells(PlayerType *player_ptr, SPELL_IDX target_spell_id, const SPELL_IDX *spell_ids, int num, TERM_LEN y, TERM_LEN x, int16_t use_realm) { - if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && AngbandWorld::get_instance().wizard) { + const auto realm = i2enum(use_realm); + if ((!MAGIC_REALM_RANGE.contains(realm) && !TECHNIC_REALM_RANGE.contains(realm)) && AngbandWorld::get_instance().wizard) { msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm")); } diff --git a/src/spell/technic-info-table.h b/src/spell/technic-info-table.h index 4fce9f7b9c..2ee4dad006 100644 --- a/src/spell/technic-info-table.h +++ b/src/spell/technic-info-table.h @@ -3,7 +3,7 @@ #include "realm/realm-types.h" #include "system/angband.h" -#define NUM_TECHNIC (MAX_REALM - MIN_TECHNIC + 1) +constexpr auto NUM_TECHNIC = std::ssize(TECHNIC_REALM_RANGE); /* * The "name" of spell 'N' is stored as spell_names[X][N], diff --git a/src/system/angband-version.h b/src/system/angband-version.h index 0f4d0c329b..212633b65c 100644 --- a/src/system/angband-version.h +++ b/src/system/angband-version.h @@ -24,7 +24,7 @@ constexpr std::string_view ROOT_VARIANT_NAME("Hengband"); #define H_VER_MAJOR 3 //!< ゲームのバージョン定義(メジャー番号) #define H_VER_MINOR 0 //!< ゲームのバージョン定義(マイナー番号) #define H_VER_PATCH 1 //!< ゲームのバージョン定義(パッチ番号) -#define H_VER_EXTRA 15 //!< ゲームのバージョン定義(エクストラ番号) +#define H_VER_EXTRA 16 //!< ゲームのバージョン定義(エクストラ番号) /*! * @brief セーブファイルのバージョン(3.0.0から導入) diff --git a/src/util/object-sort.cpp b/src/util/object-sort.cpp index 4e4c86cafa..8b9b4457bd 100644 --- a/src/util/object-sort.cpp +++ b/src/util/object-sort.cpp @@ -47,19 +47,21 @@ bool object_sort_comp(PlayerType *player_ptr, ItemEntity *o_ptr, int32_t o_value const auto o_tval = o_ptr->bi_key.tval(); const auto j_tval = j_ptr->bi_key.tval(); PlayerRealm pr(player_ptr); - if ((o_tval == pr.get_realm1_book()) && (j_tval != pr.get_realm1_book())) { + const auto realm1_book = pr.realm1().get_book(); + const auto realm2_book = pr.realm2().get_book(); + if ((o_tval == realm1_book) && (j_tval != realm1_book)) { return true; } - if ((j_tval == pr.get_realm1_book()) && (o_tval != pr.get_realm1_book())) { + if ((j_tval == realm1_book) && (o_tval != realm1_book)) { return false; } - if ((o_tval == pr.get_realm2_book()) && (j_tval != pr.get_realm2_book())) { + if ((o_tval == realm2_book) && (j_tval != realm2_book)) { return true; } - if ((j_tval == pr.get_realm2_book()) && (o_tval != pr.get_realm2_book())) { + if ((j_tval == realm2_book) && (o_tval != realm2_book)) { return false; } diff --git a/src/view/display-player.cpp b/src/view/display-player.cpp index 22cde33576..96de6a740b 100644 --- a/src/view/display-player.cpp +++ b/src/view/display-player.cpp @@ -23,11 +23,11 @@ #include "player-info/mimic-info-table.h" #include "player/patron.h" #include "player/player-personality.h" +#include "player/player-realm.h" #include "player/player-sex.h" #include "player/player-status-flags.h" #include "player/player-status-table.h" #include "player/player-status.h" -#include "realm/realm-names-table.h" #include "system/baseitem-info.h" #include "system/floor-type-definition.h" #include "system/item-entity.h" @@ -42,6 +42,7 @@ #include "view/display-util.h" #include "view/status-first-page.h" #include "world/world.h" +#include #include /*! @@ -100,17 +101,18 @@ static void display_magic_realms(PlayerType *player_ptr) return; } - std::string tmp; if (PlayerClass(player_ptr).equals(PlayerClassType::ELEMENTALIST)) { - tmp = get_element_title(player_ptr->element); - } else if (player_ptr->realm2) { - tmp = realm_names[player_ptr->realm1]; - tmp.append(", ").append(realm_names[player_ptr->realm2]); - } else { - tmp = realm_names[player_ptr->realm1]; + display_player_one_line(ENTRY_REALM, get_element_title(player_ptr->element), TERM_L_BLUE); + return; } - display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE); + PlayerRealm pr(player_ptr); + std::stringstream ss; + ss << pr.realm1().get_name(); + if (player_ptr->realm2) { + ss << ", " << pr.realm2().get_name(); + } + display_player_one_line(ENTRY_REALM, ss.str(), TERM_L_BLUE); } /*! diff --git a/src/wizard/wizard-special-process.cpp b/src/wizard/wizard-special-process.cpp index 153032f34d..2734172db8 100644 --- a/src/wizard/wizard-special-process.cpp +++ b/src/wizard/wizard-special-process.cpp @@ -637,12 +637,12 @@ void wiz_reset_class(PlayerType *player_ptr) */ void wiz_reset_realms(PlayerType *player_ptr) { - const auto new_realm1 = input_numerics("1st Realm (None=0)", 0, MAX_REALM - 1, player_ptr->realm1); + const auto new_realm1 = input_numerics("1st Realm (None=0)", 0, REALM_MAX - 1, player_ptr->realm1); if (!new_realm1) { return; } - const auto new_realm2 = input_numerics("2nd Realm (None=0)", 0, MAX_REALM - 1, player_ptr->realm2); + const auto new_realm2 = input_numerics("2nd Realm (None=0)", 0, REALM_MAX - 1, player_ptr->realm2); if (!new_realm2) { return; } diff --git a/src/wizard/wizard-spoiler.cpp b/src/wizard/wizard-spoiler.cpp index 2fea0d9635..aefa2662be 100644 --- a/src/wizard/wizard-spoiler.cpp +++ b/src/wizard/wizard-spoiler.cpp @@ -17,7 +17,7 @@ #include "io/input-key-acceptor.h" #include "main/sound-of-music.h" #include "player-info/class-info.h" -#include "realm/realm-names-table.h" +#include "player/player-realm.h" #include "spell/spells-execution.h" #include "spell/spells-util.h" #include "system/angband-system.h" @@ -210,7 +210,7 @@ static SpoilerOutputResultType spoil_player_spell() } for (int16_t r = 1; r < MAX_MAGIC; r++) { - spoil_out(format("[Realm: %s]\n", realm_names[r].data())); + spoil_out(format("[Realm: %s]\n", PlayerRealm::get_name(r).data())); spoil_out("Name Lv Cst Dif Exp\n"); for (SPELL_IDX i = 0; i < 32; i++) { auto spell_ptr = &magic_ptr->info[r][i];