OSDN Git Service

[Refactor] #40014 Separated lore-store.c/h from monster2.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 12:40:58 +0000 (21:40 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 12:40:58 +0000 (21:40 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/market/building-monster.c
src/monster-lore/lore-store.c [new file with mode: 0644]
src/monster-lore/lore-store.h [new file with mode: 0644]
src/monster/monster1.c
src/monster/monster2.c
src/monster/monster2.h
src/spell-kind/spells-sight.c

index b424c8c..372e149 100644 (file)
     <ClCompile Include="..\..\src\info-reader\race-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\skill-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\vault-reader.c" />\r
+    <ClCompile Include="..\..\src\monster-lore\lore-store.c" />\r
     <ClCompile Include="..\..\src\monster-lore\monster-lore.c" />\r
     <ClCompile Include="..\..\src\monster\monster-util.c" />\r
     <ClCompile Include="..\..\src\object-enchant\activation-info-table.c" />\r
     <ClInclude Include="..\..\src\info-reader\vault-reader.h" />\r
     <ClInclude Include="..\..\src\mind\drs-types.h" />\r
     <ClInclude Include="..\..\src\mind\snipe-types.h" />\r
+    <ClInclude Include="..\..\src\monster-lore\lore-store.h" />\r
     <ClInclude Include="..\..\src\monster-lore\monster-lore.h" />\r
     <ClInclude Include="..\..\src\monster-race\race-flags8.h" />\r
     <ClInclude Include="..\..\src\monster-race\race-flags-ability1.h" />\r
index e90ac51..d077a59 100644 (file)
     <ClCompile Include="..\..\src\monster-lore\monster-lore.c">
       <Filter>monster-lore</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\monster-lore\lore-store.c">
+      <Filter>monster-lore</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\monster-lore\monster-lore.h">
       <Filter>monster-lore</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\monster-lore\lore-store.h">
+      <Filter>monster-lore</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 050f1bc..0e49a8d 100644 (file)
@@ -310,6 +310,7 @@ hengband_SOURCES = \
        monster-attack/monster-attack-util.c monster-attack/monster-attack-util.h \
        monster-attack/monster-eating.c monster-attack/monster-eating.h \
        \
+       monster-lore/lore-store.c monster-lore/lore-store.h \
        monster-lore/monster-lore.c monster-lore/monster-lore.h \
        \
        monster-race/monster-race.c monster-race/monster-race.h \
index 4c5e374..2b64f99 100644 (file)
@@ -2,8 +2,8 @@
 #include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "monster-race/race-flags1.h"
+#include "monster-lore/lore-store.h"
 #include "monster/monster1.h"
-#include "monster/monster2.h"
 #include "term/gameterm.h"
 #include "term/term-color-types.h"
 #include "view/display-main-window.h"
