OSDN Git Service

[Refactor] #2200 Habu氏のコメントに従い、真に必要な箇所をstd::optionalで定義し、それ以外の箇所からの呼び出しはデフォルトでstd...
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 19 Feb 2022 15:02:01 +0000 (00:02 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 20 Feb 2022 00:53:23 +0000 (09:53 +0900)
37 files changed:
src/action/activation-execution.cpp
src/action/activation-execution.h
src/action/racial-execution.cpp
src/action/racial-execution.h
src/cmd-action/cmd-mind.cpp
src/cmd-action/cmd-mind.h
src/cmd-action/cmd-racial.cpp
src/cmd-action/cmd-racial.h
src/cmd-action/cmd-spell.cpp
src/cmd-action/cmd-spell.h
src/cmd-item/cmd-item.cpp
src/cmd-item/cmd-item.h
src/effect/effect-monster-charm.cpp
src/effect/effect-monster-charm.h
src/effect/effect-monster-switcher.cpp
src/effect/effect-monster-switcher.h
src/effect/effect-monster.cpp
src/effect/effect-monster.h
src/effect/effect-player.cpp
src/effect/effect-player.h
src/effect/effect-processor.cpp
src/effect/effect-processor.h
src/effect/spells-effect-util.cpp
src/effect/spells-effect-util.h
src/io/input-key-processor.cpp
src/mind/mind-mirror-master.cpp
src/mind/mind-mirror-master.h
src/racial/racial-switcher.cpp
src/racial/racial-switcher.h
src/specific-object/monster-ball.cpp
src/specific-object/monster-ball.h
src/spell-kind/spells-launcher.cpp
src/spell-kind/spells-launcher.h
src/store/cmd-store.cpp
src/store/cmd-store.h
src/store/store-key-processor.cpp
src/store/store-key-processor.h

index 5e3d4cb..a1d61d9 100644 (file)
@@ -220,7 +220,7 @@ static bool activate_whistle(PlayerType *player_ptr, ae_type *ae_ptr)
  * the user hits "escape" at the "direction" prompt.
  * </pre>
  */
-void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item, CapturedMonsterType *cap_mon_ptr)
+void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item)
 {
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
     ae_type tmp_ae;
@@ -245,7 +245,7 @@ void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item, CapturedMonsterTyp
     if (activate_whistle(player_ptr, ae_ptr))
         return;
 
-    if (exe_monster_capture(player_ptr, ae_ptr, cap_mon_ptr))
+    if (exe_monster_capture(player_ptr, ae_ptr))
         return;
 
     msg_print(_("おっと、このアイテムは始動できない。", "Oops.  That object cannot be activated."));
index c9e5d6b..f2ae6a9 100644 (file)
@@ -6,6 +6,5 @@
 
 #include "system/angband.h"
 
-class CapturedMonsterType;
 class PlayerType;
-void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item, CapturedMonsterType *cap_mon_ptr);
+void exe_activate(PlayerType *player_ptr, INVENTORY_IDX item);
index e501e30..835a82f 100644 (file)
  * @param command 発動するレイシャルのID
  * @return 処理を実際に実行した場合はTRUE、キャンセルした場合FALSEを返す。
  */
-bool exe_racial_power(PlayerType *player_ptr, const int32_t command, CapturedMonsterType *cap_mon_ptr)
+bool exe_racial_power(PlayerType *player_ptr, const int32_t command)
 {
     if (command <= -3)
-        return switch_class_racial_execution(player_ptr, command, cap_mon_ptr);
+        return switch_class_racial_execution(player_ptr, command);
 
     if (player_ptr->mimic_form)
         return switch_mimic_racial_execution(player_ptr);
index a1d91d1..a3ba0f7 100644 (file)
@@ -13,8 +13,7 @@ enum racial_level_check_result {
 };
 
 struct rpi_type;
-class CapturedMonsterType;
 class PlayerType;
 PERCENTAGE racial_chance(PlayerType *player_ptr, rpi_type *rpi_ptr);
 racial_level_check_result check_racial_level(PlayerType *player_ptr, rpi_type *rpi_ptr);
-bool exe_racial_power(PlayerType *player_ptr, const int32_t command, CapturedMonsterType *cap_mon_ptr);
+bool exe_racial_power(PlayerType *player_ptr, const int32_t command);
index d34148a..2d4b6ce 100644 (file)
@@ -273,7 +273,7 @@ static void check_mind_class(PlayerType *player_ptr, cm_type *cm_ptr)
     check_mind_mirror_master(player_ptr, cm_ptr);
 }
 
