2 * @brief スポイラー出力処理 (行数の都合でモンスター進化ツリーもここに入っている)
5 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
9 * 2013 Deskull rearranged comment for Doxygen.
10 * 2020 Hourier rearranged for decreasing lines.
13 #include "wizard/wizard-spoiler.h"
14 #include "io/files-util.h"
15 #include "io/input-key-acceptor.h"
16 #include "main/sound-of-music.h"
17 #include "monster-race/monster-race.h"
18 #include "system/angband-version.h"
19 #include "term/screen-processor.h"
20 #include "util/angband-files.h"
21 #include "util/int-char-converter.h"
22 #include "util/sort.h"
23 #include "view/display-messages.h"
24 #include "wizard/fixed-artifacts-spoiler.h"
25 #include "wizard/items-spoiler.h"
26 #include "wizard/monster-info-spoiler.h"
27 #include "wizard/spoiler-util.h"
30 * @brief int配列でstrncmp()と似た比較処理を行う /
31 * Compare two int-type array like strncmp() and return TRUE if equals
35 * @return 両者の値が等しければTRUEを返す
37 static bool int_n_cmp(int *a, int *b, int length)
53 * @brief ある木が指定された木の部分木かどうかを返す /
54 * Returns TRUE if an evolution tree is "partial tree"
55 * @param tree 元となる木構造リスト
56 * @param partial_tree 部分木かどうか判定したい木構造リスト
57 * @return 部分木ならばTRUEを返す
59 static bool is_partial_tree(int *tree, int *partial_tree)
61 int pt_head = *(partial_tree++);
63 while (partial_tree[pt_len])
67 if (*(tree++) == pt_head) {
68 if (int_n_cmp(tree, partial_tree, pt_len))
77 * @brief 進化ツリーをスポイラー出力するメインルーチン /
78 * Print monsters' evolution information to file
79 * @param fname 出力ファイル名
82 static void spoil_mon_evol(player_type *player_ptr, concptr fname)
86 int **evol_tree, i, j, n, r_idx;
87 int *evol_tree_zero; /* For C_KILL() */
88 path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
89 spoiler_file = angband_fopen(buf, "w");
91 msg_print("Cannot create spoiler file.");
95 sprintf(buf, "Monster Spoilers for Bakabakaband Version %d.%d.%d\n", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
97 spoil_out("------------------------------------------\n\n");
98 C_MAKE(evol_tree, max_r_idx, int *);
99 C_MAKE(*evol_tree, max_r_idx * (max_evolution_depth + 1), int);
100 for (i = 1; i < max_r_idx; i++)
101 evol_tree[i] = *evol_tree + i * (max_evolution_depth + 1);
103 evol_tree_zero = *evol_tree;
104 for (i = 1; i < max_r_idx; i++) {
106 if (!r_ptr->next_exp)
110 evol_tree[i][n++] = i;
112 evol_tree[i][n++] = r_ptr->next_r_idx;
113 r_ptr = &r_info[r_ptr->next_r_idx];
114 } while (r_ptr->next_exp && (n < max_evolution_depth));
117 for (i = 1; i < max_r_idx; i++) {
118 if (!evol_tree[i][0])
121 for (j = 1; j < max_r_idx; j++) {
125 if (!evol_tree[j][0])
128 if (is_partial_tree(evol_tree[j], evol_tree[i])) {
135 ang_sort(player_ptr, evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
136 for (i = 0; i < max_r_idx; i++) {
137 r_idx = evol_tree[i][0];
141 r_ptr = &r_info[r_idx];
142 fprintf(spoiler_file, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"), r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
143 for (n = 1; r_ptr->next_exp; n++) {
144 fprintf(spoiler_file, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp);
145 fprintf(spoiler_file, "[%d]: ", r_ptr->next_r_idx);
146 r_ptr = &r_info[r_ptr->next_r_idx];
147 fprintf(spoiler_file, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"), r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
150 fputc('\n', spoiler_file);
153 C_KILL(evol_tree_zero, max_r_idx * (max_evolution_depth + 1), int);
154 C_KILL(evol_tree, max_r_idx, int *);
155 if (ferror(spoiler_file) || angband_fclose(spoiler_file)) {
156 msg_print("Cannot close spoiler file.");
160 msg_print("Successfully created a spoiler file.");
164 * @brief スポイラー出力を行うコマンドのメインルーチン /
165 * Create Spoiler files -BEN-
168 void exe_output_spoilers(player_type *player_ptr)
173 prt("Create a spoiler file.", 2, 0);
174 prt("(1) Brief Object Info (obj-desc.txt)", 5, 5);
175 prt("(2) Brief Artifact Info (artifact.txt)", 6, 5);
176 prt("(3) Brief Monster Info (mon-desc.txt)", 7, 5);
177 prt("(4) Full Monster Info (mon-info.txt)", 8, 5);
178 prt("(5) Monster Evolution Info (mon-evol.txt)", 9, 5);
179 prt(_("コマンド:", "Command: "), _(18, 12), 0);
185 spoil_obj_desc(player_ptr, "obj-desc.txt");
188 spoil_fixed_artifact(player_ptr, "artifact.txt");
191 spoil_mon_desc(player_ptr, "mon-desc.txt");
194 spoil_mon_info(player_ptr, "mon-info.txt");
197 spoil_mon_evol(player_ptr, "mon-evol.txt");