OSDN Git Service

[Refactor] #4169 TimedEffects::PlayerCut をshared_ptr から普通のクラスに差し替えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Tue, 28 May 2024 10:28:28 +0000 (19:28 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Tue, 28 May 2024 13:44:59 +0000 (22:44 +0900)
21 files changed:
src/cmd-action/cmd-move.cpp
src/cmd-building/cmd-inn.cpp
src/core/magic-effects-timeout-reducer.cpp
src/floor/pattern-walk.cpp
src/hpmp/hp-mp-processor.cpp
src/load/player-info-loader.cpp
src/mind/mind-samurai.cpp
src/monster-attack/monster-attack-player.cpp
src/player-attack/player-attack.cpp
src/player-info/self-info.cpp
src/realm/realm-hissatsu.cpp
src/save/player-writer.cpp
src/spell/spells-status.cpp
src/status/bad-status-setter.cpp
src/status/buff-setter.cpp
src/status/shape-changer.cpp
src/system/player-type-definition.cpp
src/timed-effect/player-cut.h
src/timed-effect/timed-effects.cpp
src/timed-effect/timed-effects.h
src/window/main-window-stat-poster.cpp

index 1499032..f9589e3 100644 (file)
@@ -39,7 +39,6 @@
 #include "system/redrawing-flags-updater.h"
 #include "system/terrain-type-definition.h"
 #include "target/target-getter.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
index fe61097..d3633de 100644 (file)
@@ -15,7 +15,6 @@
 #include "status/bad-status-setter.h"
 #include "store/rumor.h"
 #include "system/player-type-definition.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-poison.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
