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 (FlagGroup<RF_ABILITY>::grab_one_flag(d_ptr->m_ability_flags, r_info_ability_flags, what))
75 msg_format(_("未知のモンスター・フラグ '%s'。", "Unknown monster flag '%s'."), what);
80 * @brief ダンジョン情報(d_info)のパース関数 /
81 * Initialize the "d_info" array, by parsing an ascii "template" file
86 errr parse_d_info(char *buf, angband_header *head)
88 static dungeon_type *d_ptr = NULL;
91 s = angband_strchr(buf + 2, ':');
101 int i = atoi(buf + 2);
104 if (i >= head->info_num)
110 d_ptr->name = std::string(s);
114 else if (buf[0] == 'E')
117 else if (buf[0] == 'E') {
118 /* Acquire the Text */
122 d_ptr->name = std::string(s);
125 else if (buf[0] == 'D') {
135 d_ptr->text.append(s);
136 } else if (buf[0] == 'W') {
137 int min_lev, max_lev;
139 int min_alloc, max_chance;
140 int obj_good, obj_great;
144 != 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,
145 (unsigned int *)&pit, (unsigned int *)&nest))
148 d_ptr->mindepth = (DEPTH)min_lev;
149 d_ptr->maxdepth = (DEPTH)max_lev;
150 d_ptr->min_plev = (PLAYER_LEVEL)min_plev;
151 d_ptr->mode = (BIT_FLAGS8)mode;
152 d_ptr->min_m_alloc_level = min_alloc;
153 d_ptr->max_m_alloc_chance = max_chance;
154 d_ptr->obj_good = obj_good;
155 d_ptr->obj_great = obj_great;
156 d_ptr->pit = (BIT_FLAGS16)pit;
157 d_ptr->nest = (BIT_FLAGS16)nest;
158 } else if (buf[0] == 'P') {
160 if (2 != sscanf(buf + 2, "%d:%d", &dy, &dx))
165 } else if (buf[0] == 'L') {
167 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 1, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 1))
170 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
171 d_ptr->floor[i].feat = f_tag_to_index(zz[i * 2]);
172 if (d_ptr->floor[i].feat < 0)
173 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
175 d_ptr->floor[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
178 d_ptr->tunnel_percent = atoi(zz[DUNGEON_FEAT_PROB_NUM * 2]);
179 } else if (buf[0] == 'A') {
181 if (tokenize(buf + 2, DUNGEON_FEAT_PROB_NUM * 2 + 4, zz, 0) != (DUNGEON_FEAT_PROB_NUM * 2 + 4))
184 for (int i = 0; i < DUNGEON_FEAT_PROB_NUM; i++) {
185 d_ptr->fill[i].feat = f_tag_to_index(zz[i * 2]);
186 if (d_ptr->fill[i].feat < 0)
187 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
189 d_ptr->fill[i].percent = (PERCENTAGE)atoi(zz[i * 2 + 1]);
192 d_ptr->outer_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2]);
193 if (d_ptr->outer_wall < 0)
194 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
196 d_ptr->inner_wall = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 1]);
197 if (d_ptr->inner_wall < 0)
198 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
200 d_ptr->stream1 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 2]);
201 if (d_ptr->stream1 < 0)
202 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
204 d_ptr->stream2 = f_tag_to_index(zz[DUNGEON_FEAT_PROB_NUM * 2 + 3]);
205 if (d_ptr->stream2 < 0)
206 return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
207 } else if (buf[0] == 'F') {
208 int artif = 0, monst = 0;
210 for (s = buf + 2; *s;) {
212 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
217 while (*t == ' ' || *t == '|')
221 if (1 == sscanf(s, "FINAL_ARTIFACT_%d", &artif)) {
222 d_ptr->final_artifact = (ARTIFACT_IDX)artif;
227 if (1 == sscanf(s, "FINAL_OBJECT_%d", &artif)) {
228 d_ptr->final_object = (KIND_OBJECT_IDX)artif;
233 if (1 == sscanf(s, "FINAL_GUARDIAN_%d", &monst)) {
234 d_ptr->final_guardian = (MONRACE_IDX)monst;
239 if (1 == sscanf(s, "MONSTER_DIV_%d", &monst)) {
240 d_ptr->special_div = (PROB)monst;
245 if (0 != grab_one_dungeon_flag(d_ptr, s))
250 } else if (buf[0] == 'M') {
251 for (s = buf + 2; *s;) {
253 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
258 while (*t == ' ' || *t == '|')
262 if (!strncmp(s, "R_CHAR_", 7)) {
264 angband_strcpy(d_ptr->r_char, s, sizeof(d_ptr->r_char));
269 if (0 != grab_one_basic_monster_flag(d_ptr, s))
274 } else if (buf[0] == 'S') {
275 for (s = buf + 2; *s;) {
277 for (t = s; *t && (*t != ' ') && (*t != '|'); ++t)
282 while ((*t == ' ') || (*t == '|'))
287 if (1 == sscanf(s, "1_IN_%d", &i)) {
292 if (0 != grab_one_spell_monster_flag(d_ptr, s))