diff --git a/src/monster-lore/lore-store.c b/src/monster-lore/lore-store.c
new file mode 100644 (file)
index 0000000..0af1809
--- /dev/null
@@ -0,0 +1,114 @@
+#include "monster-lore/lore-store.h"
+#include "floor/floor.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster2.h" // todo 依存しているのは気持ち悪い。後で消したい.
+#include "system/monster-type-definition.h"
+
+/*!
+ * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param r_idx 補完されるモンスター種族ID
+ * @return 明らかになった情報の度数
+ * @details
+ * Return the number of new flags learnt.  -Mogami-
+ */
+int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx)
+{
+    int n = 0;
+    monster_race *r_ptr = &r_info[r_idx];
+    if (r_ptr->r_wake != MAX_UCHAR)
+        n++;
+    if (r_ptr->r_ignore != MAX_UCHAR)
+        n++;
+    r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
+
+    for (int i = 0; i < 4; i++) {
+        if (r_ptr->blow[i].effect || r_ptr->blow[i].method) {
+            if (r_ptr->r_blows[i] != MAX_UCHAR)
+                n++;
+            r_ptr->r_blows[i] = MAX_UCHAR;
+        }
+    }
+
+    byte tmp_byte = (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) + ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) + ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0)
+        + ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) + ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) + ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
+
+    if (!(r_ptr->flags1 & RF1_ONLY_GOLD)) {
+        if (r_ptr->r_drop_item != tmp_byte)
+            n++;
+        r_ptr->r_drop_item = tmp_byte;
+    }
+    if (!(r_ptr->flags1 & RF1_ONLY_ITEM)) {
+        if (r_ptr->r_drop_gold != tmp_byte)
+            n++;
+        r_ptr->r_drop_gold = tmp_byte;
+    }
+
+    if (r_ptr->r_cast_spell != MAX_UCHAR)
+        n++;
+    r_ptr->r_cast_spell = MAX_UCHAR;
+
+    for (int i = 0; i < 32; i++) {
+        if (!(r_ptr->r_flags1 & (1L << i)) && (r_ptr->flags1 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flags2 & (1L << i)) && (r_ptr->flags2 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flags3 & (1L << i)) && (r_ptr->flags3 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flags4 & (1L << i)) && (r_ptr->flags4 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flags5 & (1L << i)) && (r_ptr->a_ability_flags1 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flags6 & (1L << i)) && (r_ptr->a_ability_flags2 & (1L << i)))
+            n++;
+        if (!(r_ptr->r_flagsr & (1L << i)) && (r_ptr->flagsr & (1L << i)))
+            n++;
+    }
+
+    r_ptr->r_flags1 = r_ptr->flags1;
+    r_ptr->r_flags2 = r_ptr->flags2;
+    r_ptr->r_flags3 = r_ptr->flags3;
+    r_ptr->r_flags4 = r_ptr->flags4;
+    r_ptr->r_flags5 = r_ptr->a_ability_flags1;
+    r_ptr->r_flags6 = r_ptr->a_ability_flags2;
+    r_ptr->r_flagsr = r_ptr->flagsr;
+
+    if (!(r_ptr->r_xtra1 & MR1_SINKA))
+        n++;
+    r_ptr->r_xtra1 |= MR1_SINKA;
+
+    if (player_ptr->monster_race_idx == r_idx) {
+        player_ptr->window |= (PW_MONSTER);
+    }
+
+    return n;
+}
+
+/*!
+ * @brief モンスターの撃破に伴うドロップ情報の記憶処理 / Take note that the given monster just dropped some treasure
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param m_idx モンスター情報のID
+ * @param num_item 手に入れたアイテム数
+ * @param num_gold 手に入れた財宝の単位数
+ * @return なし
+ */
+void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
+{
+    monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
+    monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+    if (!is_original_ap(m_ptr))
+        return;
+
+    if (num_item > r_ptr->r_drop_item)
+        r_ptr->r_drop_item = num_item;
+    if (num_gold > r_ptr->r_drop_gold)
+        r_ptr->r_drop_gold = num_gold;
+
+    if (r_ptr->flags1 & (RF1_DROP_GOOD))
+        r_ptr->r_flags1 |= (RF1_DROP_GOOD);
+    if (r_ptr->flags1 & (RF1_DROP_GREAT))
+        r_ptr->r_flags1 |= (RF1_DROP_GREAT);
+    if (player_ptr->monster_race_idx == m_ptr->r_idx)
+        player_ptr->window |= (PW_MONSTER);
+}
diff --git a/src/monster-lore/lore-store.h b/src/monster-lore/lore-store.h
new file mode 100644 (file)
index 0000000..d30ed63
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "system/angband.h"
+
+int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx);
+void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold);
index 0cb9914..d6654f4 100644 (file)
@@ -28,6 +28,7 @@
 #include "melee/melee-postprocess.h"
 #include "monster-attack/monster-attack-effect.h"
 #include "monster-attack/monster-attack-types.h"
+#include "monster-lore/lore-store.h"
 #include "monster-lore/monster-lore.h"
 #include "monster-race/race-flags-resistance.h"
 #include "monster-race/race-flags-ability1.h"
