From: Hourier Date: Sun, 2 Aug 2020 10:07:32 +0000 (+0900) Subject: [Refactor] #40512 Separated random-art-info-dumper.c/h X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b112cea9bebaf2c05034609491549c554eb2cc85;p=hengband%2Fhengband.git [Refactor] #40512 Separated random-art-info-dumper.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 5412f8387..bce33ee3e 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -254,6 +254,7 @@ + @@ -830,6 +831,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 06df75775..2c4b7876f 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1964,6 +1964,9 @@ wizard + + io-dump + @@ -4270,6 +4273,9 @@ wizard + + io-dump + diff --git a/src/Makefile.am b/src/Makefile.am index c92a23e53..ca9b2635f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 000000000..0908186aa --- /dev/null +++ b/src/io-dump/random-art-info-dumper.c @@ -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 index 000000000..026606629 --- /dev/null +++ b/src/io-dump/random-art-info-dumper.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +void spoil_random_artifact(player_type *creature_ptr, concptr fname); diff --git a/src/io/input-key-processor.c b/src/io/input-key-processor.c index 239dc74ce..2b9165af6 100644 --- a/src/io/input-key-processor.c +++ b/src/io/input-key-processor.c @@ -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" /*! diff --git a/src/wizard/wizard-spoiler.c b/src/wizard/wizard-spoiler.c index 195ad65a3..6437cfbc0 100644 --- a/src/wizard/wizard-spoiler.c +++ b/src/wizard/wizard-spoiler.c @@ -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."); -} diff --git a/src/wizard/wizard-spoiler.h b/src/wizard/wizard-spoiler.h index 8e2b1c3e6..ad65ecd98 100644 --- a/src/wizard/wizard-spoiler.h +++ b/src/wizard/wizard-spoiler.h @@ -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);