-static bool switch_mind_class(PlayerType *player_ptr, cm_type *cm_ptr, CapturedMonsterType *cap_mon_ptr)
+static bool switch_mind_class(PlayerType *player_ptr, cm_type *cm_ptr)
 {
     switch (cm_ptr->use_mind) {
     case MindKindType::MINDCRAFTER:
@@ -289,7 +289,7 @@ static bool switch_mind_class(PlayerType *player_ptr, cm_type *cm_ptr, CapturedM
         if (player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].is_mirror())
             cm_ptr->on_mirror = true;
 
-        cm_ptr->cast = cast_mirror_spell(player_ptr, i2enum<mind_mirror_master_type>(cm_ptr->n), cap_mon_ptr);
+        cm_ptr->cast = cast_mirror_spell(player_ptr, i2enum<mind_mirror_master_type>(cm_ptr->n));
         return true;
     case MindKindType::NINJUTSU:
         cm_ptr->cast = cast_ninja_spell(player_ptr, i2enum<mind_ninja_type>(cm_ptr->n));
@@ -313,11 +313,11 @@ static void mind_turn_passing(PlayerType *player_ptr, cm_type *cm_ptr)
     energy.set_player_turn_energy(100);
 }
 
-static bool judge_mind_chance(PlayerType *player_ptr, cm_type *cm_ptr, CapturedMonsterType *cap_mon_ptr)
+static bool judge_mind_chance(PlayerType *player_ptr, cm_type *cm_ptr)
 {
     if (randint0(100) >= cm_ptr->chance) {
         sound(SOUND_ZAP);
-        return switch_mind_class(player_ptr, cm_ptr, cap_mon_ptr) && cm_ptr->cast;
+        return switch_mind_class(player_ptr, cm_ptr) && cm_ptr->cast;
     }
 
     if (flush_failure)
@@ -372,7 +372,7 @@ static void process_hard_concentration(PlayerType *player_ptr, cm_type *cm_ptr)
 /*!
  * @brief 特殊技能コマンドのメインルーチン /
  */
-void do_cmd_mind(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_mind(PlayerType *player_ptr)
 {
     cm_type tmp_cm;
     cm_type *cm_ptr = initialize_cm_type(player_ptr, &tmp_cm);
@@ -391,7 +391,7 @@ void do_cmd_mind(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
     if (cm_ptr->chance > 95)
         cm_ptr->chance = 95;
 
-    if (!judge_mind_chance(player_ptr, cm_ptr, cap_mon_ptr))
+    if (!judge_mind_chance(player_ptr, cm_ptr))
         return;
 
     mind_turn_passing(player_ptr, cm_ptr);
index 7ee9b9d..fe8dac1 100644 (file)
@@ -1,7 +1,6 @@
 #pragma once
 
-class CapturedMonsterType;
 class PlayerType;
-void do_cmd_mind(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void do_cmd_mind(PlayerType *player_ptr);
 void do_cmd_mind_browse(PlayerType *player_ptr);
 void do_cmd_mind_browse(PlayerType *player_ptr);
index d3a82d0..ec8632d 100644 (file)
@@ -373,14 +373,14 @@ static bool racial_power_select_power(PlayerType *player_ptr, rc_type *rc_ptr)
  * @details
  * 戻り値の代わりにrc_ptr->castに使用の有無を入れる。
  */
-static void racial_power_cast_power(PlayerType *player_ptr, rc_type *rc_ptr, CapturedMonsterType *cap_mon_ptr)
+static void racial_power_cast_power(PlayerType *player_ptr, rc_type *rc_ptr)
 {
     auto *rpi_ptr = &rc_ptr->power_desc[rc_ptr->command_code];
 
     switch (check_racial_level(player_ptr, rpi_ptr)) {
     case RACIAL_SUCCESS:
         if (rpi_ptr->number < 0)
-            rc_ptr->cast = exe_racial_power(player_ptr, rpi_ptr->number, cap_mon_ptr);
+            rc_ptr->cast = exe_racial_power(player_ptr, rpi_ptr->number);
         else
             rc_ptr->cast = exe_mutation_power(player_ptr, i2enum<PlayerMutationType>(rpi_ptr->number));
         break;
@@ -425,7 +425,7 @@ static bool racial_power_reduce_mana(PlayerType *player_ptr, rc_type *rc_ptr)
  * @brief レイシャル・パワーコマンドのメインルーチン / Allow user to choose a power (racial / mutation) to activate
  * @param player_ptr プレイヤーへの参照ポインタ
  */
-void do_cmd_racial_power(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_racial_power(PlayerType *player_ptr)
 {
     if (player_ptr->wild_mode)
         return;
@@ -461,7 +461,7 @@ void do_cmd_racial_power(PlayerType *player_ptr, CapturedMonsterType *cap_mon_pt
     racial_power_make_prompt(rc_ptr);
 
     if (racial_power_select_power(player_ptr, rc_ptr) == RC_CONTINUE)
-        racial_power_cast_power(player_ptr, rc_ptr, cap_mon_ptr);
+        racial_power_cast_power(player_ptr, rc_ptr);
 
     if (!rc_ptr->cast) {
         energy.reset_player_turn();
index 49f63e6..191696d 100644 (file)
@@ -1,5 +1,4 @@
 #pragma once
 
-class CapturedMonsterType;
 class PlayerType;
-void do_cmd_racial_power(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void do_cmd_racial_power(PlayerType *player_ptr);
index 8263707..e801774 100644 (file)
@@ -544,14 +544,14 @@ static int get_spell(PlayerType *player_ptr, SPELL_IDX *sn, concptr prompt, OBJE
  * @param browse_only 魔法と技能の閲覧を行うならばTRUE
  * @return 魔道書を一冊も持っていないならTRUEを返す
  */
-static void confirm_use_force(PlayerType *player_ptr, bool browse_only, CapturedMonsterType *cap_mon_ptr)
+static void confirm_use_force(PlayerType *player_ptr, bool browse_only)
 {
     char which;
     COMMAND_CODE code;
 
     /* Get the item index */
     if (repeat_pull(&code) && (code == INVEN_FORCE)) {
-        browse_only ? do_cmd_mind_browse(player_ptr) : do_cmd_mind(player_ptr, cap_mon_ptr);
+        browse_only ? do_cmd_mind_browse(player_ptr) : do_cmd_mind(player_ptr);
         return;
     }
 
@@ -574,7 +574,7 @@ static void confirm_use_force(PlayerType *player_ptr, bool browse_only, Captured
     prt("", 0, 0);
 
     if (which == 'w') {
-        browse_only ? do_cmd_mind_browse(player_ptr) : do_cmd_mind(player_ptr, cap_mon_ptr);
+        browse_only ? do_cmd_mind_browse(player_ptr) : do_cmd_mind(player_ptr);
     }
 }
 
@@ -603,7 +603,7 @@ static FuncItemTester get_learnable_spellbook_tester(PlayerType *player_ptr)
  * and in the dark, primarily to allow browsing in stores.
  * </pre>
  */
-void do_cmd_browse(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_browse(PlayerType *player_ptr)
 {
     OBJECT_IDX item;
     OBJECT_SUBTYPE_VALUE sval;
@@ -630,7 +630,7 @@ void do_cmd_browse(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
 
     if (pc.equals(PlayerClassType::FORCETRAINER)) {
         if (player_has_no_spellbooks(player_ptr)) {
-            confirm_use_force(player_ptr, true, cap_mon_ptr);
+            confirm_use_force(player_ptr, true);
             return;
         }
     }
@@ -962,7 +962,7 @@ void do_cmd_study(PlayerType *player_ptr)
  * @param player_ptr プレイヤーへの参照ポインタ
  * @return 詠唱したらtrue
  */
-bool do_cmd_cast(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+bool do_cmd_cast(PlayerType *player_ptr)
 {
     OBJECT_IDX item;
     OBJECT_SUBTYPE_VALUE sval;
@@ -990,7 +990,7 @@ bool do_cmd_cast(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
 
     if (player_ptr->blind || no_lite(player_ptr)) {
         if (pc.equals(PlayerClassType::FORCETRAINER))
-            confirm_use_force(player_ptr, false, cap_mon_ptr);
+            confirm_use_force(player_ptr, false);
         else {
             msg_print(_("目が見えない!", "You cannot see!"));
             flush();
@@ -1018,7 +1018,7 @@ bool do_cmd_cast(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
 
     if (pc.equals(PlayerClassType::FORCETRAINER)) {
         if (player_has_no_spellbooks(player_ptr)) {
-            confirm_use_force(player_ptr, false, cap_mon_ptr);
+            confirm_use_force(player_ptr, false);
             return true; //!< 錬気キャンセル時の処理がない
         }
     }
@@ -1034,7 +1034,7 @@ bool do_cmd_cast(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
     if (!o_ptr) {
         if (item == INVEN_FORCE) /* the_force */
         {
-            do_cmd_mind(player_ptr, cap_mon_ptr);
+            do_cmd_mind(player_ptr);
             return true; //!< 錬気キャンセル時の処理がない
         }
         return false;
index 3db77e2..ba04dbc 100644 (file)
@@ -26,8 +26,7 @@ concptr info_power_dice(DICE_NUMBER dice, DICE_SID sides);
 concptr info_radius(POSITION rad);
 concptr info_weight(WEIGHT weight);
 
-class CapturedMonsterType;
 class PlayerType;
-void do_cmd_browse(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void do_cmd_browse(PlayerType *player_ptr);
 void do_cmd_study(PlayerType *player_ptr);
-bool do_cmd_cast(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+bool do_cmd_cast(PlayerType *player_ptr);
index 5557782..dbf968b 100644 (file)
@@ -230,7 +230,7 @@ void do_cmd_inscribe(PlayerType *player_ptr)
  * @details
  * XXX - Add actions for other item types
  */
-void do_cmd_use(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_use(PlayerType *player_ptr)
 {
     OBJECT_IDX item;
     ObjectType *o_ptr;
@@ -277,7 +277,7 @@ void do_cmd_use(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
         exe_fire(player_ptr, item, &player_ptr->inventory_list[INVEN_BOW], SP_NONE);
         break;
     default:
-        exe_activate(player_ptr, item, cap_mon_ptr);
+        exe_activate(player_ptr, item);
         break;
     }
 }
@@ -286,7 +286,7 @@ void do_cmd_use(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
  * @brief 装備を発動するコマンドのメインルーチン /
  * @param player_ptr プレイヤーへの参照ポインタ
  */
-void do_cmd_activate(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_activate(PlayerType *player_ptr)
 {
     OBJECT_IDX item;
     if (player_ptr->wild_mode || cmd_limit_arena(player_ptr))
@@ -299,5 +299,5 @@ void do_cmd_activate(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
     if (!choose_object(player_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), FuncItemTester(&ObjectType::is_activatable)))
         return;
 
-    exe_activate(player_ptr, item, cap_mon_ptr);
+    exe_activate(player_ptr, item);
 }
index 1995185..e3c0eef 100644 (file)
@@ -1,11 +1,10 @@
 #pragma once
 
-class CapturedMonsterType;
 class PlayerType;
 void do_cmd_inven(PlayerType *player_ptr);
 void do_cmd_drop(PlayerType *player_ptr);
 void do_cmd_observe(PlayerType *player_ptr);
 void do_cmd_uninscribe(PlayerType *player_ptr);
 void do_cmd_inscribe(PlayerType *player_ptr);
-void do_cmd_use(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
-void do_cmd_activate(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void do_cmd_use(PlayerType *player_ptr);
+void do_cmd_activate(PlayerType *player_ptr);
index 59fd605..ff2834b 100644 (file)
@@ -379,12 +379,13 @@ static int calcutate_capturable_hp(PlayerType *player_ptr, monster_type *m_ptr,
  * @param player_ptr プレイヤー情報への参照ポインタ
  * @param em_ptr 効果情報への参照ポインタ
  */
-static void effect_monster_captured(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr)
+static void effect_monster_captured(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> tmp_cap_mon_ptr)
 {
     if (em_ptr->m_ptr->mflag2.has(MonsterConstantFlagType::CHAMELEON))
         choose_new_monster(player_ptr, em_ptr->g_ptr->m_idx, false, MON_CHAMELEON);
 
     msg_format(_("%sを捕えた!", "You capture %^s!"), em_ptr->m_name);
+    auto cap_mon_ptr = tmp_cap_mon_ptr.value();
     cap_mon_ptr->r_idx = em_ptr->m_ptr->r_idx;
     cap_mon_ptr->speed = em_ptr->m_ptr->mspeed;
     cap_mon_ptr->current_hp = static_cast<short>(em_ptr->m_ptr->hp);
@@ -403,7 +404,7 @@ static void effect_monster_captured(PlayerType *player_ptr, effect_monster_type
  * @param em_ptr 効果情報への参照ポインタ
  * @return 効果発動結果
  */
-process_result effect_monster_capture(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr)
+process_result effect_monster_capture(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     auto *floor_ptr = player_ptr->current_floor_ptr;
 
index 5ebad90..4fc7676 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "system/angband.h"
+#include <optional>
 
 enum process_result;
 struct effect_monster_type;
@@ -13,4 +14,4 @@ process_result effect_monster_control_animal(PlayerType *player_ptr, effect_mons
 process_result effect_monster_charm_living(PlayerType *player_ptr, effect_monster_type *em_ptr);
 process_result effect_monster_domination(PlayerType *player_ptr, effect_monster_type *em_ptr);
 process_result effect_monster_crusade(PlayerType *player_ptr, effect_monster_type *em_ptr);
-process_result effect_monster_capture(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr);
+process_result effect_monster_capture(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> cap_mon_ptr);
index 78cefc3..27a7cea 100644 (file)
@@ -297,7 +297,7 @@ process_result effect_monster_wounds(effect_monster_type *em_ptr)
  * @param em_ptr モンスター効果構造体への参照ポインタ
  * @return ここのスイッチングで終るならTRUEかFALSE、後続処理を実行するならCONTINUE
  */
-process_result switch_effects_monster(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr)
+process_result switch_effects_monster(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     switch (em_ptr->attribute) {
     case AttributeType::PSY_SPEAR:
index 313b538..6769f17 100644 (file)
@@ -1,8 +1,9 @@
 #pragma once
 
 #include "system/angband.h"
+#include <optional>
 
 struct effect_monster_type;
 class CapturedMonsterType;
 class PlayerType;
-process_result switch_effects_monster(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr);
+process_result switch_effects_monster(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> cap_mon_ptr = std::nullopt);
index 71a6d48..4c40512 100644 (file)
@@ -114,7 +114,7 @@ static void make_description_of_affecred_monster(PlayerType *player_ptr, effect_
  * 完全な耐性を持っていたら、一部属性を除いて影響は及ぼさない
  * デバッグ属性、モンスター打撃、モンスター射撃であれば貫通する
  */
-static process_result exe_affect_monster_by_effect(PlayerType *player_ptr, effect_monster_type *em_ptr, CapturedMonsterType *cap_mon_ptr)
+static process_result exe_affect_monster_by_effect(PlayerType *player_ptr, effect_monster_type *em_ptr, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     const std::vector<AttributeType> effect_arrtibute = {
         AttributeType::OLD_CLONE,
@@ -148,7 +148,7 @@ static process_result exe_affect_monster_by_effect(PlayerType *player_ptr, effec
     ignore_res_all |= (em_ptr->attribute == AttributeType::MONSTER_SHOOT);
 
     if (any_bits(em_ptr->r_ptr->flagsr, RFR_RES_ALL) && ignore_res_all)
-        return switch_effects_monster(player_ptr, em_ptr, cap_mon_ptr);
+        return switch_effects_monster(player_ptr, em_ptr);
 
     em_ptr->note = _("には完全な耐性がある!", " is immune.");
     em_ptr->dam = 0;
@@ -651,7 +651,7 @@ static void exe_affect_monster_postprocess(PlayerType *player_ptr, effect_monste
  * 3.ペット及び撮影による事後効果
  */
 bool affect_monster(
-    PlayerType *player_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType attribute, BIT_FLAGS flag, bool see_s_msg, CapturedMonsterType *cap_mon_ptr)
+    PlayerType *player_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType attribute, BIT_FLAGS flag, bool see_s_msg, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     effect_monster_type tmp_effect;
     effect_monster_type *em_ptr = initialize_effect_monster(player_ptr, &tmp_effect, who, r, y, x, dam, attribute, flag, see_s_msg);
index d64cb7f..41b5e96 100644 (file)
@@ -2,7 +2,8 @@
 
 #include "system/angband.h"
 #include "effect/attribute-types.h"
+#include <optional>
 
 class CapturedMonsterType;
 class PlayerType;
-bool affect_monster(PlayerType *player_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, bool see_s_msg, CapturedMonsterType *cap_mon_ptr);
+bool affect_monster(PlayerType *player_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, bool see_s_msg, std::optional<CapturedMonsterType *> cap_mon_ptr = std::nullopt);
index b183034..8e5a6cb 100644 (file)
@@ -99,7 +99,7 @@ static bool process_bolt_reflection(PlayerType *player_ptr, EffectPlayerType *ep
         t_x = player_ptr->x - 1 + randint1(3);
     }
 
-    (*project)(player_ptr, 0, 0, t_y, t_x, ep_ptr->dam, ep_ptr->attribute, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE));
+    (*project)(player_ptr, 0, 0, t_y, t_x, ep_ptr->dam, ep_ptr->attribute, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE), std::nullopt);
     disturb(player_ptr, true, true);
     return true;
 }
@@ -204,7 +204,7 @@ bool affect_player(MONSTER_IDX who, PlayerType *player_ptr, concptr who_name, in
         GAME_TEXT m_name_self[MAX_MONSTER_NAME];
         monster_desc(player_ptr, m_name_self, ep_ptr->m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
         msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), ep_ptr->m_name, m_name_self);
-        (*project)(player_ptr, 0, 0, ep_ptr->m_ptr->fy, ep_ptr->m_ptr->fx, ep_ptr->get_damage, AttributeType::MISSILE, PROJECT_KILL);
+        (*project)(player_ptr, 0, 0, ep_ptr->m_ptr->fy, ep_ptr->m_ptr->fx, ep_ptr->get_damage, AttributeType::MISSILE, PROJECT_KILL, std::nullopt);
         if (player_ptr->tim_eyeeye) {
             set_tim_eyeeye(player_ptr, player_ptr->tim_eyeeye - 5, true);
         }
index c50dbda..96298fe 100644 (file)
@@ -1,7 +1,8 @@
 #pragma once
 
-#include "system/angband.h"
 #include "effect/attribute-types.h"
+#include "system/angband.h"
+#include <optional>
 
 struct monster_type;
 class EffectPlayerType {
@@ -17,15 +18,13 @@ public:
     AttributeType attribute;
     BIT_FLAGS flag;
     EffectPlayerType(MONSTER_IDX who, int dam, AttributeType attribute, BIT_FLAGS flag);
-
 };
 
-
 struct ProjectResult;
-
+class CapturedMonsterType;
 class PlayerType;
 using project_func = ProjectResult (*)(
-    PlayerType *player_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag);
+    PlayerType *player_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag, std::optional<CapturedMonsterType *> cap_mon_ptr);
 
 bool affect_player(MONSTER_IDX who, PlayerType *player_ptr, concptr who_name, int r, POSITION y, POSITION x, int dam, AttributeType typ, BIT_FLAGS flag,
     project_func project);
index f9fe4b9..7f51392 100644 (file)
@@ -88,7 +88,7 @@ static void next_mirror(PlayerType *player_ptr, POSITION *next_y, POSITION *next
  * @todo 引数にそのまま再代入していてカオスすぎる。直すのは簡単ではない
  */
 ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, const int dam,
-    const AttributeType typ, BIT_FLAGS flag)
+    const AttributeType typ, BIT_FLAGS flag, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     int dist;
     POSITION y1;
@@ -187,7 +187,6 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX who, POSITION ra
     path_n = projection_path(player_ptr, path_g, (project_length ? project_length : get_max_range(player_ptr)), y1, x1, y2, x2, flag);
     handle_stuff(player_ptr);
 
-    auto *cap_mon_ptr = g_cap_mon_ptr.get();
     if (typ == AttributeType::SEEKER) {
         int j;
         int last_i = 0;
index 787872a..b69828b 100644 (file)
@@ -11,8 +11,9 @@ struct ProjectResult {
     ProjectResult() = default;
 };
 
+class CapturedMonsterType;
 class EffectPlayerType;
 class PlayerType;
 ProjectResult project(
     PlayerType *player_ptr, const MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, const int dam, const AttributeType typ,
-    BIT_FLAGS flag);
+    BIT_FLAGS flag, std::optional<CapturedMonsterType *> cap_mon_ptr = std::nullopt);
index d0edf4f..11a0c67 100644 (file)
@@ -6,8 +6,6 @@ bool sukekaku;
 
 int project_length = 0;
 
-std::shared_ptr<CapturedMonsterType> g_cap_mon_ptr = std::make_shared<CapturedMonsterType>();
-
 int project_m_n;
 POSITION project_m_x;
 POSITION project_m_y;
index 523d381..9f94848 100644 (file)
@@ -1,7 +1,6 @@
 #pragma once
 
 #include "system/angband.h"
-#include <memory>
 
 extern int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
 extern int rakubadam_p; /*!< 落馬した際のダメージ量 */
@@ -16,8 +15,6 @@ public:
     int nickname;
 };
 
-extern std::shared_ptr<CapturedMonsterType> g_cap_mon_ptr;
-
 extern bool sukekaku;
 extern int project_length; /*!< 投射の射程距離 */
 
index 8119597..f9aab75 100644 (file)
@@ -169,7 +169,6 @@ void process_command(PlayerType *player_ptr)
         sniper_data->reset_concent = true;
     }
 
-    auto *cap_mon_ptr = g_cap_mon_ptr.get();
     auto *floor_ptr = player_ptr->current_floor_ptr;
     switch (command_cmd) {
     case ESCAPE:
@@ -289,7 +288,7 @@ void process_command(PlayerType *player_ptr)
         break;
     }
     case SPECIAL_KEY_STORE: {
-        do_cmd_store(player_ptr, cap_mon_ptr);
+        do_cmd_store(player_ptr);
         break;
     }
     case SPECIAL_KEY_BUILDING: {
@@ -375,7 +374,7 @@ void process_command(PlayerType *player_ptr)
         else if (pc.equals(PlayerClassType::SNIPER))
             do_cmd_snipe_browse(player_ptr);
         else
-            do_cmd_browse(player_ptr, cap_mon_ptr);
+            do_cmd_browse(player_ptr);
 
         break;
     }
@@ -435,7 +434,7 @@ void process_command(PlayerType *player_ptr)
         }
 
         if (pc.can_browse())
-            do_cmd_mind(player_ptr, cap_mon_ptr);
+            do_cmd_mind(player_ptr);
         else if (pc.equals(PlayerClassType::ELEMENTALIST))
             do_cmd_element(player_ptr);
         else if (pc.equals(PlayerClassType::IMITATOR))
@@ -451,7 +450,7 @@ void process_command(PlayerType *player_ptr)
         else if (pc.equals(PlayerClassType::SNIPER))
             do_cmd_snipe(player_ptr);
         else
-            (void)do_cmd_cast(player_ptr, cap_mon_ptr);
+            (void)do_cmd_cast(player_ptr);
 
         break;
     }
@@ -468,7 +467,7 @@ void process_command(PlayerType *player_ptr)
         break;
     }
     case 'A': {
-        do_cmd_activate(player_ptr, cap_mon_ptr);
+        do_cmd_activate(player_ptr);
         break;
     }
     case 'E': {
@@ -493,7 +492,7 @@ void process_command(PlayerType *player_ptr)
     }
     case 'z': {
         if (use_command && rogue_like_commands) {
-            do_cmd_use(player_ptr, cap_mon_ptr);
+            do_cmd_use(player_ptr);
         } else {
             do_cmd_zap_rod(player_ptr);
         }
@@ -510,14 +509,14 @@ void process_command(PlayerType *player_ptr)
     }
     case 'u': {
         if (use_command && !rogue_like_commands)
-            do_cmd_use(player_ptr, cap_mon_ptr);
+            do_cmd_use(player_ptr);
         else
             do_cmd_use_staff(player_ptr);
 
         break;
     }
     case 'U': {
-        do_cmd_racial_power(player_ptr, cap_mon_ptr);
+        do_cmd_racial_power(player_ptr);
         break;
     }
     case 'M': {
index 995f577..0d1ba61 100644 (file)
@@ -104,7 +104,7 @@ void remove_all_mirrors(PlayerType *player_ptr, bool explode)
  * @param dam ダメージ量
  * @return 効果があったらTRUEを返す
  */
-bool binding_field(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon_ptr)
+bool binding_field(PlayerType *player_ptr, int dam)
 {
     POSITION mirror_x[10], mirror_y[10]; /* 鏡はもっと少ない */
     int mirror_num = 0; /* 鏡の数 */
@@ -209,7 +209,7 @@ bool binding_field(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon
                 && centersign * ((point_x[1] - x) * (point_y[2] - y) - (point_y[1] - y) * (point_x[2] - x)) >= 0
                 && centersign * ((point_x[2] - x) * (point_y[0] - y) - (point_y[2] - y) * (point_x[0] - x)) >= 0) {
                 if (player_has_los_bold(player_ptr, y, x) && projectable(player_ptr, player_ptr->y, player_ptr->x, y, x)) {
-                    (void)affect_monster(player_ptr, 0, 0, y, x, dam, AttributeType::MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), true, cap_mon_ptr);
+                    (void)affect_monster(player_ptr, 0, 0, y, x, dam, AttributeType::MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), true);
                 }
             }
         }
@@ -228,14 +228,14 @@ bool binding_field(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon
  * @param dam ダメージ量
  * @return 効果があったらTRUEを返す
  */
-void seal_of_mirror(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon_ptr)
+void seal_of_mirror(PlayerType *player_ptr, int dam)
 {
     for (POSITION x = 0; x < player_ptr->current_floor_ptr->width; x++) {
         for (POSITION y = 0; y < player_ptr->current_floor_ptr->height; y++) {
             if (!player_ptr->current_floor_ptr->grid_array[y][x].is_mirror())
                 continue;
 
-            if (!affect_monster(player_ptr, 0, 0, y, x, dam, AttributeType::GENOCIDE, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), true, cap_mon_ptr))
+            if (!affect_monster(player_ptr, 0, 0, y, x, dam, AttributeType::GENOCIDE, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), true))
                 continue;
 
             if (!player_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
@@ -408,7 +408,7 @@ static int number_of_mirrors(floor_type *floor_ptr)
  * @param spell 発動する特殊技能のID
  * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
  */
-bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell, CapturedMonsterType *cap_mon_ptr)
+bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell)
 {
     DIRECTION dir;
     PLAYER_LEVEL plev = player_ptr->lev;
@@ -487,7 +487,7 @@ bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell, Ca
         fire_beam(player_ptr, AttributeType::SEEKER, dir, damroll(11 + (plev - 5) / 4, 8));
         break;
     case SEALING_MIRROR:
-        seal_of_mirror(player_ptr, plev * 4 + 100, cap_mon_ptr);
+        seal_of_mirror(player_ptr, plev * 4 + 100);
         break;
     case WATER_SHIELD:
         t = 20 + randint1(20);
@@ -530,7 +530,7 @@ bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell, Ca
         set_multishadow(player_ptr, 6 + randint1(6), false);
         break;
     case BINDING_FIELD:
-        if (!binding_field(player_ptr, plev * 11 + 5, cap_mon_ptr))
+        if (!binding_field(player_ptr, plev * 11 + 5))
             msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
 
         break;
index 6598fcc..25b74bf 100644 (file)
@@ -2,13 +2,12 @@
 
 #include "system/angband.h"
 
-class CapturedMonsterType;
 class PlayerType;
 bool check_multishadow(PlayerType *player_ptr);
 bool mirror_concentration(PlayerType *player_ptr);
 void remove_all_mirrors(PlayerType *player_ptr, bool explode);
-bool binding_field(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon_ptr);
-void seal_of_mirror(PlayerType *player_ptr, int dam, CapturedMonsterType *cap_mon_ptr);
+bool binding_field(PlayerType *player_ptr, int dam);
+void seal_of_mirror(PlayerType *player_ptr, int dam);
 bool confusing_light(PlayerType *player_ptr);
 bool place_mirror(PlayerType *player_ptr);
 bool mirror_tunnel(PlayerType *player_ptr);
@@ -16,4 +15,4 @@ bool set_multishadow(PlayerType *player_ptr, TIME_EFFECT v, bool do_dec);
 bool set_dustrobe(PlayerType *player_ptr, TIME_EFFECT v, bool do_dec);
 
 enum mind_mirror_master_type : int;
-bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell, CapturedMonsterType *cap_mon_ptr);
+bool cast_mirror_spell(PlayerType *player_ptr, mind_mirror_master_type spell);
index 4488f0a..68987ec 100644 (file)
@@ -83,7 +83,7 @@
 #include "util/int-char-converter.h"
 #include "view/display-messages.h"
 
-bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command, CapturedMonsterType *cap_mon_ptr)
+bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command)
 {
     DIRECTION dir = 0;
     switch (player_ptr->pclass) {
@@ -206,13 +206,13 @@ bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command
             return false;
 
         handle_stuff(player_ptr);
-        if (!do_cmd_cast(player_ptr, cap_mon_ptr))
+        if (!do_cmd_cast(player_ptr))
             return false;
 
         if (!player_ptr->paralyzed && !cmd_limit_cast(player_ptr)) {
             handle_stuff(player_ptr);
             command_dir = 0;
-            (void)do_cmd_cast(player_ptr, cap_mon_ptr);
+            (void)do_cmd_cast(player_ptr);
         }
         return true;
     case PlayerClassType::SAMURAI:
index 0c4ef22..2a1a65f 100644 (file)
@@ -2,8 +2,7 @@
 
 #include "system/angband.h"
 
-class CapturedMonsterType;
 class PlayerType;
-bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command, CapturedMonsterType *cap_mon_ptr);
+bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command);
 bool switch_mimic_racial_execution(PlayerType *player_ptr);
 bool switch_race_racial_execution(PlayerType *player_ptr, const int32_t command);
index 920b9df..83880eb 100644 (file)
@@ -62,7 +62,7 @@ static void inscribe_nickname(ae_type *ae_ptr, CapturedMonsterType *cap_mon_ptr)
     ae_ptr->o_ptr->inscription = quark_add(buf);
 }
 
-static bool set_activation_target(PlayerType *player_ptr, ae_type *ae_ptr, CapturedMonsterType *cap_mon_ptr)
+static bool set_activation_target(PlayerType *player_ptr, ae_type *ae_ptr)
 {
     bool old_target_pet = target_pet;
     target_pet = true;
@@ -72,14 +72,15 @@ static bool set_activation_target(PlayerType *player_ptr, ae_type *ae_ptr, Captu
     }
 
     target_pet = old_target_pet;
-    if (!fire_ball(player_ptr, AttributeType::CAPTURE, ae_ptr->dir, 0, 0))
+    CapturedMonsterType cap_mon_ptr;
+    if (!fire_ball(player_ptr, AttributeType::CAPTURE, ae_ptr->dir, 0, 0, &cap_mon_ptr))
         return true;
 
-    ae_ptr->o_ptr->pval = cap_mon_ptr->r_idx;
-    ae_ptr->o_ptr->captured_monster_speed = cap_mon_ptr->speed;
-    ae_ptr->o_ptr->captured_monster_current_hp = cap_mon_ptr->current_hp;
-    ae_ptr->o_ptr->captured_monster_max_hp = cap_mon_ptr->max_hp;
-    inscribe_nickname(ae_ptr, cap_mon_ptr);
+    ae_ptr->o_ptr->pval = cap_mon_ptr.r_idx;
+    ae_ptr->o_ptr->captured_monster_speed = cap_mon_ptr.speed;
+    ae_ptr->o_ptr->captured_monster_current_hp = cap_mon_ptr.current_hp;
+    ae_ptr->o_ptr->captured_monster_max_hp = cap_mon_ptr.max_hp;
+    inscribe_nickname(ae_ptr, &cap_mon_ptr);
     return true;
 }
 
@@ -169,13 +170,13 @@ static void check_monster_ball_use(PlayerType *player_ptr, ae_type *ae_ptr)
     ae_ptr->success = true;
 }
 
-bool exe_monster_capture(PlayerType *player_ptr, ae_type *ae_ptr, CapturedMonsterType *cap_mon_ptr)
+bool exe_monster_capture(PlayerType *player_ptr, ae_type *ae_ptr)
 {
     if (ae_ptr->o_ptr->tval != ItemKindType::CAPTURE)
         return false;
 
     if (ae_ptr->o_ptr->pval == 0) {
-        if (!set_activation_target(player_ptr, ae_ptr, cap_mon_ptr))
+        if (!set_activation_target(player_ptr, ae_ptr))
             return true;
 
         calc_android_exp(player_ptr);
index 99061da..63303c1 100644 (file)
@@ -1,6 +1,5 @@
 #pragma once
 
 struct ae_type;
-class CapturedMonsterType;
 class PlayerType;
-bool exe_monster_capture(PlayerType *player_ptr, ae_type *ae_ptr, CapturedMonsterType *cap_mon_ptr);
+bool exe_monster_capture(PlayerType *player_ptr, ae_type *ae_ptr);
index ed36fb0..fd3d771 100644 (file)
@@ -20,7 +20,7 @@
  * Affect grids, objects, and monsters
  * </pre>
  */
-bool fire_ball(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad)
+bool fire_ball(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad, std::optional<CapturedMonsterType *> cap_mon_ptr)
 {
     BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
     if (typ == AttributeType::CHARM_LIVING)
@@ -35,7 +35,7 @@ bool fire_ball(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam
         ty = target_row;
     }
 
-    return project(player_ptr, 0, rad, ty, tx, dam, typ, flg).notice;
+    return project(player_ptr, 0, rad, ty, tx, dam, typ, flg, cap_mon_ptr).notice;
 }
 
 /*!
index 538fc1c..0af03f7 100644 (file)
@@ -2,9 +2,11 @@
 
 #include "system/angband.h"
 #include "effect/attribute-types.h"
+#include <optional>
 
+class CapturedMonsterType;
 class PlayerType;
-bool fire_ball(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad);
+bool fire_ball(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad, std::optional<CapturedMonsterType *> cap_mon_ptr = std::nullopt);
 bool fire_breath(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad);
 bool fire_rocket(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad);
 bool fire_ball_hide(PlayerType *player_ptr, AttributeType typ, DIRECTION dir, int dam, POSITION rad);
index ef26452..4af992c 100644 (file)
@@ -51,7 +51,7 @@
  * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
  * </pre>
  */
-void do_cmd_store(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void do_cmd_store(PlayerType *player_ptr)
 {
     if (player_ptr->wild_mode)
         return;
@@ -146,7 +146,7 @@ void do_cmd_store(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
 
         prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
         request_command(player_ptr, true);
-        store_process_command(player_ptr, cap_mon_ptr);
+        store_process_command(player_ptr);
 
         bool need_redraw_store_inv = any_bits(player_ptr->update, PU_BONUS);
         w_ptr->character_icky_depth = 1;
index f3397db..42d3721 100644 (file)
@@ -1,5 +1,4 @@
 #pragma once
 
-class CapturedMonsterType;
 class PlayerType;
-void do_cmd_store(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void do_cmd_store(PlayerType *player_ptr);
index 68d88fd..9c67d42 100644 (file)
@@ -51,7 +51,7 @@ bool leave_store = false;
  * but not in the stores, to prevent chaos.
  * </pre>
  */
-void store_process_command(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr)
+void store_process_command(PlayerType *player_ptr)
 {
     repeat_check();
     if (rogue_like_commands && (command_cmd == 'l'))
@@ -161,7 +161,7 @@ void store_process_command(PlayerType *player_ptr, CapturedMonsterType *cap_mon_
         else if (pc.equals(PlayerClassType::SNIPER))
             do_cmd_snipe_browse(player_ptr);
         else
-            do_cmd_browse(player_ptr, cap_mon_ptr);
+            do_cmd_browse(player_ptr);
 
         break;
     }
index b964c85..e4c8ee4 100644 (file)
@@ -2,6 +2,5 @@
 
 extern bool leave_store;
 
-class CapturedMonsterType;
 class PlayerType;
-void store_process_command(PlayerType *player_ptr, CapturedMonsterType *cap_mon_ptr);
+void store_process_command(PlayerType *player_ptr);