OSDN Git Service

[Refactor] #3286 Removed player-redraw-types.h
[hengbandforosx/hengbandosx.git] / src / cmd-item / cmd-equipment.cpp
index 17d6517..7dcd17a 100644 (file)
@@ -4,8 +4,6 @@
 #include "autopick/autopick.h"
 #include "avatar/avatar.h"
 #include "core/asking-player.h"
-#include "core/player-redraw-types.h"
-#include "core/player-update-types.h"
 #include "core/window-redrawer.h"
 #include "dungeon/quest.h" //!< @todo 違和感、何故アイテムを装備するとクエストの成功判定が走るのか?.
 #include "flavor/flavor-describer.h"
@@ -47,6 +45,7 @@
 #include "status/shape-changer.h"
 #include "system/item-entity.h"
 #include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
 #include "term/screen-processor.h"
 #include "term/z-form.h"
 #include "util/bit-flags-calculator.h"
@@ -59,6 +58,7 @@
  */
 static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity *o_ptr, PlayerType *player_ptr)
 {
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
     if (set_anubis_and_chariot(player_ptr) && ((slot == INVEN_MAIN_HAND) || (slot == INVEN_SUB_HAND))) {
 
         ItemEntity *anubis = &(player_ptr->inventory_list[INVEN_MAIN_HAND]);
@@ -72,7 +72,7 @@ static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity *o_ptr, PlayerType *pl
         chariot->curse_flags.set(CurseTraitType::VUL_CURSE);
 
         msg_format(_("『銀の戦車』プラス『アヌビス神』二刀流ッ!", "*Silver Chariot* plus *Anubis God* Two Swords!"));
-        player_ptr->update |= (PU_BONUS);
+        rfu.set_flag(StatusRedrawingFlag::BONUS);
         return;
     }
 
@@ -86,7 +86,7 @@ static void do_curse_on_equip(OBJECT_IDX slot, ItemEntity *o_ptr, PlayerType *pl
     o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
     msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), item_name.data());
     o_ptr->feeling = FEEL_NONE;
-    player_ptr->update |= (PU_BONUS);
+    rfu.set_flag(StatusRedrawingFlag::BONUS);
 }
 
 /*!
@@ -335,19 +335,29 @@ void do_cmd_wield(PlayerType *player_ptr)
     msg_format(act, item_name.data(), index_to_label(slot));
     if (o_ptr->is_cursed()) {
         msg_print(_("うわ! すさまじく冷たい!", "Oops! It feels deathly cold!"));
-        chg_virtue(player_ptr, V_HARMONY, -1);
+        chg_virtue(player_ptr, Virtue::HARMONY, -1);
         o_ptr->ident |= (IDENT_SENSE);
     }
 
     do_curse_on_equip(slot, o_ptr, player_ptr);
-    if (o_ptr->is_specific_artifact(FixedArtifactId::STONEMASK) && !pr.equals(PlayerRaceType::VAMPIRE) && !pr.equals(PlayerRaceType::ANDROID)) {
-        change_race(player_ptr, PlayerRaceType::VAMPIRE, "");
+    if (o_ptr->is_specific_artifact(FixedArtifactId::STONEMASK)) {
+        auto is_specific_race = pr.equals(PlayerRaceType::VAMPIRE);
+        is_specific_race |= pr.equals(PlayerRaceType::ANDROID);
+        if (!is_specific_race) {
+            change_race(player_ptr, PlayerRaceType::VAMPIRE, "");
+        }
     }
 
     calc_android_exp(player_ptr);
-    player_ptr->update |= PU_BONUS | PU_TORCH | PU_MANA;
-    player_ptr->redraw |= PR_EQUIPPY;
-    player_ptr->window_flags |= PW_INVEN | PW_EQUIP | PW_PLAYER;
+    const auto flags_srf = {
+        StatusRedrawingFlag::BONUS,
+        StatusRedrawingFlag::TORCH,
+        StatusRedrawingFlag::MP,
+    };
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
+    rfu.set_flags(flags_srf);
+    rfu.set_flag(MainWindowRedrawingFlag::EQUIPPY);
+    player_ptr->window_flags |= PW_INVENTORY | PW_EQUIPMENT | PW_PLAYER;
 }
 
 /*!
@@ -368,6 +378,7 @@ void do_cmd_takeoff(PlayerType *player_ptr)
     }
 
     PlayerEnergy energy(player_ptr);
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
     if (o_ptr->is_cursed()) {
         if (o_ptr->curse_flags.has(CurseTraitType::PERMA_CURSE) || !pc.equals(PlayerClassType::BERSERKER)) {
             msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
@@ -379,8 +390,8 @@ void do_cmd_takeoff(PlayerType *player_ptr)
             o_ptr->ident |= (IDENT_SENSE);
             o_ptr->curse_flags.clear();
             o_ptr->feeling = FEEL_NONE;
-            player_ptr->update |= PU_BONUS;
-            player_ptr->window_flags |= PW_EQUIP;
+            rfu.set_flag(StatusRedrawingFlag::BONUS);
+            player_ptr->window_flags |= PW_EQUIPMENT;
             msg_print(_("呪いを打ち破った。", "You break the curse."));
         } else {
             msg_print(_("装備を外せなかった。", "You couldn't remove the equipment."));
@@ -394,7 +405,12 @@ void do_cmd_takeoff(PlayerType *player_ptr)
     (void)inven_takeoff(player_ptr, item, 255);
     verify_equip_slot(player_ptr, item);
     calc_android_exp(player_ptr);
-    player_ptr->update |= PU_BONUS | PU_TORCH | PU_MANA;
-    player_ptr->redraw |= PR_EQUIPPY;
-    player_ptr->window_flags |= PW_INVEN | PW_EQUIP | PW_PLAYER;
+    const auto flags_srf = {
+        StatusRedrawingFlag::BONUS,
+        StatusRedrawingFlag::TORCH,
+        StatusRedrawingFlag::MP,
+    };
+    rfu.set_flags(flags_srf);
+    rfu.set_flag(MainWindowRedrawingFlag::EQUIPPY);
+    player_ptr->window_flags |= PW_INVENTORY | PW_EQUIPMENT | PW_PLAYER;
 }