OSDN Git Service

[Refactor] #40512 Separated random-art-info-dumper.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 2 Aug 2020 10:07:32 +0000 (19:07 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 2 Aug 2020 10:07:32 +0000 (19:07 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/io-dump/random-art-info-dumper.c [new file with mode: 0644]
src/io-dump/random-art-info-dumper.h [new file with mode: 0644]
src/io/input-key-processor.c
src/wizard/wizard-spoiler.c
src/wizard/wizard-spoiler.h

index 5412f83..bce33ee 100644 (file)
     <ClCompile Include="..\..\src\inventory\inventory-describer.c" />\r
     <ClCompile Include="..\..\src\inventory\inventory-util.c" />\r
     <ClCompile Include="..\..\src\inventory\item-getter.c" />\r
+    <ClCompile Include="..\..\src\io-dump\random-art-info-dumper.c" />\r
     <ClCompile Include="..\..\src\io\command-repeater.c" />\r
     <ClCompile Include="..\..\src\io\cursor.c" />\r
     <ClCompile Include="..\..\src\io\input-key-acceptor.c" />\r
     <ClInclude Include="..\..\src\inventory\inventory-describer.h" />\r
     <ClInclude Include="..\..\src\inventory\inventory-util.h" />\r
     <ClInclude Include="..\..\src\inventory\item-getter.h" />\r
+    <ClInclude Include="..\..\src\io-dump\random-art-info-dumper.h" />\r
     <ClInclude Include="..\..\src\io\command-repeater.h" />\r
     <ClInclude Include="..\..\src\io\cursor.h" />\r
     <ClInclude Include="..\..\src\io\input-key-acceptor.h" />\r
index 06df757..2c4b787 100644 (file)
     <ClCompile Include="..\..\src\wizard\monster-info-spoiler.c">
       <Filter>wizard</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\io-dump\random-art-info-dumper.c">
+      <Filter>io-dump</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\wizard\monster-info-spoiler.h">
       <Filter>wizard</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\io-dump\random-art-info-dumper.h">
+      <Filter>io-dump</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index c92a23e..ca9b263 100644 (file)
@@ -299,6 +299,7 @@ hengband_SOURCES = \
        io-dump/dump-remover.c io-dump/dump-remover.h \
        io-dump/dump-util.c io-dump/dump-util.h \
        io-dump/player-status-dump.c io-dump/player-status-dump.h \
+       io-dump/random-art-info-dumper.c io-dump/random-art-info-dumper.h \
        io-dump/special-class-dump.c io-dump/special-class-dump.h \
        \
        knowledge/knowledge-autopick.c knowledge/knowledge-autopick.h \
