OSDN Git Service

[Refactor] #40482 Separated spells-equipment.c/h from spells3.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:30:45 +0000 (13:30 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:30:45 +0000 (13:30 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/effect/effect-monster-resist-hurt.c
src/monster-attack/monster-attack-switcher.c
src/specific-object/chest.c
src/spell-kind/spells-equipment.c [new file with mode: 0644]
src/spell-kind/spells-equipment.h [new file with mode: 0644]
src/spell-kind/spells-random.c
src/spell/spells3.c
src/spell/spells3.h

index 45bf6e5..baa5cf6 100644 (file)
     <ClCompile Include="..\..\src\object-hook\hook-quest.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-weapon.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-armor.c" />\r
+    <ClCompile Include="..\..\src\spell-kind\spells-equipment.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-fetcher.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-craft.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-demon.c" />\r
     <ClInclude Include="..\..\src\object-hook\hook-perception.h" />\r
     <ClInclude Include="..\..\src\object-hook\hook-quest.h" />\r
     <ClInclude Include="..\..\src\object-hook\hook-weapon.h" />\r
+    <ClInclude Include="..\..\src\spell-kind\spells-equipment.h" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-fetcher.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-craft.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-demon.h" />\r
index 89167a2..c7e9008 100644 (file)
     <ClCompile Include="..\..\src\spell-realm\spells-sorcery.c">
       <Filter>spell-realm</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\spell-kind\spells-equipment.c">
+      <Filter>spell-kind</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\spell-realm\spells-sorcery.h">
       <Filter>spell-realm</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\spell-kind\spells-equipment.h">
+      <Filter>spell-kind</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index d6a7751..8bea251 100644 (file)
@@ -542,6 +542,7 @@ hengband_SOURCES = \
        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-equipment.c spell-kind/spells-equipment.h \
        spell-kind/spells-fetcher.c spell-kind/spells-fetcher.h \
        spell-kind/spells-floor.c spell-kind/spells-floor.h \
        spell-kind/spells-genocide.c spell-kind/spells-genocide.h \
index aaa7be3..185ed57 100644 (file)
@@ -6,7 +6,7 @@
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-status.h"
 #include "monster/monster-info.h"
-#include "spell/spells3.h"
+#include "spell-kind/spells-equipment.h"
 
 gf_switch_result effect_monster_void(effect_monster_type *em_ptr)
 {
index 0f7ae36..605b681 100644 (file)
@@ -15,7 +15,7 @@
 #include "monster/monster-update.h"
 #include "player/player-damage.h"
 #include "spell-kind/earthquake.h"
-#include "spell/spells3.h"
+#include "spell-kind/spells-equipment.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
 #include "status/element-resistance.h"
index 17b34ad..919f436 100644 (file)
 #include "perception/object-perception.h"
 #include "player/player-class.h"
 #include "player/player-damage.h"
+#include "spell-kind/spells-equipment.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-sight.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
-#include "spell/spells3.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
 #include "status/element-resistance.h"
diff --git a/src/spell-kind/spells-equipment.c b/src/spell-kind/spells-equipment.c
new file mode 100644 (file)
index 0000000..e458d6e
--- /dev/null
@@ -0,0 +1,115 @@
+#include "spell-kind/spells-equipment.h"
+#include "inventory/inventory-slot-types.h"
+#include "mind/racial-android.h"
+#include "object-hook/hook-enchant.h"
+#include "object-hook/hook-weapon.h"
+#include "object/object-flavor.h"
+#include "object/object-info.h"
+#include "player/avatar.h"
+#include "system/object-type-definition.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief プレイヤーの装備劣化処理 /
+ * Apply disenchantment to the player's stuff
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param mode 最下位ビットが1ならば劣化処理が若干低減される
+ * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
+ * Return "TRUE" if the player notices anything
+ */
+bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
+{
+    int t = 0;
+    switch (randint1(8)) {
+    case 1:
+        t = INVEN_RARM;
+        break;
+    case 2:
+        t = INVEN_LARM;
+        break;
+    case 3:
+        t = INVEN_BOW;
+        break;
+    case 4:
+        t = INVEN_BODY;
+        break;
+    case 5:
+        t = INVEN_OUTER;
+        break;
+    case 6:
+        t = INVEN_HEAD;
+        break;
+    case 7:
+        t = INVEN_HANDS;
+        break;
+    case 8:
+        t = INVEN_FEET;
+        break;
+    }
+
+    object_type *o_ptr;
+    o_ptr = &target_ptr->inventory_list[t];
+    if (!o_ptr->k_idx)
+        return FALSE;
+
+    if (!object_is_weapon_armour_ammo(target_ptr, o_ptr))
+        return FALSE;
+
+    if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1)) {
+        return FALSE;
+    }
+
+    GAME_TEXT o_name[MAX_NLEN];
+    object_desc(target_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+    if (object_is_artifact(o_ptr) && (randint0(100) < 71)) {
+#ifdef JP
+        msg_format("%s(%c)は劣化を跳ね返した!", o_name, index_to_label(t));
+#else
+        msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "" : "s"));
+#endif
+        return TRUE;
+    }
+
+    int to_h = o_ptr->to_h;
+    int to_d = o_ptr->to_d;
+    int to_a = o_ptr->to_a;
+    int pval = o_ptr->pval;
+
+    if (o_ptr->to_h > 0)
+        o_ptr->to_h--;
+    if ((o_ptr->to_h > 5) && (randint0(100) < 20))
+        o_ptr->to_h--;
+
+    if (o_ptr->to_d > 0)
+        o_ptr->to_d--;
+    if ((o_ptr->to_d > 5) && (randint0(100) < 20))
+        o_ptr->to_d--;
+
+    if (o_ptr->to_a > 0)
+        o_ptr->to_a--;
+    if ((o_ptr->to_a > 5) && (randint0(100) < 20))
+        o_ptr->to_a--;
+
+    if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01))
+        o_ptr->pval--;
+
+    bool is_actually_disenchanted = to_h != o_ptr->to_h;
+    is_actually_disenchanted |= to_d != o_ptr->to_d;
+    is_actually_disenchanted |= to_a != o_ptr->to_a;
+    is_actually_disenchanted |= pval != o_ptr->pval;
+    if (!is_actually_disenchanted)
+        return TRUE;
+
+#ifdef JP
+    msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t));
+#else
+    msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "were" : "was"));
+#endif
+    chg_virtue(target_ptr, V_HARMONY, 1);
+    chg_virtue(target_ptr, V_ENCHANT, -2);
+    target_ptr->update |= (PU_BONUS);
+    target_ptr->window |= (PW_EQUIP | PW_PLAYER);
+
+    calc_android_exp(target_ptr);
+    return TRUE;
+}
diff --git a/src/spell-kind/spells-equipment.h b/src/spell-kind/spells-equipment.h
new file mode 100644 (file)
index 0000000..02424ab
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode);
index d59ea5a..906de65 100644 (file)
@@ -18,6 +18,7 @@
 #include "status/bad-status-setter.h"
 #include "player/player-damage.h"
 #include "spell-kind/earthquake.h"
