2 * @file info-initializer.cpp
3 * @brief 変愚蛮怒のゲームデータ解析処理定義
6 #include "main/info-initializer.h"
7 #include "dungeon/dungeon.h"
8 #include "grid/feature.h"
9 #include "info-reader/artifact-reader.h"
10 #include "info-reader/dungeon-reader.h"
11 #include "info-reader/ego-reader.h"
12 #include "info-reader/feature-reader.h"
13 #include "info-reader/fixed-map-parser.h"
14 #include "info-reader/general-parser.h"
15 #include "info-reader/info-reader-util.h"
16 #include "info-reader/kind-reader.h"
17 #include "info-reader/magic-reader.h"
18 #include "info-reader/race-reader.h"
19 #include "info-reader/skill-reader.h"
20 #include "info-reader/vault-reader.h"
21 #include "io/files-util.h"
22 #include "io/uid-checker.h"
23 #include "main/angband-headers.h"
24 #include "main/init-error-messages-table.h"
25 #include "monster-race/monster-race.h"
26 #include "object-enchant/object-ego.h"
27 #include "object/object-kind.h"
28 #include "player-info/class-info.h"
29 #include "player/player-skill.h"
30 #include "room/rooms-vault.h"
31 #include "system/angband-version.h"
32 #include "system/artifact-type-definition.h"
33 #include "system/monster-race-definition.h"
34 #include "system/player-type-definition.h"
35 #include "util/angband-files.h"
36 #include "view/display-messages.h"
37 #include "world/world.h"
40 #include <sys/types.h>
42 #include <string_view>
45 * @brief 基本情報読み込みのメインルーチン /
46 * Initialize misc. values
47 * @param player_ptr プレイヤーへの参照ポインタ
50 errr init_misc(player_type *player_ptr)
52 return parse_fixed_map(player_ptr, "misc.txt", 0, 0, 0, 0);
57 * Initialize the header of an *_info.raw file.
58 * @param head rawファイルのヘッダ
63 static void init_header(angband_header *head, IDX num = 0)
66 head->info_num = (IDX)num;
70 * @brief 各種設定データをlib/edit/のテキストから読み込み
71 * Initialize the "*_info" array
72 * @param filename ファイル名(拡張子txt)
73 * @param head 処理に用いるヘッダ構造体
74 * @param info データ保管先の構造体ポインタ
77 * Note that we let each entry have a unique "name" and "text" string,
78 * even if the string happens to be empty (everyone has a unique '\0').
80 template <typename InfoType>
81 static errr init_info(concptr filename, angband_header &head, std::vector<InfoType> &info, std::function<errr(std::string_view, angband_header *)> parser,
82 void (*retouch)(angband_header *head))
85 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, format("%s.txt", filename));
87 FILE *fp = angband_fopen(buf, "r");
90 quit(format(_("'%s.txt'ファイルをオープンできません。", "Cannot open '%s.txt' file."), filename));
92 info = std::vector<InfoType>(head.info_num);
94 errr err = init_info_txt(fp, buf, &head, parser);
98 concptr oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : _("未知の", "unknown"));
100 msg_format("'%s.txt'ファイルの %d 行目にエラー。", filename, error_line);
102 msg_format("Error %d at line %d of '%s.txt'.", err, error_line, filename);
104 msg_format(_("レコード %d は '%s' エラーがあります。", "Record %d contains a '%s' error."), error_idx, oops);
105 msg_format(_("構文 '%s'。", "Parsing '%s'."), buf);
107 quit(format(_("'%s.txt'ファイルにエラー", "Error in '%s.txt' file."), filename));
110 info.shrink_to_fit();
111 head.info_num = static_cast<uint16_t>(info.size());
120 * @brief 地形情報読み込みのメインルーチン /
121 * Initialize the "f_info" array
126 init_header(&f_head);
127 return init_info("f_info", f_head, f_info, parse_f_info, retouch_f_info);
131 * @brief ベースアイテム情報読み込みのメインルーチン /
132 * Initialize the "k_info" array
137 init_header(&k_head);
138 return init_info("k_info", k_head, k_info, parse_k_info, nullptr);
142 * @brief 固定アーティファクト情報読み込みのメインルーチン /
143 * Initialize the "a_info" array
148 init_header(&a_head);
149 return init_info("a_info", a_head, a_info, parse_a_info, nullptr);
153 * @brief 固定アーティファクト情報読み込みのメインルーチン /
154 * Initialize the "e_info" array
159 init_header(&e_head);
160 return init_info("e_info", e_head, e_info, parse_e_info, nullptr);
164 * @brief モンスター種族情報読み込みのメインルーチン /
165 * Initialize the "r_info" array
170 init_header(&r_head);
171 return init_info("r_info", r_head, r_info, parse_r_info, nullptr);
175 * @brief ダンジョン情報読み込みのメインルーチン /
176 * Initialize the "d_info" array
181 init_header(&d_head);
182 return init_info("d_info", d_head, d_info, parse_d_info, nullptr);
186 * @brief Vault情報読み込みのメインルーチン /
187 * Initialize the "v_info" array
190 * Note that we let each entry have a unique "name" and "text" string,
191 * even if the string happens to be empty (everyone has a unique '\0').
195 init_header(&v_head);
196 return init_info("v_info", v_head, v_info, parse_v_info, nullptr);
200 * @brief 職業技能情報読み込みのメインルーチン /
201 * Initialize the "s_info" array
206 init_header(&s_head, MAX_CLASS);
207 return init_info("s_info", s_head, s_info, parse_s_info, nullptr);
211 * @brief 職業魔法情報読み込みのメインルーチン /
212 * Initialize the "m_info" array
217 init_header(&m_head, MAX_CLASS);
218 return init_info("m_info", m_head, m_info, parse_m_info, nullptr);