diff --git a/src/io-dump/random-art-info-dumper.c b/src/io-dump/random-art-info-dumper.c
new file mode 100644 (file)
index 0000000..0908186
--- /dev/null
@@ -0,0 +1,116 @@
+#include "io-dump/random-art-info-dumper.h"
+#include "floor/floor-town.h"
+#include "inventory/inventory-slot-types.h"
+#include "io/files-util.h"
+#include "perception/object-perception.h"
+#include "store/store-util.h"
+#include "system/object-type-definition.h"
+#include "util/angband-files.h"
+#include "view/display-messages.h"
+#include "wizard/artifact-analyzer.h"
+#include "wizard/fixed-artifact-spoiler.h"
+#include "wizard/spoiler-util.h"
+
+/*!
+ * @brief ランダムアーティファクト1件をスポイラー出力する /
+ * Create a spoiler file entry for an artifact
+ * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
+ * @param art_ptr 記述内容を収めた構造体参照ポインタ
+ * Fill in an object description structure for a given object
+ * @return なし
+ */
+static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
+{
+    pval_info_type *pval_ptr = &art_ptr->pval_info;
+    char buf[80];
+    fprintf(spoiler_file, "%s\n", art_ptr->description);
+    if (!object_is_fully_known(o_ptr)) {
+        fprintf(spoiler_file, _("%s不明\n", "%sUnknown\n"), spoiler_indent);
+    } else {
+        if (pval_ptr->pval_desc[0]) {
+            sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
+            spoiler_outlist(buf, pval_ptr->pval_affects, item_separator);
+        }
+
+        spoiler_outlist(_("対:", "Slay"), art_ptr->slays, item_separator);
+        spoiler_outlist(_("武器属性:", ""), art_ptr->brands, list_separator);
+        spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, item_separator);
+        spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, item_separator);
+        spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, item_separator);
+        spoiler_outlist("", art_ptr->misc_magic, list_separator);
+        if (art_ptr->activation) {
+            fprintf(spoiler_file, _("%s発動: %s\n", "%sActivates for %s\n"), spoiler_indent, art_ptr->activation);
+        }
+    }
+
+    fprintf(spoiler_file, "%s%s\n\n", spoiler_indent, art_ptr->misc_desc);
+}
+
+/*!
+ * @brief ランダムアーティファクト内容をスポイラー出力するサブルーチン /
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
+ * @param i 出力したい記録ランダムアーティファクトID
+ * @return なし
+ */
+static void spoil_random_artifact_aux(player_type *player_ptr, object_type *o_ptr, int i)
+{
+    obj_desc_list artifact;
+    if (!object_is_known(o_ptr) || !o_ptr->art_name || o_ptr->tval != group_artifact[i].tval)
+        return;
+
+    random_artifact_analyze(player_ptr, o_ptr, &artifact);
+    spoiler_print_randart(o_ptr, &artifact);
+}
+
+/*!
+ * @brief ランダムアーティファクト内容をスポイラー出力するメインルーチン /
+ * Create a list file for random artifacts
+ * @param fname 出力ファイル名
+ * @return なし
+ */
+void spoil_random_artifact(player_type *creature_ptr, concptr fname)
+{
+    store_type *store_ptr;
+    object_type *q_ptr;
+    char buf[1024];
+    path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
+    spoiler_file = angband_fopen(buf, "w");
+    if (!spoiler_file) {
+        msg_print("Cannot create list file.");
+        return;
+    }
+
+    sprintf(buf, "Random artifacts list.\r");
+    spoiler_underline(buf);
+    for (int j = 0; group_artifact[j].tval; j++) {
+        for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+            q_ptr = &creature_ptr->inventory_list[i];
+            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
+        }
+
+        for (int i = 0; i < INVEN_PACK; i++) {
+            q_ptr = &creature_ptr->inventory_list[i];
+            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
+        }
+
+        store_ptr = &town_info[1].store[STORE_HOME];
+        for (int i = 0; i < store_ptr->stock_num; i++) {
+            q_ptr = &store_ptr->stock[i];
+            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
+        }
+
+        store_ptr = &town_info[1].store[STORE_MUSEUM];
+        for (int i = 0; i < store_ptr->stock_num; i++) {
+            q_ptr = &store_ptr->stock[i];
+            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
+        }
+    }
+
+    if (ferror(spoiler_file) || angband_fclose(spoiler_file)) {
+        msg_print("Cannot close list file.");
+        return;
+    }
+
+    msg_print("Successfully created a list file.");
+}
diff --git a/src/io-dump/random-art-info-dumper.h b/src/io-dump/random-art-info-dumper.h
new file mode 100644 (file)
index 0000000..0266066
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+void spoil_random_artifact(player_type *creature_ptr, concptr fname);
index 239dc74..2b9165a 100644 (file)
@@ -57,6 +57,7 @@
 #include "game-option/game-play-options.h"
 #include "game-option/input-options.h"
 #include "game-option/runtime-arguments.h"
+#include "io-dump/random-art-info-dumper.h"
 #include "io/chuukei.h"
 #include "io/command-repeater.h"
 #include "io/files-util.h"
@@ -83,7 +84,6 @@
 #include "view/display-messages.h"
 #include "window/display-sub-windows.h"
 #include "wizard/cmd-wizard.h"
