1 #include "info-reader/dungeon-reader.h"
2 #include "dungeon/dungeon.h"
3 #include "info-reader/dungeon-info-tokens-table.h"
4 #include "info-reader/feature-reader.h"
5 #include "info-reader/parse-error-types.h"
6 #include "info-reader/race-info-tokens-table.h"
7 #include "io/tokenizer.h"
8 #include "main/angband-headers.h"
9 #include "util/string-processor.h"
10 #include "view/display-messages.h"
13 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
14 * Grab one flag for a dungeon type from a textual string
15 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
16 * @param what 参照元の文字列ポインタ
19 static errr grab_one_dungeon_flag(dungeon_type *d_ptr, concptr what)
21 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
24 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
29 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
30 * Grab one (basic) flag in a monster_race from a textual string
31 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
32 * @param what 参照元の文字列ポインタ
35 static errr grab_one_basic_monster_flag(dungeon_type *d_ptr, concptr what)
37 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
40 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
43 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
46 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
49 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
52 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
55 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
58 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
63 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
64 * Grab one (spell) flag in a monster_race from a textual string
65 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
66 * @param what 参照元の文字列ポインタ
69 static errr grab_one_spell_monster_flag(dungeon_type *d_ptr, concptr what)
71 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
74 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
77 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
80 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
85 * @brief ダンジョン情報(d_info)のパース関数 /
86 * Initialize the "d_info" array, by parsing an ascii "template" file
91 errr parse_d_info(char *buf, angband_header *head)
93 static dungeon_type *d_ptr = NULL;
96 s = angband_strchr(buf + 2, ':');
106 int i = atoi(buf + 2);
109 if (i >= head->info_num)
115 if (!add_name(&d_ptr->name, head, s))
120 else if (buf[0] == 'E')
123 else if (buf[0] == 'E') {
124 /* Acquire the Text */
128 if (!add_name(&d_ptr->name, head, s))
132 else if (buf[0] == 'D') {
142 if (!add_text(&d_ptr->text, head, s, TRUE))
144 } else if (buf[0] == 'W') {
145 int min_lev, max_lev;
147 int min_alloc, max_chance;
148 int obj_good, obj_great;
152 != sscanf(buf + 2, "%d:%d:%d:%d:%d:%d:%d:%d:%x:%x", &min_lev, &max_lev, &min_plev, &mode, &min_alloc, &max_chance, &obj_good, &obj_great,
153 (unsigned int *)&pit, (unsigned int *)&nest))
156 d_ptr->mindepth = (DEPTH)min_lev;
157 d_ptr->maxdepth = (DEPTH)max_lev;
158 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
159 d_ptr->mode = (BIT_FLAGS8)mode;
160 d_ptr->min_m_alloc_level = min_alloc;
161 d_ptr->max_m_alloc_chance = max_chance;
162 d_ptr->obj_good = obj_good;
163 d_ptr->obj_great = obj_great;
164 d_ptr->pit = (BIT_FLAGS16)pit;
165 d_ptr->nest = (BIT_FLAGS16)nest;
166 } else if (buf[0] == 'P') {
168 if (2 != sscanf(buf + 2, "%d:%d", &dy, &dx))
173 } else if (buf[0] == 'L') {
175 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1))
178 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
179 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
180 if (d_ptr->floor[i].feat < 0)
181 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
183 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
186 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
187 } else if (buf[0] == 'A') {
189 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4))
192 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
193 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
194 if (d_ptr->fill[i].feat < 0)
195 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
197 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
200 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
201 if (d_ptr->outer_wall < 0)
202 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
204 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
205 if (d_ptr->inner_wall < 0)
206 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
208 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
209 if (d_ptr->stream1 < 0)
210 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
212 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
213 if (d_ptr->stream2 < 0)
214 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
215 } else if (buf[0] == 'F') {
216 int artif = 0, monst = 0;
218 for (s = buf + 2; *s;) {
220 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
225 while (*t == ' ' || *t == '|')
229 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif)) {
230 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
235 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif)) {
236 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
241 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst)) {
242 d_ptr->final_guardian = (MONRACE_IDX)monst;
247 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst)) {
248 d_ptr->special_div = (PROB)monst;
253 if (0 != grab_one_dungeon_flag(d_ptr, s))
258 } else if (buf[0] == 'M') {
259 for (s = buf + 2; *s;) {
261 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
266 while (*t == ' ' || *t == '|')
270 if (!strncmp(s, "R_CHAR_", 7)) {
272 strncpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
277 if (0 != grab_one_basic_monster_flag(d_ptr, s))
282 } else if (buf[0] == 'S') {
283 for (s = buf + 2; *s;) {
285 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
290 while ((*t == ' ') || (*t == '|'))
295 if (1 == sscanf(s, "1_IN_%d", &i)) {
300 if (0 != grab_one_spell_monster_flag(d_ptr, s))