OSDN Git Service

[Refactor] #40482 Separated spells-polymorph.c/h from spells3.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:51:28 +0000 (13:51 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 04:51:28 +0000 (13:51 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/effect/effect-monster.c
src/player-attack/attack-chaos-effect.c
src/spell-kind/spells-polymorph.c [new file with mode: 0644]
src/spell-kind/spells-polymorph.h [new file with mode: 0644]
src/spell/spells3.c
src/spell/spells3.h

index 4b741c9..88c276d 100644 (file)
     <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-kind\spells-polymorph.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-craft.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-demon.c" />\r
     <ClCompile Include="..\..\src\spell-realm\spells-sorcery.c" />\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-kind\spells-polymorph.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-craft.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-demon.h" />\r
     <ClInclude Include="..\..\src\spell-realm\spells-sorcery.h" />\r
index eebad30..e2faae7 100644 (file)
     <ClCompile Include="..\..\src\view\display-sub-window-spells.c">
       <Filter>view</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\spell-kind\spells-polymorph.c">
+      <Filter>spell-kind</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\view\display-sub-window-spells.h">
       <Filter>view</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\spell-kind\spells-polymorph.h">
+      <Filter>spell-kind</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 0adc9e1..c1354c8 100644 (file)
@@ -552,6 +552,7 @@ hengband_SOURCES = \
        spell-kind/spells-neighbor.c spell-kind/spells-neighbor.h \
        spell-kind/spells-pet.c spell-kind/spells-pet.h \
        spell-kind/spells-perception.c spell-kind/spells-perception.h \
+       spell-kind/spells-polymorph.c spell-kind/spells-polymorph.h \
        spell-kind/spells-random.c spell-kind/spells-random.h \
        spell-kind/spells-recall.c spell-kind/spells-recall.h \
        spell-kind/spells-sight.c spell-kind/spells-sight.h \
index 5b90525..f638ac5 100644 (file)
@@ -32,6 +32,7 @@
 #include "object/object-kind-hook.h"
 #include "player/avatar.h"
 #include "player/player-move.h"
+#include "spell-kind/spells-polymorph.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell/spell-types.h"
 #include "spell/spells3.h"
index 65b8dbb..86e8ce0 100644 (file)
@@ -20,9 +20,9 @@
 #include "object/object-flavor.h"
 #include "object/object-mark-types.h"
 #include "realm/realm-hex-numbers.h"
-#include "spell-realm/spells-hex.h"
+#include "spell-kind/spells-polymorph.h"
 #include "spell-kind/spells-teleport.h"