index 2348f5f..d333127 100644 (file)
@@ -1144,185 +1144,10 @@ void monster_name(player_type *player_ptr, MONSTER_IDX m_idx, char* m_name)
 
 
 /*!
- * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param r_idx 補完されるモンスター種族ID
- * @return 明らかになった情報の度数
- * @details
- * Return the number of new flags learnt.  -Mogami-
- */
-int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx)
-{
-       int n = 0;
-       monster_race *r_ptr = &r_info[r_idx];
-       if (r_ptr->r_wake != MAX_UCHAR) n++;
-       if (r_ptr->r_ignore != MAX_UCHAR) n++;
-       r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
-
-       for (int i = 0; i < 4; i++)
-       {
-               if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
-               {
-                       if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
-                       r_ptr->r_blows[i] = MAX_UCHAR;
-               }
-       }
-
-       byte tmp_byte =
-               (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
-               ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
-                       ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
-                       ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
-                       ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
-                       ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
-
-       if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
-       {
-               if (r_ptr->r_drop_item != tmp_byte) n++;
-               r_ptr->r_drop_item = tmp_byte;
-       }
-       if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
-       {
-               if (r_ptr->r_drop_gold != tmp_byte) n++;
-               r_ptr->r_drop_gold = tmp_byte;
-       }
-
-       if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
-       r_ptr->r_cast_spell = MAX_UCHAR;
-
-       for (int i = 0; i < 32; i++)
-       {
-               if (!(r_ptr->r_flags1 & (1L << i)) &&
-                       (r_ptr->flags1 & (1L << i))) n++;
-               if (!(r_ptr->r_flags2 & (1L << i)) &&
-                       (r_ptr->flags2 & (1L << i))) n++;
-               if (!(r_ptr->r_flags3 & (1L << i)) &&
-                       (r_ptr->flags3 & (1L << i))) n++;
-               if (!(r_ptr->r_flags4 & (1L << i)) &&
-                       (r_ptr->flags4 & (1L << i))) n++;
-               if (!(r_ptr->r_flags5 & (1L << i)) &&
-                       (r_ptr->a_ability_flags1 & (1L << i))) n++;
-               if (!(r_ptr->r_flags6 & (1L << i)) &&
-                       (r_ptr->a_ability_flags2 & (1L << i))) n++;
-               if (!(r_ptr->r_flagsr & (1L << i)) &&
-                       (r_ptr->flagsr & (1L << i))) n++;
-       }
-
-       r_ptr->r_flags1 = r_ptr->flags1;
-       r_ptr->r_flags2 = r_ptr->flags2;
-       r_ptr->r_flags3 = r_ptr->flags3;
-       r_ptr->r_flags4 = r_ptr->flags4;
-       r_ptr->r_flags5 = r_ptr->a_ability_flags1;
-       r_ptr->r_flags6 = r_ptr->a_ability_flags2;
-       r_ptr->r_flagsr = r_ptr->flagsr;
-
-       if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
-       r_ptr->r_xtra1 |= MR1_SINKA;
-
-       if (player_ptr->monster_race_idx == r_idx)
-       {
-               player_ptr->window |= (PW_MONSTER);
-       }
-
-       return n;
-}
-
-
-/*!
- * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param m_idx モンスター情報のID
- * @param num_item 手に入れたアイテム数
- * @param num_gold 手に入れた財宝の単位数
- * @return なし
- * @details
- * Note that learning the "GOOD"/"GREAT" flags gives information
- * about the treasure (even when the monster is killed for the first
- * time, such as uniques, and the treasure has not been examined yet).
- *
- * This "indirect" method is used to prevent the player from learning
- * exactly how much treasure a monster can drop from observing only
- * a single example of a drop.  This method actually observes how much
- * gold and items are dropped, and remembers that information to be
- * described later by the monster recall code.
- */
-void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
-{
-       monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-       if (!is_original_ap(m_ptr)) return;
-
-       if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
-       if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
-
-       if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
-       if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
-       if (player_ptr->monster_race_idx == m_ptr->r_idx) player_ptr->window |= (PW_MONSTER);
-}
-
-
-/*!
  * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
  * @param m_idx 更新するモンスター情報のID
  * @param full プレイヤーとの距離更新を行うならばtrue
  * @return なし
- * @details
- * This involves extracting the distance to the player (if requested),
- * and then checking for visibility (natural, infravision, see-invis,
- * telepathy), updating the monster visibility flag, redrawing (or
- * erasing) the monster when its visibility changes, and taking note
- * of any interesting monster flags (cold-blooded, invisible, etc).
- *
- * Note the new "mflag" field which encodes several monster state flags,
- * including "view" for when the monster is currently in line of sight,
- * and "mark" for when the monster is currently visible via detection.
- *
- * The only monster fields that are changed here are "cdis" (the
- * distance from the player), "ml" (visible to the player), and
- * "mflag" (to maintain the "MFLAG_VIEW" flag).
- *
- * Note the special "update_monsters()" function which can be used to
- * call this function once for every monster.
- *
- * Note the "full" flag which requests that the "cdis" field be updated,
- * this is only needed when the monster (or the player) has moved.
- *
- * Every time a monster moves, we must call this function for that
- * monster, and update the distance, and the visibility.  Every time
- * the player moves, we must call this function for every monster, and
- * update the distance, and the visibility.  Whenever the player "state"
- * changes in certain ways ("blindness", "infravision", "telepathy",
- * and "see invisible"), we must call this function for every monster,
- * and update the visibility.
- *
- * Routines that change the "illumination" of a grid must also call this
- * function for any monster in that grid, since the "visibility" of some
- * monsters may be based on the illumination of their grid.
- *
- * Note that this function is called once per monster every time the
- * player moves.  When the player is running, this function is one
- * of the primary bottlenecks, along with "update_view()" and the
- * "process_monsters()" code, so efficiency is important.
- *
- * Note the optimized "inline" version of the "distance()" function.
- *
- * A monster is "visible" to the player if (1) it has been detected
- * by the player, (2) it is close to the player and the player has
- * telepathy, or (3) it is close to the player, and in line of sight
- * of the player, and it is "illuminated" by some combination of
- * infravision, torch light, or permanent light (invisible monsters
- * are only affected by "light" if the player can see invisible).
- *
- * Monsters which are not on the current panel may be "visible" to
- * the player, and their descriptions will include an "offscreen"
- * reference.  Currently, offscreen monsters cannot be targetted
- * or viewed directly, but old targets will remain set.  XXX XXX
- *
- * The player can choose to be disturbed by several things, including
- * "disturb_move" (monster which is viewable moves in some way), and
- * "disturb_near" (monster which is "easily" viewable moves in some
- * way).  Note that "moves" includes "appears" and "disappears".
  */
 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
 {
@@ -3326,3 +3151,5 @@ bool is_friendly_idx(player_type *player_ptr, MONSTER_IDX m_idx)
 {
        return m_idx > 0 && is_friendly(&player_ptr->current_floor_ptr->m_list[(m_idx)]);
 }
+
+bool is_original_ap(monster_type* m_ptr) { return m_ptr->ap_r_idx == m_ptr->r_idx; }
index 97c3b3d..137d813 100644 (file)
@@ -14,8 +14,6 @@ MONSTER_IDX m_pop(player_type *player_ptr);
 
 #define GMN_ARENA 0x00000001 //!< 賭け闘技場向け生成
 MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option);
-int lore_do_probe(player_type *player_ptr, MONRACE_IDX r_idx);
-void lore_treasure(player_type *player_ptr, MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold);
 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full);
 void update_monsters(player_type *player_ptr, bool full);
 bool multiply_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode);
@@ -32,8 +30,8 @@ void monster_drop_carried_objects(player_type *player_ptr, monster_type *m_ptr);
 
 #define is_hostile(A) (bool)((is_friendly(A) || is_pet(A)) ? FALSE : TRUE)
 
-/* Hack -- Determine monster race appearance index is same as race index */
-#define is_original_ap(A) (bool)(((A)->ap_r_idx == (A)->r_idx) ? TRUE : FALSE)
+/*  Determine monster race appearance index is same as race index */
+bool is_original_ap(monster_type *m_ptr);
 
 int get_monster_crowd_number(player_type *player_ptr, MONSTER_IDX m_idx);
 void message_pain(player_type *player_ptr, MONSTER_IDX m_idx, HIT_POINT dam);
index 8c4f10c..5165e7e 100644 (file)
@@ -3,6 +3,7 @@
 #include "effect/effect-characteristics.h"
 #include "floor/floor.h"
 #include "locale/english.h"
+#include "monster-lore/lore-store.h"
 #include "monster-race/race-flags3.h"
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"