-#include "wizard/wizard-spoiler.h"
 #include "world/world.h"
 
 /*!
index 195ad65..6437cfb 100644 (file)
@@ -229,108 +229,3 @@ void exe_output_spoilers(player_type *player_ptr)
         msg_erase();
     }
 }
-
-/*!
- * @brief ランダムアーティファクト1件をスポイラー出力する /
- * Create a spoiler file entry for an artifact
- * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
- * @param art_ptr 記述内容を収めた構造体参照ポインタ
- * Fill in an object description structure for a given object
- * @return なし
- */
-static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
-{
-    pval_info_type *pval_ptr = &art_ptr->pval_info;
-    char buf[80];
-    fprintf(spoiler_file, "%s\n", art_ptr->description);
-    if (!object_is_fully_known(o_ptr)) {
-        fprintf(spoiler_file, _("%s不明\n", "%sUnknown\n"), spoiler_indent);
-    } else {
-        if (pval_ptr->pval_desc[0]) {
-            sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
-            spoiler_outlist(buf, pval_ptr->pval_affects, item_separator);
-        }
-
-        spoiler_outlist(_("対:", "Slay"), art_ptr->slays, item_separator);
-        spoiler_outlist(_("武器属性:", ""), art_ptr->brands, list_separator);
-        spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, item_separator);
-        spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, item_separator);
-        spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, item_separator);
-        spoiler_outlist("", art_ptr->misc_magic, list_separator);
-        if (art_ptr->activation) {
-            fprintf(spoiler_file, _("%s発動: %s\n", "%sActivates for %s\n"), spoiler_indent, art_ptr->activation);
-        }
-    }
-
-    fprintf(spoiler_file, "%s%s\n\n", spoiler_indent, art_ptr->misc_desc);
-}
-
-/*!
- * @brief ランダムアーティファクト内容をスポイラー出力するサブルーチン /
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
- * @param i 出力したい記録ランダムアーティファクトID
- * @return なし
- */
-static void spoil_random_artifact_aux(player_type *player_ptr, object_type *o_ptr, int i)
-{
-    obj_desc_list artifact;
-    if (!object_is_known(o_ptr) || !o_ptr->art_name || o_ptr->tval != group_artifact[i].tval)
-        return;
-
-    random_artifact_analyze(player_ptr, o_ptr, &artifact);
-    spoiler_print_randart(o_ptr, &artifact);
-}
-
-/*!
- * @brief ランダムアーティファクト内容をスポイラー出力するメインルーチン /
- * Create a list file for random artifacts
- * @param fname 出力ファイル名
- * @return なし
- */
-void spoil_random_artifact(player_type *creature_ptr, concptr fname)
-{
-    int i, j;
-    store_type *store_ptr;
-    object_type *q_ptr;
-    char buf[1024];
-    path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
-    spoiler_file = angband_fopen(buf, "w");
-    if (!spoiler_file) {
-        msg_print("Cannot create list file.");
-        return;
-    }
-
-    sprintf(buf, "Random artifacts list.\r");
-    spoiler_underline(buf);
-    for (j = 0; group_artifact[j].tval; j++) {
-        for (i = INVEN_RARM; i < INVEN_TOTAL; i++) {
-            q_ptr = &creature_ptr->inventory_list[i];
-            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
-        }
-
-        for (i = 0; i < INVEN_PACK; i++) {
-            q_ptr = &creature_ptr->inventory_list[i];
-            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
-        }
-
-        store_ptr = &town_info[1].store[STORE_HOME];
-        for (i = 0; i < store_ptr->stock_num; i++) {
-            q_ptr = &store_ptr->stock[i];
-            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
-        }
-
-        store_ptr = &town_info[1].store[STORE_MUSEUM];
-        for (i = 0; i < store_ptr->stock_num; i++) {
-            q_ptr = &store_ptr->stock[i];
-            spoil_random_artifact_aux(creature_ptr, q_ptr, j);
-        }
-    }
-
-    if (ferror(spoiler_file) || angband_fclose(spoiler_file)) {
-        msg_print("Cannot close list file.");
-        return;
-    }
-
-    msg_print("Successfully created a list file.");
-}
index 8e2b1c3..ad65ecd 100644 (file)
@@ -3,4 +3,3 @@
 #include "system/angband.h"
 
 void exe_output_spoilers(player_type* player_ptr);
-void spoil_random_artifact(player_type* creature_ptr, concptr fname);