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"
14 * @brief テキストトークンを走査してフラグを一つ得る(ダンジョン用) /
15 * Grab one flag for a dungeon type from a textual string
16 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
17 * @param what 参照元の文字列ポインタ
20 static errr grab_one_dungeon_flag(dungeon_type *d_ptr, concptr what)
22 if (grab_one_flag(&d_ptr->flags1, d_info_flags1, what) == 0)
25 msg_format(_("未知のダンジョン・フラグ '%s'。", "Unknown dungeon type flag '%s'."), what);
30 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用1) /
31 * Grab one (basic) flag in a monster_race from a textual string
32 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
33 * @param what 参照元の文字列ポインタ
36 static errr grab_one_basic_monster_flag(dungeon_type *d_ptr, concptr what)
38 if (grab_one_flag(&d_ptr->mflags1, r_info_flags1, what) == 0)
41 if (grab_one_flag(&d_ptr->mflags2, r_info_flags2, what) == 0)
44 if (grab_one_flag(&d_ptr->mflags3, r_info_flags3, what) == 0)
47 if (grab_one_flag(&d_ptr->mflags7, r_info_flags7, what) == 0)
50 if (grab_one_flag(&d_ptr->mflags8, r_info_flags8, what) == 0)
53 if (grab_one_flag(&d_ptr->mflags9, r_info_flags9, what) == 0)
56 if (grab_one_flag(&d_ptr->mflagsr, r_info_flagsr, what) == 0)
59 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
64 * @brief テキストトークンを走査してフラグを一つ得る(モンスターのダンジョン出現条件用2) /
65 * Grab one (spell) flag in a monster_race from a textual string
66 * @param d_ptr 保管先のダンジョン構造体参照ポインタ
67 * @param what 参照元の文字列ポインタ
70 static errr grab_one_spell_monster_flag(dungeon_type *d_ptr, concptr what)
72 if (grab_one_flag(&d_ptr->mflags4, r_info_flags4, what) == 0)
75 if (grab_one_flag(&d_ptr->m_a_ability_flags1, r_a_ability_flags1, what) == 0)
78 if (grab_one_flag(&d_ptr->m_a_ability_flags2, r_a_ability_flags2, what) == 0)
81 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
86 * @brief ダンジョン情報(d_info)のパース関数 /
87 * Initialize the "d_info" array, by parsing an ascii "template" file
92 errr parse_d_info(char *buf, angband_header *head)
94 static dungeon_type *d_ptr = NULL;
97 s = angband_strchr(buf + 2, ':');
107 int i = atoi(buf + 2);
110 if (i >= head->info_num)
116 d_ptr->name = std::string(s);
120 else if (buf[0] == 'E')
123 else if (buf[0] == 'E') {
124 /* Acquire the Text */
128 d_ptr->name = std::string(s);
131 else if (buf[0] == 'D') {
141 d_ptr->text.append(s);
142 } else if (buf[0] == 'W') {
143 int min_lev, max_lev;
145 int min_alloc, max_chance;
146 int obj_good, obj_great;
150 != 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,
151 (unsigned int *)&pit, (unsigned int *)&nest))
154 d_ptr->mindepth = (DEPTH)min_lev;
155 d_ptr->maxdepth = (DEPTH)max_lev;
156 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
157 d_ptr->mode = (BIT_FLAGS8)mode;
158 d_ptr->min_m_alloc_level = min_alloc;
159 d_ptr->max_m_alloc_chance = max_chance;
160 d_ptr->obj_good = obj_good;
161 d_ptr->obj_great = obj_great;
162 d_ptr->pit = (BIT_FLAGS16)pit;
163 d_ptr->nest = (BIT_FLAGS16)nest;
164 } else if (buf[0] == 'P') {
166 if (2 != sscanf(buf + 2, "%d:%d", &dy, &dx))
171 } else if (buf[0] == 'L') {
173 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1))
176 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
177 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
178 if (d_ptr->floor[i].feat < 0)
179 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
181 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
184 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
185 } else if (buf[0] == 'A') {
187 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4))
190 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
191 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
192 if (d_ptr->fill[i].feat < 0)
193 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
195 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
198 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
199 if (d_ptr->outer_wall < 0)
200 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
202 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
203 if (d_ptr->inner_wall < 0)
204 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
206 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
207 if (d_ptr->stream1 < 0)
208 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
210 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
211 if (d_ptr->stream2 < 0)
212 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
213 } else if (buf[0] == 'F') {
214 int artif = 0, monst = 0;
216 for (s = buf + 2; *s;) {
218 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
223 while (*t == ' ' || *t == '|')
227 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif)) {
228 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
233 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif)) {
234 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
239 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst)) {
240 d_ptr->final_guardian = (MONRACE_IDX)monst;
245 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst)) {
246 d_ptr->special_div = (PROB)monst;
251 if (0 != grab_one_dungeon_flag(d_ptr, s))
256 } else if (buf[0] == 'M') {
257 for (s = buf + 2; *s;) {
259 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
264 while (*t == ' ' || *t == '|')
268 if (!strncmp(s, "R_CHAR_", 7)) {
270 angband_strcpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
275 if (0 != grab_one_basic_monster_flag(d_ptr, s))
280 } else if (buf[0] == 'S') {
281 for (s = buf + 2; *s;) {
283 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
288 while ((*t == ' ') || (*t == '|'))
293 if (1 == sscanf(s, "1_IN_%d", &i)) {
298 if (0 != grab_one_spell_monster_flag(d_ptr, s))