OSDN Git Service

[Refactor] #1558 Replaced set_image() to hallucination() and transferred it into...
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 20 Sep 2021 06:52:19 +0000 (15:52 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Wed, 22 Sep 2021 11:37:03 +0000 (20:37 +0900)
13 files changed:
src/cmd-action/cmd-mind.cpp
src/cmd-item/cmd-eat.cpp
src/core/magic-effects-timeout-reducer.cpp
src/effect/effect-player-resist-hurt.cpp
src/effect/effect-player-spirit.cpp
src/floor/pattern-walk.cpp
src/mutation/mutation-processor.cpp
src/object-activation/activation-others.cpp
src/object-use/quaff-execution.cpp
src/player/eldritch-horror.cpp
src/spell/spells-status.cpp
src/status/bad-status-setter.cpp
src/status/bad-status-setter.h

index b7ae7fa..f32c0d6 100644 (file)
@@ -204,15 +204,15 @@ static void check_mind_mindcrafter(player_type *player_ptr, cm_type *cm_ptr)
         return;
     }
 
+    BadStatusSetter bss(player_ptr);
     if (cm_ptr->b < 15) {
         msg_print(_("奇妙な光景が目の前で踊っている...", "Weird visions seem to dance before your eyes..."));
-        hallucination(player_ptr, player_ptr->hallucinated + 5 + randint1(10));
+        (void)bss.hallucination(player_ptr->hallucinated + 5 + randint1(10));
         return;
     }
 
     if (cm_ptr->b < 45) {
         msg_print(_("あなたの頭は混乱した!", "Your brain is addled!"));
-        BadStatusSetter bss(player_ptr);
         (void)bss.confusion(player_ptr->confused + randint1(8));
         return;
     }
@@ -244,7 +244,7 @@ static void check_mind_mirror_master(player_type *player_ptr, cm_type *cm_ptr)
 
     if (cm_ptr->b < 96) {
         msg_print(_("まわりのものがキラキラ輝いている!", "Your brain is addled!"));
-        hallucination(player_ptr, player_ptr->hallucinated + 5 + randint1(10));
+        (void)BadStatusSetter(player_ptr).hallucination(player_ptr->hallucinated + 5 + randint1(10));
         return;
     }
 
index fd4c88d..c6bd64d 100644 (file)
@@ -72,7 +72,7 @@ bool exe_eat_food_type_object(player_type *player_ptr, object_type *o_ptr)
     case SV_FOOD_CONFUSION:
         return !has_resist_conf(player_ptr) && bss.confusion(player_ptr->confused + randint0(10) + 10);
     case SV_FOOD_HALLUCINATION:
-        return !has_resist_chaos(player_ptr) && hallucination(player_ptr, player_ptr->hallucinated + randint0(250) + 250);
+        return !has_resist_chaos(player_ptr) && bss.hallucination(player_ptr->hallucinated + randint0(250) + 250);
     case SV_FOOD_PARALYSIS:
         return !player_ptr->free_act && bss.paralysis(player_ptr->paralyzed + randint0(10) + 10);
     case SV_FOOD_WEAKNESS:
