OSDN Git Service

[Refactor] #40482 Separated spells-curse-removal.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 13:11:18 +0000 (22:11 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 13:11:18 +0000 (22:11 +0900)
13 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-read.c
src/cmd-item/cmd-usestaff.c
src/realm/realm-craft.c
src/realm/realm-crusade.c
src/realm/realm-life.c
src/spell-kind/spells-curse-removal.c [new file with mode: 0644]
src/spell-kind/spells-curse-removal.h [new file with mode: 0644]
src/spell/spells3.c
src/spell/spells3.h

index b76d3a0..e0dabb4 100644 (file)
     <ClCompile Include="..\..\src\mind\racial-kutar.c" />\r
     <ClCompile Include="..\..\src\mind\stances-table.c" />\r
     <ClCompile Include="..\..\src\player\bad-status-setter.c" />\r
+    <ClCompile Include="..\..\src\spell-kind\spells-curse-removal.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-recall.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-chaos.c" />\r
     <ClCompile Include="..\..\src\view\display-map.c" />\r
     <ClInclude Include="..\..\src\mspell\mspells3.h" />\r
     <ClInclude Include="..\..\src\player\bad-status-setter.h" />\r
     <ClInclude Include="..\..\src\player\special-defense-types.h" />\r
+    <ClInclude Include="..\..\src\spell-kind\spells-curse-removal.h" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-recall.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-chaos.h" />\r
     <ClInclude Include="..\..\src\system\alloc-entries.h" />\r
index e412664..f7bffa7 100644 (file)
     <ClCompile Include="..\..\src\spell-realm\spells-chaos.c">
       <Filter>spell-realm</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\spell-kind\spells-curse-removal.c">
+      <Filter>spell-kind</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\spell-realm\spells-chaos.h">
       <Filter>spell-realm</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\spell-kind\spells-curse-removal.h">
+      <Filter>spell-kind</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ac875b0..38ba6e8 100644 (file)
@@ -518,6 +518,7 @@ hengband_SOURCES = \
        spell-kind/earthquake.c spell-kind/earthquake.h \
        spell-kind/spells-beam.c spell-kind/spells-beam.h \
        spell-kind/spells-charm.c spell-kind/spells-charm.h \
+       spell-kind/spells-curse-removal.c spell-kind/spells-curse-removal.h \
        spell-kind/spells-detection.c spell-kind/spells-detection.h \
        spell-kind/spells-floor.c spell-kind/spells-floor.h \
        spell-kind/spells-genocide.c spell-kind/spells-genocide.h \
index b7517ee..41ed21c 100644 (file)
@@ -53,6 +53,7 @@
 #include "spell-kind/earthquake.h"
 #include "spell-kind/spells-beam.h"
 #include "spell-kind/spells-charm.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
index 00df792..af0340e 100644 (file)
@@ -30,6 +30,7 @@
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "player/special-defense-types.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
index c30f671..0134ff2 100644 (file)
@@ -25,6 +25,7 @@
 #include "player/player-status.h"
 #include "player/special-defense-types.h"
 #include "spell-kind/earthquake.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
index 70860f2..964d5bb 100644 (file)
@@ -6,6 +6,7 @@
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "player/selfinfo.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell/range-calc.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
index 8d0d3c0..a3eddcf 100644 (file)
@@ -8,20 +8,21 @@
 #include "player/bad-status-setter.h"
 #include "player/player-class.h"
 #include "player/player-effects.h"
-#include "spell/process-effect.h"
 #include "spell-kind/spells-beam.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
-#include "spell/spells-diceroll.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-neighbor.h"
-#include "spell/spells-object.h"
 #include "spell-kind/spells-sight.h"
-#include "spell/spells-status.h"
-#include "spell/spells-summon.h"
 #include "spell-kind/spells-teleport.h"
-#include "spell/spell-types.h"
 #include "spell-realm/spells-crusade.h"
+#include "spell/process-effect.h"
+#include "spell/spell-types.h"
+#include "spell/spells-diceroll.h"
+#include "spell/spells-object.h"
+#include "spell/spells-status.h"
+#include "spell/spells-summon.h"
 #include "spell/spells3.h"
 #include "view/display-messages.h"
 #include "world/world.h"
index 9376f41..6b6d3cd 100644 (file)
@@ -5,6 +5,7 @@
 #include "player/bad-status-setter.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
+#include "spell-kind/spells-curse-removal.h"
 #include "spell-kind/spells-detection.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