+#include "spell-kind/spells-equipment.h"
 #include "spell-kind/spells-floor.h"
 #include "spell-kind/spells-genocide.h"
 #include "spell-kind/spells-launcher.h"
@@ -31,7 +32,6 @@
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/spell-types.h"
-#include "spell/spells3.h"
 #include "status/base-status.h"
 #include "status/experience.h"
 #include "view/display-messages.h"
index 3ef8050..d8f28cb 100644 (file)
 #include "world/world.h"
 
 /*!
- * @brief プレイヤーの装備劣化処理 /
- * Apply disenchantment to the player's stuff
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param mode 最下位ビットが1ならば劣化処理が若干低減される
- * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
- * Return "TRUE" if the player notices anything
- */
-bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
-{
-    int t = 0;
-    switch (randint1(8)) {
-    case 1:
-        t = INVEN_RARM;
-        break;
-    case 2:
-        t = INVEN_LARM;
-        break;
-    case 3:
-        t = INVEN_BOW;
-        break;
-    case 4:
-        t = INVEN_BODY;
-        break;
-    case 5:
-        t = INVEN_OUTER;
-        break;
-    case 6:
-        t = INVEN_HEAD;
-        break;
-    case 7:
-        t = INVEN_HANDS;
-        break;
-    case 8:
-        t = INVEN_FEET;
-        break;
-    }
-
-    object_type *o_ptr;
-    o_ptr = &target_ptr->inventory_list[t];
-    if (!o_ptr->k_idx)
-        return FALSE;
-
-    if (!object_is_weapon_armour_ammo(target_ptr, o_ptr))
-        return FALSE;
-
-    if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1)) {
-        return FALSE;
-    }
-
-    GAME_TEXT o_name[MAX_NLEN];
-    object_desc(target_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-    if (object_is_artifact(o_ptr) && (randint0(100) < 71)) {
-#ifdef JP
-        msg_format("%s(%c)は劣化を跳ね返した!", o_name, index_to_label(t));
-#else
-        msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "" : "s"));
-#endif
-        return TRUE;
-    }
-
-    int to_h = o_ptr->to_h;
-    int to_d = o_ptr->to_d;
-    int to_a = o_ptr->to_a;
-    int pval = o_ptr->pval;
-
-    if (o_ptr->to_h > 0)
-        o_ptr->to_h--;
-    if ((o_ptr->to_h > 5) && (randint0(100) < 20))
-        o_ptr->to_h--;
-
-    if (o_ptr->to_d > 0)
-        o_ptr->to_d--;
-    if ((o_ptr->to_d > 5) && (randint0(100) < 20))
-        o_ptr->to_d--;
-
-    if (o_ptr->to_a > 0)
-        o_ptr->to_a--;
-    if ((o_ptr->to_a > 5) && (randint0(100) < 20))
-        o_ptr->to_a--;
-
-    if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01))
-        o_ptr->pval--;
-
-    bool is_actually_disenchanted = to_h != o_ptr->to_h;
-    is_actually_disenchanted |= to_d != o_ptr->to_d;
-    is_actually_disenchanted |= to_a != o_ptr->to_a;
-    is_actually_disenchanted |= pval != o_ptr->pval;
-    if (!is_actually_disenchanted)
-        return TRUE;
-
-#ifdef JP
-    msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t));
-#else
-    msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "were" : "was"));
-#endif
-    chg_virtue(target_ptr, V_HARMONY, 1);
-    chg_virtue(target_ptr, V_ENCHANT, -2);
-    target_ptr->update |= (PU_BONUS);
-    target_ptr->window |= (PW_EQUIP | PW_PLAYER);
-
-    calc_android_exp(target_ptr);
-    return TRUE;
-}
-
-/*!
  * @brief 現実変容処理
  * @param caster_ptr プレーヤーへの参照ポインタ
  * @return なし
index cad4650..7cd2bc8 100644 (file)
@@ -2,7 +2,6 @@
 
 #include "system/angband.h"
 
-bool apply_disenchant(player_type* target_ptr, BIT_FLAGS mode);
 void reserve_alter_reality(player_type* caster_ptr);
 bool artifact_scroll(player_type* caster_ptr);
 bool mundane_spell(player_type* ownner_ptr, bool only_equip);