index fa84b3d..a33e0a2 100644 (file)
@@ -34,7 +34,7 @@ void reduce_magic_effects_timeout(player_type *player_ptr)
     BadStatusSetter bss(player_ptr);
     auto effects = player_ptr->effects();
     if (player_ptr->hallucinated) {
-        (void)hallucination(player_ptr, player_ptr->hallucinated - dec_count);
+        (void)bss.hallucination(player_ptr->hallucinated - dec_count);
     }
 
     if (player_ptr->blind) {
index 1493abd..212fae4 100644 (file)
@@ -240,7 +240,7 @@ void effect_player_chaos(player_type *player_ptr, effect_player_type *ep_ptr)
     }
 
     if (!has_resist_chaos(player_ptr)) {
-        (void)hallucination(player_ptr, player_ptr->hallucinated + randint1(10));
+        (void)bss.hallucination(player_ptr->hallucinated + randint1(10));
         if (one_in_(3)) {
             msg_print(_("あなたの身体はカオスの力で捻じ曲げられた!", "Your body is twisted by chaos!"));
             (void)gain_mutation(player_ptr, 0);
@@ -673,7 +673,7 @@ void effect_player_abyss(player_type *player_ptr, effect_player_type *ep_ptr)
     msg_print(_("深淵から何かがあなたを覗き込んでいる!", "Something gazes you from abyss!"));
 
     if (!has_resist_chaos(player_ptr)) {
-        (void)hallucination(player_ptr, player_ptr->hallucinated + randint1(10));
+        (void)bss.hallucination(player_ptr->hallucinated + randint1(10));
     }
 
     if (!has_resist_conf(player_ptr)) {
index 72f8a45..93f971a 100644 (file)
@@ -82,7 +82,7 @@ void effect_player_mind_blast(player_type *player_ptr, effect_player_type *ep_pt
     }
 
     if (!has_resist_chaos(player_ptr) && one_in_(3)) {
-        (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(250) + 150);
+        (void)bss.hallucination(player_ptr->hallucinated + randint0(250) + 150);
     }
 
     player_ptr->csp -= 50;
@@ -138,6 +138,6 @@ void effect_player_brain_smash(player_type *player_ptr, effect_player_type *ep_p
         (void)do_dec_stat(player_ptr, A_WIS);
 
     if (!has_resist_chaos(player_ptr)) {
-        (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(250) + 150);
+        (void)bss.hallucination(player_ptr->hallucinated + randint0(250) + 150);
     }
 }
index f1bb3b9..c94321d 100644 (file)
@@ -114,7 +114,7 @@ bool pattern_effect(player_type *player_ptr)
     int pattern_type = f_info[floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
     switch (pattern_type) {
     case PATTERN_TILE_END:
-        (void)hallucination(player_ptr, 0);
+        (void)BadStatusSetter(player_ptr).hallucination(0);
         (void)restore_all_status(player_ptr);
         (void)restore_level(player_ptr);
         (void)cure_critical_wounds(player_ptr, 1000);
index 97bc3d6..736b3ba 100644 (file)
@@ -169,7 +169,7 @@ void process_world_aux_mutation(player_type *player_ptr)
             } else {
                 if (one_in_(3)) {
                     msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
-                    (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(150) + 150);
+                    (void)bss.hallucination(player_ptr->hallucinated + randint0(150) + 150);
                 }
             }
         }
@@ -179,7 +179,7 @@ void process_world_aux_mutation(player_type *player_ptr)
         if (!has_resist_chaos(player_ptr)) {
             disturb(player_ptr, false, true);
             player_ptr->redraw |= PR_EXTRA;
-            (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(50) + 20);
+            (void)bss.hallucination(player_ptr->hallucinated + randint0(50) + 20);
         }
     }
 
index ad7cba2..6578aca 100644 (file)
@@ -358,7 +358,7 @@ bool activate_protection_elbereth(player_type *player_ptr)
     create_rune_protection_one(player_ptr);
     (void)bss.afraidness(0);
     (void)bss.blindness(0);
-    (void)hallucination(player_ptr, 0);
+    (void)bss.hallucination(0);
     set_blessed(player_ptr, randint0(25) + 25, true);
     set_bits(player_ptr->redraw, PR_STATS);
     return true;
index 9fbfa92..1981918 100644 (file)
@@ -66,7 +66,8 @@ static bool booze(player_type *player_ptr)
     else if (!has_resist_conf(player_ptr))
         player_ptr->special_attack |= ATTACK_SUIKEN;
 
-    if (!has_resist_conf(player_ptr) && BadStatusSetter(player_ptr).confusion(randint0(20) + 15)) {
+    BadStatusSetter bss(player_ptr);
+    if (!has_resist_conf(player_ptr) && bss.confusion(randint0(20) + 15)) {
         ident = true;
     }
 
@@ -74,7 +75,7 @@ static bool booze(player_type *player_ptr)
         return ident;
     }
 
-    if (one_in_(2) && hallucination(player_ptr, player_ptr->hallucinated + randint0(150) + 150)) {
+    if (one_in_(2) && bss.hallucination(player_ptr->hallucinated + randint0(150) + 150)) {
         ident = true;
     }
 
@@ -539,7 +540,7 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
             break;
 
         case SV_POTION_NEO_TSUYOSHI:
-            (void)hallucination(player_ptr, 0);
+            (void)BadStatusSetter(player_ptr).hallucination(0);
             (void)set_tsuyoshi(player_ptr, player_ptr->tsuyoshi + randint1(100) + 100, false);
             ident = true;
             break;
@@ -550,7 +551,7 @@ void exe_quaff_potion(player_type *player_ptr, INVENTORY_IDX item)
             player_ptr->tsuyoshi = 1;
             (void)set_tsuyoshi(player_ptr, 0, true);
             if (!has_resist_chaos(player_ptr)) {
-                (void)hallucination(player_ptr, 50 + randint1(50));
+                (void)BadStatusSetter(player_ptr).hallucination(50 + randint1(50));
             }
             ident = true;
             break;
index 56a3209..53c9a1a 100644 (file)
@@ -266,7 +266,7 @@ void sanity_blast(player_type *player_ptr, monster_type *m_ptr, bool necro)
         }
 
         if (!has_resist_chaos(player_ptr) && one_in_(3)) {
-            (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(250) + 150);
+            (void)bss.hallucination(player_ptr->hallucinated + randint0(250) + 150);
         }
 
         /*!< @todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
@@ -284,7 +284,7 @@ void sanity_blast(player_type *player_ptr, monster_type *m_ptr, bool necro)
             (void)bss.paralysis(player_ptr->paralyzed + randint0(4) + 4);
         }
         if (!has_resist_chaos(player_ptr)) {
-            (void)hallucination(player_ptr, player_ptr->hallucinated + randint0(250) + 150);
+            (void)bss.hallucination(player_ptr->hallucinated + randint0(250) + 150);
         }
 
         do {
index 7a98a18..ac1564e 100644 (file)
@@ -285,7 +285,7 @@ bool life_stream(player_type *player_ptr, bool message, bool virtue_change)
     (void)bss.poison(0);
     (void)bss.blindness(0);
     (void)bss.confusion(0);
-    (void)hallucination(player_ptr, 0);
+    (void)bss.hallucination(0);
     (void)set_stun(player_ptr, 0);
     (void)set_cut(player_ptr, 0);
     (void)bss.paralysis(0);
@@ -446,7 +446,7 @@ bool true_healing(player_type *player_ptr, HIT_POINT pow)
         ident = true;
     }
 
-    if (hallucination(player_ptr, 0)) {
+    if (bss.hallucination(0)) {
         ident = true;
     }
 
index 88a97bc..d4f241e 100644 (file)
@@ -308,48 +308,51 @@ bool BadStatusSetter::paralysis(TIME_EFFECT v)
  * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
  * @details Note that we must redraw the map when hallucination changes.
  */
-bool hallucination(player_type *player_ptr, TIME_EFFECT v)
+bool BadStatusSetter::hallucination(TIME_EFFECT v)
 {
-    bool notice = false;
+    auto notice = false;
     v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
 
-    if (player_ptr->is_dead)
+    if (this->player_ptr->is_dead) {
         return false;
-    if (is_chargeman(player_ptr))
+    }
+
+    if (is_chargeman(this->player_ptr)) {
         v = 0;
+    }
 
     if (v) {
-        set_tsuyoshi(player_ptr, 0, true);
-        if (!player_ptr->hallucinated) {
+        set_tsuyoshi(this->player_ptr, 0, true);
+        if (!this->player_ptr->hallucinated) {
             msg_print(_("ワーオ!何もかも虹色に見える!", "Oh, wow! Everything looks so cosmic now!"));
+            if (this->player_ptr->concent) {
+                reset_concentration(this->player_ptr, true);
+            }
 
-            /* Sniper */
-            if (player_ptr->concent)
-                reset_concentration(player_ptr, true);
-
-            player_ptr->counter = false;
+            this->player_ptr->counter = false;
             notice = true;
         }
     } else {
-        if (player_ptr->hallucinated) {
+        if (this->player_ptr->hallucinated) {
             msg_print(_("やっとはっきりと物が見えるようになった。", "You can see clearly again."));
             notice = true;
         }
     }
 
-    player_ptr->hallucinated = v;
-    player_ptr->redraw |= (PR_STATUS);
-
-    if (!notice)
+    this->player_ptr->hallucinated = v;
+    this->player_ptr->redraw |= PR_STATUS;
+    if (!notice) {
         return false;
+    }
 
-    if (disturb_state)
-        disturb(player_ptr, false, true);
+    if (disturb_state) {
+        disturb(this->player_ptr, false, true);
+    }
 
-    player_ptr->redraw |= (PR_MAP | PR_HEALTH | PR_UHEALTH);
-    player_ptr->update |= (PU_MONSTERS);
-    player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
-    handle_stuff(player_ptr);
+    this->player_ptr->redraw |= PR_MAP | PR_HEALTH | PR_UHEALTH;
+    this->player_ptr->update |= PU_MONSTERS;
+    this->player_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
+    handle_stuff(this->player_ptr);
     return true;
 }
 
index 4ef4af3..a6a52f4 100644 (file)
@@ -14,12 +14,12 @@ public:
     bool poison(TIME_EFFECT v);
     bool afraidness(TIME_EFFECT v);
     bool paralysis(TIME_EFFECT v);
+    bool hallucination(TIME_EFFECT v);
 
 private:
     player_type *player_ptr;
 };
 
-bool hallucination(player_type *player_ptr, TIME_EFFECT v);
 bool set_slow(player_type *player_ptr, TIME_EFFECT v, bool do_dec);
 bool set_stun(player_type *player_ptr, TIME_EFFECT v);
 bool set_cut(player_type *player_ptr, TIME_EFFECT v);