diff --git a/src/spell-kind/spells-curse-removal.c b/src/spell-kind/spells-curse-removal.c
new file mode 100644 (file)
index 0000000..efcffae
--- /dev/null
@@ -0,0 +1,60 @@
+#include "spell-kind/spells-curse-removal.h"
+#include "object-enchant/item-feeling.h"
+#include "object-enchant/special-object-flags.h"
+#include "object-enchant/trc-types.h"
+#include "object/object-hook.h"
+#include "system/object-type-definition.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief 装備の解呪処理 / Removes curses from items in inventory
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param all 軽い呪いまでの解除ならば0
+ * @return 解呪されたアイテムの数
+ * @details 永遠の呪いは解呪できない
+ */
+static int exe_curse_removal(player_type *creature_ptr, int all)
+{
+    int cnt = 0;
+    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        object_type *o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+        if (!object_is_cursed(o_ptr))
+            continue;
+        if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE))
+            continue;
+        if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
+            o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
+            continue;
+        }
+
+        o_ptr->curse_flags = 0L;
+        o_ptr->ident |= IDENT_SENSE;
+        o_ptr->feeling = FEEL_NONE;
+
+        creature_ptr->update |= (PU_BONUS);
+        creature_ptr->window |= (PW_EQUIP);
+        cnt++;
+    }
+
+    if (cnt)
+        msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
+
+    return cnt;
+}
+
+/*!
+ * @brief 装備の軽い呪い解呪処理 /
+ * Remove most curses
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return 解呪に成功した装備数
+ */
+int remove_curse(player_type *caster_ptr) { return exe_curse_removal(caster_ptr, FALSE); }
+
+/*!
+ * @brief 装備の重い呪い解呪処理 /
+ * Remove all curses
+ * @return 解呪に成功した装備数
+ */
+int remove_all_curse(player_type *caster_ptr) { return exe_curse_removal(caster_ptr, TRUE); }
diff --git a/src/spell-kind/spells-curse-removal.h b/src/spell-kind/spells-curse-removal.h
new file mode 100644 (file)
index 0000000..5264f17
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "system/angband.h"
+
+int remove_curse(player_type *caster_ptr);
+int remove_all_curse(player_type *caster_ptr);
index 45cc1c8..6bb8c81 100644 (file)
@@ -344,68 +344,6 @@ void identify_pack(player_type *target_ptr)
 }
 
 /*!
- * @brief 装備の解呪処理 /
- * Removes curses from items in inventory
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @param all 軽い呪いまでの解除ならば0
- * @return 解呪されたアイテムの数
- * @details
- * <pre>
- * Note that Items which are "Perma-Cursed" (The One Ring,
- * The Crown of Morgoth) can NEVER be uncursed.
- *
- * Note that if "all" is FALSE, then Items which are
- * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
- * will not be uncursed.
- * </pre>
- */
-static int remove_curse_aux(player_type *creature_ptr, int all)
-{
-    int cnt = 0;
-    for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-        object_type *o_ptr = &creature_ptr->inventory_list[i];
-        if (!o_ptr->k_idx)
-            continue;
-        if (!object_is_cursed(o_ptr))
-            continue;
-        if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE))
-            continue;
-        if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
-            o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
-            continue;
-        }
-
-        o_ptr->curse_flags = 0L;
-        o_ptr->ident |= (IDENT_SENSE);
-        o_ptr->feeling = FEEL_NONE;
-
-        creature_ptr->update |= (PU_BONUS);
-        creature_ptr->window |= (PW_EQUIP);
-        cnt++;
-    }
-
-    if (cnt)
-        msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
-
-    return cnt;
-}
-
-/*!
- * @brief 装備の軽い呪い解呪処理 /
- * Remove most curses
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @return 解呪に成功した装備数
- */
-int remove_curse(player_type *caster_ptr) { return remove_curse_aux(caster_ptr, FALSE); }
-
-/*!
- * @brief 装備の重い呪い解呪処理 /
- * Remove all curses
- * @return 解呪に成功した装備数
- */
-int remove_all_curse(player_type *caster_ptr) { return remove_curse_aux(caster_ptr, TRUE); }
-
-/*!
  * @brief アイテムの価値に応じた錬金術処理 /
  * Turns an object into gold, gain some of its value in a shop
  * @param caster_ptr プレーヤーへの参照ポインタ
index 6c7f515..3c21118 100644 (file)
@@ -5,15 +5,11 @@
 #include "system/angband.h"
 
 bool eat_magic(player_type *caster_ptr, int power);
-
 bool apply_disenchant(player_type* target_ptr, BIT_FLAGS mode);
 void fetch(player_type* caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los);
 void reserve_alter_reality(player_type* caster_ptr);
 void identify_pack(player_type* target_ptr);
-int remove_curse(player_type* caster_ptr);
-int remove_all_curse(player_type* caster_ptr);
 bool alchemy(player_type* caster_ptr);
-
 bool artifact_scroll(player_type* caster_ptr);
 bool ident_spell(player_type* caster_ptr, bool only_equip, tval_type item_tester_tval);
 bool mundane_spell(player_type* ownner_ptr, bool only_equip);