@@ -47,7 +46,7 @@ static bool buy_food(PlayerType *player_ptr)
 static bool is_healthy_stay(PlayerType *player_ptr)
 {
     const auto effects = player_ptr->effects();
-    if (!effects->poison()->is_poisoned() && !effects->cut()->is_cut()) {
+    if (!effects->poison()->is_poisoned() && !effects->cut().is_cut()) {
         return true;
     }
 
index 37db212..0e16dbd 100644 (file)
@@ -18,7 +18,6 @@
 #include "status/temporary-resistance.h"
 #include "system/player-type-definition.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -228,10 +227,10 @@ void reduce_magic_effects_timeout(PlayerType *player_ptr)
         (void)bss.mod_stun(-adjust);
     }
 
-    auto player_cut = effects->cut();
-    if (player_cut->is_cut()) {
+    auto &player_cut = effects->cut();
+    if (player_cut.is_cut()) {
         short adjust = adj_con_fix[player_ptr->stat_index[A_CON]] + 1;
-        if (player_cut->get_rank() == PlayerCutRank::MORTAL) {
+        if (player_cut.get_rank() == PlayerCutRank::MORTAL) {
             adjust = 0;
         }
 
index ca86853..857fae9 100644 (file)
@@ -25,7 +25,6 @@
 #include "system/player-type-definition.h"
 #include "system/terrain-type-definition.h"
 #include "term/z-form.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
@@ -113,7 +112,7 @@ bool pattern_effect(PlayerType *player_ptr)
         return false;
     }
 
-    auto is_cut = player_ptr->effects()->cut()->is_cut();
+    const auto is_cut = player_ptr->effects()->cut().is_cut();
     if ((PlayerRace(player_ptr).equals(PlayerRaceType::AMBERITE)) && is_cut && one_in_(10)) {
         wreck_the_pattern(player_ptr);
     }
index fb6d820..b634ffa 100644 (file)
@@ -40,7 +40,6 @@
 #include "system/player-type-definition.h"
 #include "system/redrawing-flags-updater.h"
 #include "system/terrain-type-definition.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-poison.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
@@ -126,9 +125,9 @@ void process_player_hp_mp(PlayerType *player_ptr)
         }
     }
 
-    const auto player_cut = effects->cut();
-    if (player_cut->is_cut() && !is_invuln(player_ptr)) {
-        auto dam = player_cut->get_damage();
+    const auto &player_cut = effects->cut();
+    if (player_cut.is_cut() && !is_invuln(player_ptr)) {
+        const auto dam = player_cut.get_damage();
         if (take_hit(player_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a mortal wound")) > 0) {
             sound(SOUND_DAMAGE_OVER_TIME);
         }
@@ -413,7 +412,7 @@ void process_player_hp_mp(PlayerType *player_ptr)
     if (player_poison->is_poisoned()) {
         regen_amount = 0;
     }
-    if (player_cut->is_cut()) {
+    if (player_cut.is_cut()) {
         regen_amount = 0;
     }
     if (cave_no_regen) {
index 1141651..45a7e5d 100644 (file)
@@ -25,7 +25,6 @@
 #include "system/floor-type-definition.h"
 #include "system/player-type-definition.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -368,7 +367,7 @@ static void rd_status(PlayerType *player_ptr)
     effects->acceleration()->set(rd_s16b());
     effects->deceleration()->set(rd_s16b());
     effects->fear()->set(rd_s16b());
-    effects->cut()->set(rd_s16b());
+    effects->cut().set(rd_s16b());
     effects->stun()->set(rd_s16b());
     effects->poison()->set(rd_s16b());
     effects->hallucination()->set(rd_s16b());
index 0a89649..4002d5f 100644 (file)
@@ -35,7 +35,6 @@
 #include "system/redrawing-flags-updater.h"
 #include "term/screen-processor.h"
 #include "term/z-form.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
@@ -272,9 +271,9 @@ static void hissatsu_lightning_eagle(PlayerType *player_ptr, samurai_slaying_typ
  */
 static void hissatsu_bloody_maelstroem(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
 {
-    auto player_cut = player_ptr->effects()->cut();
-    if ((samurai_slaying_ptr->mode == HISSATSU_SEKIRYUKA) && player_cut->is_cut() && samurai_slaying_ptr->m_ptr->has_living_flag()) {
-        auto tmp = std::min<short>(100, std::max<short>(10, player_cut->current() / 10));
+    const auto &player_cut = player_ptr->effects()->cut();
+    if ((samurai_slaying_ptr->mode == HISSATSU_SEKIRYUKA) && player_cut.is_cut() && samurai_slaying_ptr->m_ptr->has_living_flag()) {
+        auto tmp = std::min<short>(100, std::max<short>(10, player_cut.current() / 10));
         if (samurai_slaying_ptr->mult < tmp) {
             samurai_slaying_ptr->mult = tmp;
         }
index 02e733a..469ba57 100644 (file)
@@ -51,7 +51,6 @@
 #include "system/monster-race-info.h"
 #include "system/player-type-definition.h"
 #include "system/redrawing-flags-updater.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
index f71800a..4b88ef4 100644 (file)
@@ -52,7 +52,6 @@
 #include "system/monster-entity.h"
 #include "system/monster-race-info.h"
 #include "system/player-type-definition.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
 #include "util/string-processor.h"
@@ -390,7 +389,7 @@ static void apply_damage_bonus(PlayerType *player_ptr, player_attack_type *pa_pt
         pa_ptr->attack_damage = 0;
     }
 
-    auto is_cut = player_ptr->effects()->cut()->is_cut();
+    auto is_cut = player_ptr->effects()->cut().is_cut();
     if ((pa_ptr->mode == HISSATSU_SEKIRYUKA) && !is_cut) {
         pa_ptr->attack_damage /= 2;
     }
index d3d8f67..f0e928e 100644 (file)
@@ -30,7 +30,6 @@
 #include "term/gameterm.h"
 #include "term/screen-processor.h"
 #include "term/z-form.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-poison.h"
@@ -53,7 +52,7 @@ static void set_bad_status_info(PlayerType *player_ptr, self_info_type *self_ptr
         self_ptr->info_list.emplace_back(_("あなたは恐怖に侵されている。", "You are terrified."));
     }
 
-    if (effects->cut()->is_cut()) {
+    if (effects->cut().is_cut()) {
         self_ptr->info_list.emplace_back(_("あなたは出血している。", "You are bleeding."));
     }
 
index 0e11947..015e4c2 100644 (file)
@@ -50,7 +50,6 @@
 #include "target/projection-path-calculator.h"
 #include "target/target-getter.h"
 #include "term/screen-processor.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -579,7 +578,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
         }
 
         if (cast) {
-            auto current_cut = player_ptr->effects()->cut()->current();
+            const auto current_cut = player_ptr->effects()->cut().current();
             short new_cut = current_cut < 300 ? current_cut + 300 : current_cut * 2;
             (void)BadStatusSetter(player_ptr).set_cut(new_cut);
             const auto &floor = *player_ptr->current_floor_ptr;
index e3041f4..9cc7f06 100644 (file)
@@ -12,7 +12,6 @@
 #include "system/floor-type-definition.h"
 #include "system/player-type-definition.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -170,7 +169,7 @@ void wr_player(PlayerType *player_ptr)
     wr_s16b(effects->acceleration()->current());
     wr_s16b(effects->deceleration()->current());
     wr_s16b(effects->fear()->current());
-    wr_s16b(effects->cut()->current());
+    wr_s16b(effects->cut().current());
     wr_s16b(effects->stun()->current());
     wr_s16b(effects->poison()->current());
     wr_s16b(effects->hallucination()->current());
index 494253e..87e1894 100644 (file)
@@ -50,7 +50,6 @@
 #include "system/redrawing-flags-updater.h"
 #include "target/target-getter.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/timed-effects.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -381,7 +380,7 @@ bool cure_serious_wounds(PlayerType *player_ptr, DICE_NUMBER dice, DICE_SID side
         ident = true;
     }
 
-    if (bss.set_cut((player_ptr->effects()->cut()->current() / 2) - 50)) {
+    if (bss.set_cut((player_ptr->effects()->cut().current() / 2) - 50)) {
         ident = true;
     }
 
index a54c779..ddeb205 100644 (file)
@@ -19,7 +19,6 @@
 #include "system/angband-exceptions.h"
 #include "system/player-type-definition.h"
 #include "system/redrawing-flags-updater.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -517,7 +516,7 @@ bool BadStatusSetter::set_cut(const TIME_EFFECT tmp_v)
     }
 
     auto notice = this->process_cut_effect(v);
-    this->player_ptr->effects()->cut()->set(v);
+    this->player_ptr->effects()->cut().set(v);
     if (!notice) {
         return false;
     }
@@ -535,7 +534,7 @@ bool BadStatusSetter::set_cut(const TIME_EFFECT tmp_v)
 
 bool BadStatusSetter::mod_cut(const TIME_EFFECT tmp_v)
 {
-    return this->set_cut(this->player_ptr->effects()->cut()->current() + tmp_v);
+    return this->set_cut(this->player_ptr->effects()->cut().current() + tmp_v);
 }
 
 bool BadStatusSetter::process_stun_effect(const short v)
@@ -627,9 +626,9 @@ void BadStatusSetter::decrease_int_wis(const short v)
 
 bool BadStatusSetter::process_cut_effect(const short v)
 {
-    auto player_cut = this->player_ptr->effects()->cut();
-    auto old_rank = player_cut->get_rank();
-    auto new_rank = player_cut->get_rank(v);
+    const auto &player_cut = this->player_ptr->effects()->cut();
+    auto old_rank = player_cut.get_rank();
+    auto new_rank = player_cut.get_rank(v);
     if (new_rank > old_rank) {
         this->decrease_charisma(new_rank, v);
         return true;
index 19d3062..7416c12 100644 (file)
@@ -19,7 +19,6 @@
 #include "system/player-type-definition.h"
 #include "system/redrawing-flags-updater.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -44,7 +43,7 @@ void reset_tim_flags(PlayerType *player_ptr)
     effects->fear()->reset();
     effects->hallucination()->reset();
     effects->poison()->reset();
-    effects->cut()->reset();
+    effects->cut().reset();
     effects->stun()->reset();
 
     player_ptr->protevil = 0; /* Timed -- Protection */
index 6484336..8b5ebc4 100644 (file)
@@ -23,7 +23,6 @@
 #include "status/base-status.h"
 #include "system/player-type-definition.h"
 #include "system/redrawing-flags-updater.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/timed-effects.h"
 #include "util/enum-converter.h"
 #include "view/display-messages.h"
@@ -33,8 +32,8 @@ void do_poly_wounds(PlayerType *player_ptr)
     int16_t hit_p = (player_ptr->mhp - player_ptr->chp);
     int16_t change = damroll(player_ptr->lev, 5);
     auto nasty_effect = one_in_(5);
-    auto player_cut = player_ptr->effects()->cut();
-    if (!player_cut->is_cut() && (hit_p == 0) && !nasty_effect) {
+    const auto &player_cut = player_ptr->effects()->cut();
+    if (!player_cut.is_cut() && (hit_p == 0) && !nasty_effect) {
         return;
     }
 
index 911700c..4a0e58c 100644 (file)
@@ -3,7 +3,6 @@
 #include "market/arena-info-table.h"
 #include "system/angband-exceptions.h"
 #include "system/redrawing-flags-updater.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -53,7 +52,7 @@ bool PlayerType::is_fully_healthy() const
     is_fully_healthy &= !effects->poison()->is_poisoned();
     is_fully_healthy &= !effects->fear()->is_fearful();
     is_fully_healthy &= !effects->stun()->is_stunned();
-    is_fully_healthy &= !effects->cut()->is_cut();
+    is_fully_healthy &= !effects->cut().is_cut();
     is_fully_healthy &= !effects->deceleration()->is_slow();
     is_fully_healthy &= !effects->paralysis()->is_paralyzed();
     is_fully_healthy &= !effects->hallucination()->is_hallucinated();
index 953a49d..68aa8db 100644 (file)
@@ -18,7 +18,11 @@ enum class PlayerCutRank {
 class PlayerCut {
 public:
     PlayerCut() = default;
-    virtual ~PlayerCut() = default;
+    ~PlayerCut() = default;
+    PlayerCut(const PlayerCut &) = delete;
+    PlayerCut(PlayerCut &&) = delete;
+    PlayerCut &operator=(const PlayerCut &) = delete;
+    PlayerCut &operator=(PlayerCut &&) = delete;
 
     static PlayerCutRank get_rank(short value);
     static std::string get_cut_mes(PlayerCutRank stun_rank);
index 1109eea..88f6e3b 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "timed-effect/timed-effects.h"
 #include "timed-effect/player-acceleration.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -15,8 +14,7 @@
 #include "timed-effect/player-stun.h"
 
 TimedEffects::TimedEffects()
-    : player_cut(std::make_shared<PlayerCut>())
-    , player_fear(std::make_shared<PlayerFear>())
+    : player_fear(std::make_shared<PlayerFear>())
     , player_hallucination(std::make_shared<PlayerHallucination>())
     , player_paralysis(std::make_shared<PlayerParalysis>())
     , player_stun(std::make_shared<PlayerStun>())
@@ -46,7 +44,12 @@ const PlayerConfusion &TimedEffects::confusion() const
     return this->player_confusion;
 }
 
-std::shared_ptr<PlayerCut> TimedEffects::cut() const
+PlayerCut &TimedEffects::cut()
+{
+    return this->player_cut;
+}
+
+const PlayerCut &TimedEffects::cut() const
 {
     return this->player_cut;
 }
index 06e1ea2..f1b3b69 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "timed-effect/player-blindness.h"
 #include "timed-effect/player-confusion.h"
+#include "timed-effect/player-cut.h"
 #include <memory>
 
 class PlayerAcceleration;
@@ -10,7 +11,6 @@ class PlayerFear;
 class PlayerHallucination;
 class PlayerParalysis;
 class PlayerPoison;
-class PlayerCut;
 class PlayerStun;
 class TimedEffects {
 public:
@@ -25,7 +25,8 @@ public:
     const PlayerBlindness &blindness() const;
     PlayerConfusion &confusion();
     const PlayerConfusion &confusion() const;
-    std::shared_ptr<PlayerCut> cut() const;
+    PlayerCut &cut();
+    const PlayerCut &cut() const;
     std::shared_ptr<PlayerFear> fear() const;
     std::shared_ptr<PlayerHallucination> hallucination() const;
     std::shared_ptr<PlayerParalysis> paralysis() const;
@@ -37,7 +38,7 @@ public:
 private:
     PlayerBlindness player_blindness{};
     PlayerConfusion player_confusion{};
-    std::shared_ptr<PlayerCut> player_cut;
+    PlayerCut player_cut{};
     std::shared_ptr<PlayerFear> player_fear;
     std::shared_ptr<PlayerHallucination> player_hallucination;
     std::shared_ptr<PlayerParalysis> player_paralysis;
index 2a7c069..f0db833 100644 (file)
@@ -23,7 +23,6 @@
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
 #include "term/z-form.h"
-#include "timed-effect/player-cut.h"
 #include "timed-effect/player-deceleration.h"
 #include "timed-effect/player-fear.h"
 #include "timed-effect/player-hallucination.h"
@@ -79,13 +78,13 @@ void print_stat(PlayerType *player_ptr, int stat)
  */
 void print_cut(PlayerType *player_ptr)
 {
-    auto player_cut = player_ptr->effects()->cut();
-    if (!player_cut->is_cut()) {
+    const auto &player_cut = player_ptr->effects()->cut();
+    if (!player_cut.is_cut()) {
         put_str("            ", ROW_CUT, COL_CUT);
         return;
     }
 
-    auto [color, stat] = player_cut->get_expr();
+    auto [color, stat] = player_cut.get_expr();
     c_put_str(color, stat, ROW_CUT, COL_CUT);
 }