-#include "spell/spells3.h"
+#include "spell-realm/spells-hex.h"
 #include "view/display-messages.h"
 
 /*!
diff --git a/src/spell-kind/spells-polymorph.c b/src/spell-kind/spells-polymorph.c
new file mode 100644 (file)
index 0000000..c7b9f0a
--- /dev/null
@@ -0,0 +1,128 @@
+#include "spell-kind/spells-polymorph.h"
+#include "core/stuff-handler.h"
+#include "floor/floor-object.h"
+#include "floor/floor.h"
+#include "grid/grid.h"
+#include "io/targeting.h"
+#include "monster-floor/monster-generator.h"
+#include "monster-floor/monster-remover.h"
+#include "monster-floor/place-monster-types.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster-flag-types.h"
+#include "monster/monster-info.h"
+#include "monster/monster-list.h"
+#include "monster/monster-status.h"
+#include "monster/monster-util.h"
+#include "system/object-type-definition.h"
+
+/*!
+ * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
+ * Helper function -- return a "nearby" race for polymorphing
+ * @param floor_ptr 配置するフロアの参照ポインタ
+ * @param r_idx 基準となるモンスター種族ID
+ * @return 変更先のモンスター種族ID
+ * @details
+ * Note that this function is one of the more "dangerous" ones...
+ */
+static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx)
+{
+    monster_race *r_ptr = &r_info[r_idx];
+    if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
+        return (r_idx);
+
+    DEPTH lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
+    DEPTH lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
+    MONRACE_IDX r;
+    for (int i = 0; i < 1000; i++) {
+        r = get_mon_num(caster_ptr, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5, 0);
+        if (!r)
+            break;
+
+        r_ptr = &r_info[r];
+        if (r_ptr->flags1 & RF1_UNIQUE)
+            continue;
+        if ((r_ptr->level < lev1) || (r_ptr->level > lev2))
+            continue;
+
+        r_idx = r;
+        break;
+    }
+
+    return r_idx;
+}
+
+/*!
+ * @brief 指定座標にいるモンスターを変身させる /
+ * Helper function -- return a "nearby" race for polymorphing
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param y 指定のY座標
+ * @param x 指定のX座標
+ * @return 実際に変身したらTRUEを返す
+ */
+bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
+{
+    floor_type *floor_ptr = caster_ptr->current_floor_ptr;
+    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+    monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
+    MONRACE_IDX new_r_idx;
+    MONRACE_IDX old_r_idx = m_ptr->r_idx;
+    bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
+    bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
+
+    if (floor_ptr->inside_arena || caster_ptr->phase_out)
+        return FALSE;
+    if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE))
+        return FALSE;
+
+    monster_type back_m = *m_ptr;
+    new_r_idx = poly_r_idx(caster_ptr, old_r_idx);
+    if (new_r_idx == old_r_idx)
+        return FALSE;
+
+    bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
+    OBJECT_IDX this_o_idx, next_o_idx = 0;
+
+    BIT_FLAGS mode = 0L;
+    if (is_friendly(m_ptr))
+        mode |= PM_FORCE_FRIENDLY;
+    if (is_pet(m_ptr))
+        mode |= PM_FORCE_PET;
+    if (m_ptr->mflag2 & MFLAG2_NOPET)
+        mode |= PM_NO_PET;
+
+    m_ptr->hold_o_idx = 0;
+    delete_monster_idx(caster_ptr, g_ptr->m_idx);
+    bool polymorphed = FALSE;
+    if (place_monster_aux(caster_ptr, 0, y, x, new_r_idx, mode)) {
+        floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
+        floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
+        floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
+        polymorphed = TRUE;
+    } else {
+        if (place_monster_aux(caster_ptr, 0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN))) {
+            floor_ptr->m_list[hack_m_idx_ii] = back_m;
+            mproc_init(floor_ptr);
+        } else
+            preserve_hold_objects = FALSE;
+    }
+
+    if (preserve_hold_objects) {
+        for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
+            object_type *o_ptr = &floor_ptr->o_list[this_o_idx];
+            next_o_idx = o_ptr->next_o_idx;
+            o_ptr->held_m_idx = hack_m_idx_ii;
+        }
+    } else if (back_m.hold_o_idx) {
+        for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
+            next_o_idx = floor_ptr->o_list[this_o_idx].next_o_idx;
+            delete_object_idx(caster_ptr, this_o_idx);
+        }
+    }
+
+    if (targeted)
+        target_who = hack_m_idx_ii;
+    if (health_tracked)
+        health_track(caster_ptr, hack_m_idx_ii);
+    return polymorphed;
+}
diff --git a/src/spell-kind/spells-polymorph.h b/src/spell-kind/spells-polymorph.h
new file mode 100644 (file)
index 0000000..1fa7290
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x);
index 9c2484d..e2beb1f 100644 (file)
@@ -455,117 +455,6 @@ bool recharge(player_type *caster_ptr, int power)
 }
 
 /*!
- * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
- * Helper function -- return a "nearby" race for polymorphing
- * @param floor_ptr 配置するフロアの参照ポインタ
- * @param r_idx 基準となるモンスター種族ID
- * @return 変更先のモンスター種族ID
- * @details
- * Note that this function is one of the more "dangerous" ones...
- */
-static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx)
-{
-    monster_race *r_ptr = &r_info[r_idx];
-    if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
-        return (r_idx);
-
-    DEPTH lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
-    DEPTH lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
-    MONRACE_IDX r;
-    for (int i = 0; i < 1000; i++) {
-        r = get_mon_num(caster_ptr, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5, 0);
-        if (!r)
-            break;
-
-        r_ptr = &r_info[r];
-        if (r_ptr->flags1 & RF1_UNIQUE)
-            continue;
-        if ((r_ptr->level < lev1) || (r_ptr->level > lev2))
-            continue;
-
-        r_idx = r;
-        break;
-    }
-
-    return r_idx;
-}
-
-/*!
- * @brief 指定座標にいるモンスターを変身させる /
- * Helper function -- return a "nearby" race for polymorphing
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @param y 指定のY座標
- * @param x 指定のX座標
- * @return 実際に変身したらTRUEを返す
- */
-bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
-{
-    floor_type *floor_ptr = caster_ptr->current_floor_ptr;
-    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
-    MONRACE_IDX new_r_idx;
-    MONRACE_IDX old_r_idx = m_ptr->r_idx;
-    bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
-    bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
-
-    if (floor_ptr->inside_arena || caster_ptr->phase_out)
-        return FALSE;
-    if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE))
-        return FALSE;
-
-    monster_type back_m = *m_ptr;
-    new_r_idx = poly_r_idx(caster_ptr, old_r_idx);
-    if (new_r_idx == old_r_idx)
-        return FALSE;
-
-    bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
-    OBJECT_IDX this_o_idx, next_o_idx = 0;
-
-    BIT_FLAGS mode = 0L;
-    if (is_friendly(m_ptr))
-        mode |= PM_FORCE_FRIENDLY;
-    if (is_pet(m_ptr))
-        mode |= PM_FORCE_PET;
-    if (m_ptr->mflag2 & MFLAG2_NOPET)
-        mode |= PM_NO_PET;
-
-    m_ptr->hold_o_idx = 0;
-    delete_monster_idx(caster_ptr, g_ptr->m_idx);
-    bool polymorphed = FALSE;
-    if (place_monster_aux(caster_ptr, 0, y, x, new_r_idx, mode)) {
-        floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
-        floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
-        floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
-        polymorphed = TRUE;
-    } else {
-        if (place_monster_aux(caster_ptr, 0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN))) {
-            floor_ptr->m_list[hack_m_idx_ii] = back_m;
-            mproc_init(floor_ptr);
-        } else
-            preserve_hold_objects = FALSE;
-    }
-
-    if (preserve_hold_objects) {
-        for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
-            object_type *o_ptr = &floor_ptr->o_list[this_o_idx];
-            next_o_idx = o_ptr->next_o_idx;
-            o_ptr->held_m_idx = hack_m_idx_ii;
-        }
-    } else if (back_m.hold_o_idx) {
-        for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
-            next_o_idx = floor_ptr->o_list[this_o_idx].next_o_idx;
-            delete_object_idx(caster_ptr, this_o_idx);
-        }
-    }
-
-    if (targeted)
-        target_who = hack_m_idx_ii;
-    if (health_tracked)
-        health_track(caster_ptr, hack_m_idx_ii);
-    return polymorphed;
-}
-
-/*!
  * @brief 皆殺し(全方向攻撃)処理
  * @param caster_ptr プレーヤーへの参照ポインタ
  * @return なし
index ab0f00c..63e9423 100644 (file)
@@ -6,7 +6,6 @@ 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);
 bool recharge(player_type* caster_ptr, int power);
-bool polymorph_monster(player_type* caster_ptr, POSITION y, POSITION x);
 void massacre(player_type* caster_ptr);
 bool eat_rock(player_type* caster_ptr);
 bool shock_power(player_type* caster_ptr);