OSDN Git Service

[Refactor] #40581 Separated monster-death-util.c/h from monster-death.c
authorHourier <hourier@users.sourceforge.jp>
Fri, 21 Aug 2020 06:29:39 +0000 (15:29 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 21 Aug 2020 06:29:39 +0000 (15:29 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/monster-floor/monster-death-util.c [new file with mode: 0644]
src/monster-floor/monster-death-util.h [new file with mode: 0644]
src/monster-floor/monster-death.c
src/monster-race/race-indice-types.h

index 196dc96..cbc547f 100644 (file)
     <ClCompile Include="..\..\src\mind\mind-power-getter.c" />\r
     <ClCompile Include="..\..\src\mind\mind-priest.c" />\r
     <ClCompile Include="..\..\src\mind\mind-weaponsmith.c" />\r
+    <ClCompile Include="..\..\src\monster-floor\monster-death-util.c" />\r
     <ClCompile Include="..\..\src\monster-floor\monster-lite-util.c" />\r
     <ClCompile Include="..\..\src\monster-floor\monster-lite.c" />\r
     <ClCompile Include="..\..\src\monster\monster-status-setter.c" />\r
     <ClInclude Include="..\..\src\mind\mind-priest.h" />\r
     <ClInclude Include="..\..\src\mind\mind-types.h" />\r
     <ClInclude Include="..\..\src\mind\mind-weaponsmith.h" />\r
+    <ClInclude Include="..\..\src\monster-floor\monster-death-util.h" />\r
     <ClInclude Include="..\..\src\monster-floor\monster-lite-util.h" />\r
     <ClInclude Include="..\..\src\monster-floor\monster-lite.h" />\r
     <ClInclude Include="..\..\src\monster\monster-status-setter.h" />\r
index 0962748..3e79dfa 100644 (file)
     <ClCompile Include="..\..\src\mind\mind-hobbit.c">
       <Filter>mind</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\monster-floor\monster-death-util.c">
+      <Filter>monster-floor</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\mind\mind-hobbit.h">
       <Filter>mind</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\monster-floor\monster-death-util.h">
+      <Filter>monster-floor</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index fb19f4f..edfebc0 100644 (file)
@@ -476,6 +476,7 @@ hengband_SOURCES = \
        monster-attack/monster-eating.c monster-attack/monster-eating.h \
        \
        monster-floor/monster-death.c monster-floor/monster-death.h \
+       monster-floor/monster-death-util.c monster-floor/monster-death-util.h \
        monster-floor/monster-direction.c monster-floor/monster-direction.h \
        monster-floor/monster-dist-offsets.c monster-floor/monster-dist-offsets.h \
        monster-floor/monster-generator.c monster-floor/monster-generator.h \
diff --git a/src/monster-floor/monster-death-util.c b/src/monster-floor/monster-death-util.c
new file mode 100644 (file)
index 0000000..04f67e0
--- /dev/null
@@ -0,0 +1,49 @@
+#include "monster-floor/monster-death-util.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags1.h"
+#include "monster-race/race-indice-types.h"
+#include "monster/monster-info.h"
+#include "monster/smart-learn-types.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-type-definition.h"
+
+/*!
+ * @brief \83\82\83\93\83X\83^\81[\82ð\93|\82µ\82½\8dÛ\82Ì\8dà\95ósval\82ð\95Ô\82·
+ * @param r_idx \93|\82µ\82½\83\82\83\93\83X\83^\81[\82Ì\8eí\91°ID
+ * @return \8dà\95ó\82Ìsval
+ * @details
+ * Hack -- Return the "automatic coin type" of a monster race
+ * Used to allocate proper treasure when "Creeping coins" die
+ * Note the use of actual "monster names"
+ */
+static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
+{
+    switch (r_idx) {
+    case MON_COPPER_COINS:
+        return 2;
+    case MON_SILVER_COINS:
+        return 5;
+    case MON_GOLD_COINS:
+        return 10;
+    case MON_MITHRIL_COINS:
+    case MON_MITHRIL_GOLEM:
+        return 16;
+    case MON_ADAMANT_COINS:
+        return 17;
+    }
+
+    return MON_PLAYER;
+}
+
+monster_death_type *initialize_monster_death_type(player_type *player_ptr, monster_death_type *md_ptr, MONSTER_IDX m_idx, bool drop_item)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    md_ptr->m_ptr = &floor_ptr->m_list[m_idx];
+    md_ptr->r_ptr = &r_info[md_ptr->m_ptr->r_idx];
+    md_ptr->do_gold = (!(md_ptr->r_ptr->flags1 & RF1_ONLY_ITEM));
+    md_ptr->do_item = (!(md_ptr->r_ptr->flags1 & RF1_ONLY_GOLD));
+    md_ptr->cloned = (md_ptr->m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
+    md_ptr->force_coin = get_coin_type(md_ptr->m_ptr->r_idx);
+    md_ptr->drop_chosen_item = drop_item && !md_ptr->cloned && !floor_ptr->inside_arena && !player_ptr->phase_out && !is_pet(md_ptr->m_ptr);
+    return md_ptr;
+}
diff --git a/src/monster-floor/monster-death-util.h b/src/monster-floor/monster-death-util.h
new file mode 100644 (file)
index 0000000..f24b467
--- /dev/null
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "system/angband.h"
+
+typedef struct monster_type monster_type;
+typedef struct monster_race monster_race;
+typedef struct monster_death_type {
+    monster_type *m_ptr;
+    monster_race *r_ptr;
+    bool do_gold;
+    bool do_item;
+    bool cloned;
+    int force_coin;
+    bool drop_chosen_item;
+    POSITION md_y;
+    POSITION md_x;
+} monster_death_type;
+
+monster_death_type *initialize_monster_death_type(player_type *player_ptr, monster_death_type *md_ptr, MONSTER_IDX m_idx, bool drop_item);
index 521404f..727bf72 100644 (file)
@@ -22,6 +22,7 @@
 #include "main/music-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "market/arena-info-table.h"
+#include "monster-floor/monster-death-util.h"
 #include "monster-floor/monster-object.h"
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
-typedef struct monster_death_type {
-    monster_type *m_ptr;
-    monster_race *r_ptr;
-    bool do_gold;
-    bool do_item;
-    bool cloned;
-    int force_coin;
-    bool drop_chosen_item;
-    POSITION md_y;
-    POSITION md_x;
-} monster_death_type;
-
-monster_death_type *initialize_monster_death_type(player_type *player_ptr, monster_death_type *md_ptr, MONSTER_IDX m_idx, bool drop_item)
-{
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    md_ptr->m_ptr = &floor_ptr->m_list[m_idx];
-    md_ptr->r_ptr = &r_info[md_ptr->m_ptr->r_idx];
-    md_ptr->do_gold = (!(md_ptr->r_ptr->flags1 & RF1_ONLY_ITEM));
-    md_ptr->do_item = (!(md_ptr->r_ptr->flags1 & RF1_ONLY_GOLD));
-    md_ptr->cloned = (md_ptr->m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
-    md_ptr->force_coin = get_coin_type(md_ptr->m_ptr->r_idx);
-    md_ptr->drop_chosen_item = drop_item && !md_ptr->cloned && !floor_ptr->inside_arena && !player_ptr->phase_out && !is_pet(md_ptr->m_ptr);
-    return md_ptr;
-}
-
-/*!
- * @brief モンスターを倒した際の財宝svalを返す
- * @param r_idx 倒したモンスターの種族ID
- * @return 財宝のsval
- * @details
- * Hack -- Return the "automatic coin type" of a monster race
- * Used to allocate proper treasure when "Creeping coins" die
- * Note the use of actual "monster names"
- */
-static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
-{
-    switch (r_idx) {
-    case MON_COPPER_COINS:
-        return 2;
-    case MON_SILVER_COINS:
-        return 5;
-    case MON_GOLD_COINS:
-        return 10;
-    case MON_MITHRIL_COINS:
-    case MON_MITHRIL_GOLEM:
-        return 16;
-    case MON_ADAMANT_COINS:
-        return 17;
-    }
-
-    return 0;
-}
-
 /*!
  * @brief モンスターが死亡した時の処理 /
  * Handle the "death" of a monster.
index 125d119..51212e5 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 typedef enum monster_race_type {
+    MON_PLAYER = 0, // Dummy.
     MON_BEGGAR = 12,
     MON_LEPER = 13,
     MON_LION_HEART = 19,