OSDN Git Service

[Refactor] #38844 Continued removing inclusion of monster-race.h in angband.h
[hengband/hengband.git] / src / main / init.c
1 /*!
2  * @brief ゲームデータ初期化2 / Initialization (part 2) -BEN-
3  * @date 2014/01/28
4  * @author
5  * <pre>
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  * 2014 Deskull rearranged comment for Doxygen.\n
11  * </pre>
12  * @details
13  * <pre>
14  * This file is used to initialize various variables and arrays for the
15  * Angband game.  Note the use of "fd_read()" and "fd_write()" to bypass
16  * the common limitation of "read()" and "write()" to only 32767 bytes
17  * at a time.
18  * Several of the arrays for Angband are built from "template" files in
19  * the "lib/file" directory, from which quick-load binary "image" files
20  * are constructed whenever they are not present in the "lib/data"
21  * directory, or if those files become obsolete, if we are allowed.
22  * Warning -- the "ascii" file parsers use a minor hack to collect the
23  * name and text information in a single pass.  Thus, the game will not
24  * be able to load any template file with more than 20K of names or 60K
25  * of text, even though technically, up to 64K should be legal.
26  * The "init1.c" file is used only to parse the ascii template files,
27  * to create the binary image files.  Note that the binary image files
28  * are extremely system dependant.
29  * </pre>
30  */
31
32 #include "main/init.h"
33 #include "cmd-building/cmd-building.h"
34 #include "cmd-io/macro-util.h"
35 #include "info-reader/fixed-map-parser.h" // 相互参照、後で何とかする.
36 #include "dungeon/dungeon.h"
37 #include "dungeon/quest.h"
38 #include "floor/floor-town.h"
39 #include "floor/floor.h"
40 #include "floor/wild.h"
41 #include "game-option/option-flags.h"
42 #include "game-option/option-types-table.h"
43 #include "grid/feature.h"
44 #include "grid/trap.h"
45 #include "info-reader/artifact-reader.h"
46 #include "info-reader/dungeon-reader.h"
47 #include "info-reader/ego-reader.h"
48 #include "info-reader/feature-reader.h"
49 #include "info-reader/general-parser.h"
50 #include "info-reader/kind-reader.h"
51 #include "info-reader/magic-reader.h"
52 #include "info-reader/race-reader.h"
53 #include "info-reader/skill-reader.h"
54 #include "info-reader/parse-error-types.h"
55 #include "info-reader/vault-reader.h"
56 #include "io/files-util.h"
57 #include "io/read-pref-file.h"
58 #include "io/uid-checker.h"
59 #include "market/articles-on-sale.h"
60 #include "monster-race/monster-race.h"
61 #include "monster-race/race-flags7.h"
62 #include "object-enchant/artifact.h"
63 #include "object-enchant/object-ego.h"
64 #include "object/object-kind.h"
65 #include "player/player-class.h"
66 #include "player/player-skill.h"
67 #include "room/rooms-vault.h"
68 #include "room/rooms.h"
69 #include "store/store-util.h"
70 #include "store/store.h"
71 #include "system/alloc-entries.h"
72 #include "system/angband-version.h"
73 #include "system/building-type-definition.h"
74 #include "system/system-variables.h"
75 #include "term/gameterm.h"
76 #include "term/screen-processor.h"
77 #include "term/term-color-types.h"
78 #include "util/angband-files.h"
79 #include "util/quarks.h"
80 #include "util/tag-sorter.h"
81 #include "view/display-messages.h"
82 #include "world/world.h"
83
84 #include <sys/stat.h>
85 #include <sys/types.h>
86
87 /*!
88  * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
89  * @note Default: assume at most 256 macros are used
90  */
91 static const int MACRO_MAX = 256;
92
93 static void put_title(void);
94
95 /*!
96  * @brief 各データファイルを読み取るためのパスを取得する
97  * Find the default paths to all of our important sub-directories.
98  * @param path パス保管先の文字列
99  * @return なし
100  * @details
101  * <pre>
102  * The purpose of each sub-directory is described in "variable.c".
103  * All of the sub-directories should, by default, be located inside
104  * the main "lib" directory, whose location is very system dependant.
105  * This function takes a writable buffer, initially containing the
106  * "path" to the "lib" directory, for example, "/pkg/lib/angband/",
107  * or a system dependant string, for example, ":lib:".  The buffer
108  * must be large enough to contain at least 32 more characters.
109  * Various command line options may allow some of the important
110  * directories to be changed to user-specified directories, most
111  * importantly, the "info" and "user" and "save" directories,
112  * but this is done after this function, see "main.c".
113  * In general, the initial path should end in the appropriate "PATH_SEP"
114  * string.  All of the "sub-directory" paths (created below or supplied
115  * by the user) will NOT end in the "PATH_SEP" string, see the special
116  * "path_build()" function in "util.c" for more information.
117  * Mega-Hack -- support fat raw files under NEXTSTEP, using special
118  * "suffixed" directories for the "ANGBAND_DIR_DATA" directory, but
119  * requiring the directories to be created by hand by the user.
120  * Hack -- first we free all the strings, since this is known
121  * to succeed even if the strings have not been allocated yet,
122  * as long as the variables start out as "NULL".  This allows
123  * this function to be called multiple times, for example, to
124  * try several base "path" values until a good one is found.
125  * </pre>
126  */
127 void init_file_paths(char *path)
128 {
129         char *tail;
130
131 #ifdef PRIVATE_USER_PATH
132         char buf[1024];
133 #endif /* PRIVATE_USER_PATH */
134
135         /*** Free everything ***/
136
137         /* Free the main path */
138         string_free(ANGBAND_DIR);
139
140         /* Free the sub-paths */
141         string_free(ANGBAND_DIR_APEX);
142         string_free(ANGBAND_DIR_BONE);
143         string_free(ANGBAND_DIR_DATA);
144         string_free(ANGBAND_DIR_EDIT);
145         string_free(ANGBAND_DIR_SCRIPT);
146         string_free(ANGBAND_DIR_FILE);
147         string_free(ANGBAND_DIR_HELP);
148         string_free(ANGBAND_DIR_INFO);
149         string_free(ANGBAND_DIR_SAVE);
150         string_free(ANGBAND_DIR_USER);
151         string_free(ANGBAND_DIR_XTRA);
152
153         /*** Prepare the "path" ***/
154
155         /* Hack -- save the main directory */
156         ANGBAND_DIR = string_make(path);
157
158         /* Prepare to append to the Base Path */
159         tail = path + strlen(path);
160
161         /*** Build the sub-directory names ***/
162
163         /* Build a path name */
164         strcpy(tail, "apex");
165         ANGBAND_DIR_APEX = string_make(path);
166
167         /* Build a path name */
168         strcpy(tail, "bone");
169         ANGBAND_DIR_BONE = string_make(path);
170
171         /* Build a path name */
172         strcpy(tail, "data");
173         ANGBAND_DIR_DATA = string_make(path);
174
175         /* Build a path name */
176         strcpy(tail, "edit");
177         ANGBAND_DIR_EDIT = string_make(path);
178
179         /* Build a path name */
180         strcpy(tail, "script");
181         ANGBAND_DIR_SCRIPT = string_make(path);
182
183         /* Build a path name */
184         strcpy(tail, "file");
185         ANGBAND_DIR_FILE = string_make(path);
186
187         /* Build a path name */
188         strcpy(tail, "help");
189         ANGBAND_DIR_HELP = string_make(path);
190
191         /* Build a path name */
192         strcpy(tail, "info");
193         ANGBAND_DIR_INFO = string_make(path);
194
195         /* Build a path name */
196         strcpy(tail, "pref");
197         ANGBAND_DIR_PREF = string_make(path);
198
199         /* Build a path name */
200         strcpy(tail, "save");
201         ANGBAND_DIR_SAVE = string_make(path);
202
203 #ifdef PRIVATE_USER_PATH
204
205         /* Build the path to the user specific directory */
206         path_build(buf, sizeof(buf), PRIVATE_USER_PATH, VERSION_NAME);
207
208         /* Build a relative path name */
209         ANGBAND_DIR_USER = string_make(buf);
210
211 #else /* PRIVATE_USER_PATH */
212
213         /* Build a path name */
214         strcpy(tail, "user");
215         ANGBAND_DIR_USER = string_make(path);
216
217 #endif /* PRIVATE_USER_PATH */
218
219         /* Build a path name */
220         strcpy(tail, "xtra");
221         ANGBAND_DIR_XTRA = string_make(path);
222 }
223
224
225 /*
226  * Hack -- help give useful error messages
227  */
228 int error_idx; /*!< データ読み込み/初期化時に汎用的にエラーコードを保存するグローバル変数 */
229 int error_line; /*!< データ読み込み/初期化時に汎用的にエラー行数を保存するグローバル変数 */
230
231 /*!
232  * エラーメッセージの名称定義 / Standard error message text
233  */
234 concptr err_str[PARSE_ERROR_MAX] =
235 {
236         NULL,
237 #ifdef JP
238         "文法エラー",
239         "古いファイル",
240         "記録ヘッダがない",
241         "不連続レコード",
242         "おかしなフラグ存在",
243         "未定義命令",
244         "メモリ不足",
245         "座標範囲外",
246         "引数不足",
247         "未定義地形タグ",
248 #else
249         "parse error",
250         "obsolete file",
251         "missing record header",
252         "non-sequential records",
253         "invalid flag specification",
254         "undefined directive",
255         "out of memory",
256         "coordinates out of bounds",
257         "too few arguments",
258         "undefined terrain tag",
259 #endif
260
261 };
262
263 /*
264  * File headers
265  */
266 static angband_header v_head; /*!< Vault情報のヘッダ構造体 */
267 static angband_header k_head; /*!< ペースアイテム情報のヘッダ構造体 */
268 static angband_header a_head; /*!< 固定アーティファクト情報のヘッダ構造体 */
269 static angband_header e_head; /*!< アイテムエゴ情報のヘッダ構造体 */
270 static angband_header r_head; /*!< モンスター種族情報のヘッダ構造体 */
271 static angband_header d_head; /*!< ダンジョン情報のヘッダ構造体 */
272 static angband_header s_head; /*!< プレイヤー職業技能情報のヘッダ構造体 */
273 static angband_header m_head; /*!< プレイヤー職業魔法情報のヘッダ構造体 */
274
275 /*!
276  * @brief テキストファイルとrawファイルの更新時刻を比較する
277  * Find the default paths to all of our important sub-directories.
278  * @param fd ファイルディスクリプタ
279  * @param template_file ファイル名
280  * @return テキストの方が新しいか、rawファイルがなく更新の必要がある場合-1、更新の必要がない場合0。
281  */
282 static errr check_modification_date(int fd, concptr template_file)
283 {
284         struct stat txt_stat, raw_stat;
285         char buf[1024];
286         path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, template_file);
287
288         /* Access stats on text file */
289         if (stat(buf, &txt_stat))
290         {
291                 return 0;
292         }
293
294         /* Access stats on raw file */
295         if (fstat(fd, &raw_stat))
296         {
297                 return -1;
298         }
299
300         /* Ensure text file is not newer than raw file */
301         if (txt_stat.st_mtime > raw_stat.st_mtime)
302         {
303                 return -1;
304         }
305
306         return 0;
307 }
308
309
310 /*** Initialize from binary image files ***/
311
312 /*!
313  * @brief rawファイルからのデータの読み取り処理
314  * Initialize the "*_info" array, by parsing a binary "image" file
315  * @param fd ファイルディスクリプタ
316  * @param head rawファイルのヘッダ
317  * @return エラーコード
318  */
319 static errr init_info_raw(int fd, angband_header *head)
320 {
321         angband_header test;
322
323         /* Read and Verify the header */
324         if (fd_read(fd, (char*)(&test), sizeof(angband_header)) ||
325                 (test.v_major != head->v_major) ||
326                 (test.v_minor != head->v_minor) ||
327                 (test.v_patch != head->v_patch) ||
328                 (test.info_num != head->info_num) ||
329                 (test.info_len != head->info_len) ||
330                 (test.head_size != head->head_size) ||
331                 (test.info_size != head->info_size))
332         {
333                 /* Error */
334                 return -1;
335         }
336
337         /* Accept the header */
338         (*head) = test;
339
340         /* Allocate the "*_info" array */
341         C_MAKE(head->info_ptr, head->info_size, char);
342
343         /* Read the "*_info" array */
344         fd_read(fd, head->info_ptr, head->info_size);
345
346         if (head->name_size)
347         {
348                 /* Allocate the "*_name" array */
349                 C_MAKE(head->name_ptr, head->name_size, char);
350
351                 /* Read the "*_name" array */
352                 fd_read(fd, head->name_ptr, head->name_size);
353         }
354
355         if (head->text_size)
356         {
357                 /* Allocate the "*_text" array */
358                 C_MAKE(head->text_ptr, head->text_size, char);
359
360                 /* Read the "*_text" array */
361                 fd_read(fd, head->text_ptr, head->text_size);
362         }
363
364         if (head->tag_size)
365         {
366                 /* Allocate the "*_tag" array */
367                 C_MAKE(head->tag_ptr, head->tag_size, char);
368
369                 /* Read the "*_tag" array */
370                 fd_read(fd, head->tag_ptr, head->tag_size);
371         }
372
373         return 0;
374 }
375
376
377
378 /*!
379  * @brief ヘッダ構造体の更新
380  * Initialize the header of an *_info.raw file.
381  * @param head rawファイルのヘッダ
382  * @param num データ数
383  * @param len データの長さ
384  * @return エラーコード
385  */
386 static void init_header(angband_header *head, IDX num, int len)
387 {
388         /* Save the "version" */
389         head->v_major = FAKE_VER_MAJOR;
390         head->v_minor = FAKE_VER_MINOR;
391         head->v_patch = FAKE_VER_PATCH;
392         head->v_extra = 0;
393
394         /* Save the "record" information */
395         head->info_num = (IDX)num;
396         head->info_len = len;
397
398         /* Save the size of "*_head" and "*_info" */
399         head->head_size = sizeof(angband_header);
400         head->info_size = head->info_num * head->info_len;
401 }
402
403
404 static void update_header(angband_header *head, void **info, char **name, char **text, char **tag)
405 {
406         if (info) *info = head->info_ptr;
407         if (name) *name = head->name_ptr;
408         if (text) *text = head->text_ptr;
409         if (tag)  *tag = head->tag_ptr;
410 }
411
412
413 /*!
414  * @brief ヘッダ構造体の更新
415  * Initialize the "*_info" array
416  * @param filename ファイル名(拡張子txt/raw)
417  * @param head 処理に用いるヘッダ構造体
418  * @param info データ保管先の構造体ポインタ
419  * @param name 名称用可変文字列の保管先
420  * @param text テキスト用可変文字列の保管先
421  * @param tag タグ用可変文字列の保管先
422  * @return エラーコード
423  * @note
424  * Note that we let each entry have a unique "name" and "text" string,
425  * even if the string happens to be empty (everyone has a unique '\0').
426  */
427 static errr init_info(concptr filename, angband_header *head, void **info, char **name, char **text, char **tag)
428 {
429         /* General buffer */
430         char buf[1024];
431
432         /*** Load the binary image file ***/
433         path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
434
435         /* Attempt to open the "raw" file */
436         int fd = fd_open(buf, O_RDONLY);
437
438         /* Process existing "raw" file */
439         errr err = 1;
440         if (fd >= 0)
441         {
442                 err = check_modification_date(fd, format("%s.txt", filename));
443
444                 /* Attempt to parse the "raw" file */
445                 if (!err)
446                         err = init_info_raw(fd, head);
447                 (void)fd_close(fd);
448         }
449
450         /* Do we have to parse the *.txt file? */
451         BIT_FLAGS file_permission = 0644;
452         if (err == 0)
453         {
454                 update_header(head, info, name, text, tag);
455                 return 0;
456         }
457
458         /*** Make the fake arrays ***/
459         C_MAKE(head->info_ptr, head->info_size, char);
460
461         /* Hack -- make "fake" arrays */
462         if (name) C_MAKE(head->name_ptr, FAKE_NAME_SIZE, char);
463         if (text) C_MAKE(head->text_ptr, FAKE_TEXT_SIZE, char);
464         if (tag)  C_MAKE(head->tag_ptr, FAKE_TAG_SIZE, char);
465
466         if (info) (*info) = head->info_ptr;
467         if (name) (*name) = head->name_ptr;
468         if (text) (*text) = head->text_ptr;
469         if (tag)  (*tag) = head->tag_ptr;
470
471         /*** Load the ascii template file ***/
472         path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, format("%s.txt", filename));
473         FILE *fp;
474         fp = angband_fopen(buf, "r");
475
476         /* Parse it */
477         if (!fp) quit(format(_("'%s.txt'ファイルをオープンできません。", "Cannot open '%s.txt' file."), filename));
478
479         /* Parse the file */
480         err = init_info_txt(fp, buf, head, head->parse_info_txt);
481         angband_fclose(fp);
482
483         /* Errors */
484         if (err)
485         {
486                 concptr oops;
487
488 #ifdef JP
489                 /* Error string */
490                 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "未知の");
491
492                 msg_format("'%s.txt'ファイルの %d 行目にエラー。", filename, error_line);
493                 msg_format("レコード %d は '%s' エラーがあります。", error_idx, oops);
494                 msg_format("構文 '%s'。", buf);
495                 msg_print(NULL);
496
497                 /* Quit */
498                 quit(format("'%s.txt'ファイルにエラー", filename));
499 #else
500                 /* Error string */
501                 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
502
503                 msg_format("Error %d at line %d of '%s.txt'.", err, error_line, filename);
504                 msg_format("Record %d contains a '%s' error.", error_idx, oops);
505                 msg_format("Parsing '%s'.", buf);
506                 msg_print(NULL);
507
508                 /* Quit */
509                 quit(format("Error in '%s.txt' file.", filename));
510 #endif
511         }
512
513         /*** Make final retouch on fake tags ***/
514         if (head->retouch)
515         {
516                 (*head->retouch)(head);
517         }
518
519         /*** Dump the binary image file ***/
520         path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
521
522         /* Grab permissions */
523         safe_setuid_grab();
524
525         /* Kill the old file */
526         (void)fd_kill(buf);
527
528         /* Attempt to create the raw file */
529         fd = fd_make(buf, file_permission);
530
531         /* Drop permissions */
532         safe_setuid_drop();
533
534         /* Dump to the file */
535         if (fd >= 0)
536         {
537                 /* Dump it */
538                 fd_write(fd, (concptr)(head), head->head_size);
539
540                 /* Dump the "*_info" array */
541                 fd_write(fd, head->info_ptr, head->info_size);
542
543                 /* Dump the "*_name" array */
544                 fd_write(fd, head->name_ptr, head->name_size);
545
546                 /* Dump the "*_text" array */
547                 fd_write(fd, head->text_ptr, head->text_size);
548
549                 /* Dump the "*_tag" array */
550                 fd_write(fd, head->tag_ptr, head->tag_size);
551
552                 /* Close */
553                 (void)fd_close(fd);
554         }
555
556         /*** Kill the fake arrays ***/
557
558         /* Free the "*_info" array */
559         C_KILL(head->info_ptr, head->info_size, char);
560
561         /* Hack -- Free the "fake" arrays */
562         if (name) C_KILL(head->name_ptr, FAKE_NAME_SIZE, char);
563         if (text) C_KILL(head->text_ptr, FAKE_TEXT_SIZE, char);
564         if (tag)  C_KILL(head->tag_ptr, FAKE_TAG_SIZE, char);
565
566         /*** Load the binary image file ***/
567         path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
568
569         /* Attempt to open the "raw" file */
570         fd = fd_open(buf, O_RDONLY);
571
572         /* Process existing "raw" file */
573         if (fd < 0) quit(format(_("'%s_j.raw'ファイルをロードできません。", "Cannot load '%s.raw' file."), filename));
574
575         /* Attempt to parse the "raw" file */
576         err = init_info_raw(fd, head);
577         (void)fd_close(fd);
578
579         /* Error */
580         if (err) quit(format(_("'%s_j.raw'ファイルを解析できません。", "Cannot parse '%s.raw' file."), filename));
581
582         update_header(head, info, name, text, tag);
583         return 0;
584 }
585
586
587 /*!
588  * @brief 地形情報読み込みのメインルーチン /
589  * Initialize the "f_info" array
590  * @return エラーコード
591  */
592 static errr init_f_info(void)
593 {
594         /* Init the header */
595         init_header(&f_head, max_f_idx, sizeof(feature_type));
596
597         /* Save a pointer to the parsing function */
598         f_head.parse_info_txt = parse_f_info;
599
600         /* Save a pointer to the retouch fake tags */
601         f_head.retouch = retouch_f_info;
602
603         return init_info("f_info", &f_head,
604                 (void*)&f_info, &f_name, NULL, &f_tag);
605 }
606
607
608 /*!
609  * @brief ベースアイテム情報読み込みのメインルーチン /
610  * Initialize the "k_info" array
611  * @return エラーコード
612  */
613 static errr init_k_info(void)
614 {
615         /* Init the header */
616         init_header(&k_head, max_k_idx, sizeof(object_kind));
617
618         /* Save a pointer to the parsing function */
619         k_head.parse_info_txt = parse_k_info;
620
621         return init_info("k_info", &k_head,
622                 (void*)&k_info, &k_name, &k_text, NULL);
623 }
624
625
626 /*!
627  * @brief 固定アーティファクト情報読み込みのメインルーチン /
628  * Initialize the "a_info" array
629  * @return エラーコード
630  */
631 static errr init_a_info(void)
632 {
633         /* Init the header */
634         init_header(&a_head, max_a_idx, sizeof(artifact_type));
635
636         /* Save a pointer to the parsing function */
637         a_head.parse_info_txt = parse_a_info;
638
639         return init_info("a_info", &a_head,
640                 (void*)&a_info, &a_name, &a_text, NULL);
641 }
642
643
644 /*!
645  * @brief 固定アーティファクト情報読み込みのメインルーチン /
646  * Initialize the "e_info" array
647  * @return エラーコード
648  */
649 static errr init_e_info(void)
650 {
651         /* Init the header */
652         init_header(&e_head, max_e_idx, sizeof(ego_item_type));
653
654         /* Save a pointer to the parsing function */
655         e_head.parse_info_txt = parse_e_info;
656
657         return init_info("e_info", &e_head,
658                 (void*)&e_info, &e_name, &e_text, NULL);
659 }
660
661
662 /*!
663  * @brief モンスター種族情報読み込みのメインルーチン /
664  * Initialize the "r_info" array
665  * @return エラーコード
666  */
667 static errr init_r_info(void)
668 {
669         /* Init the header */
670         init_header(&r_head, max_r_idx, sizeof(monster_race));
671
672         /* Save a pointer to the parsing function */
673         r_head.parse_info_txt = parse_r_info;
674
675         return init_info("r_info", &r_head,
676                 (void*)&r_info, &r_name, &r_text, NULL);
677 }
678
679
680 /*!
681  * @brief ダンジョン情報読み込みのメインルーチン /
682  * Initialize the "d_info" array
683  * @return エラーコード
684  */
685 static errr init_d_info(void)
686 {
687         /* Init the header */
688         init_header(&d_head, current_world_ptr->max_d_idx, sizeof(dungeon_type));
689
690         /* Save a pointer to the parsing function */
691         d_head.parse_info_txt = parse_d_info;
692
693         return init_info("d_info", &d_head,
694                 (void*)&d_info, &d_name, &d_text, NULL);
695 }
696
697
698 /*!
699  * @brief Vault情報読み込みのメインルーチン /
700  * Initialize the "v_info" array
701  * @return エラーコード
702  * @note
703  * Note that we let each entry have a unique "name" and "text" string,
704  * even if the string happens to be empty (everyone has a unique '\0').
705  */
706 errr init_v_info(void)
707 {
708         /* Init the header */
709         init_header(&v_head, max_v_idx, sizeof(vault_type));
710
711         /* Save a pointer to the parsing function */
712         v_head.parse_info_txt = parse_v_info;
713
714         return init_info("v_info", &v_head,
715                 (void*)&v_info, &v_name, &v_text, NULL);
716 }
717
718
719 /*!
720  * @brief 職業技能情報読み込みのメインルーチン /
721  * Initialize the "s_info" array
722  * @return エラーコード
723  */
724 static errr init_s_info(void)
725 {
726         /* Init the header */
727         init_header(&s_head, MAX_CLASS, sizeof(skill_table));
728
729         /* Save a pointer to the parsing function */
730         s_head.parse_info_txt = parse_s_info;
731
732         return init_info("s_info", &s_head,
733                 (void*)&s_info, NULL, NULL, NULL);
734 }
735
736
737 /*!
738  * @brief 職業魔法情報読み込みのメインルーチン /
739  * Initialize the "m_info" array
740  * @return エラーコード
741  */
742 static errr init_m_info(void)
743 {
744         /* Init the header */
745         init_header(&m_head, MAX_CLASS, sizeof(player_magic));
746
747         /* Save a pointer to the parsing function */
748         m_head.parse_info_txt = parse_m_info;
749
750         return init_info("m_info", &m_head,
751                 (void*)&m_info, NULL, NULL, NULL);
752 }
753
754
755 /*!
756  * @brief 基本情報読み込みのメインルーチン /
757  * Initialize misc. values
758  * @param player_ptr プレーヤーへの参照ポインタ
759  * @return エラーコード
760  */
761 static errr init_misc(player_type *player_ptr)
762 {
763         return parse_fixed_map(player_ptr, "misc.txt", 0, 0, 0, 0);
764 }
765
766
767 /*!
768  * @brief 町情報読み込みのメインルーチン /
769  * Initialize town array
770  * @return エラーコード
771  */
772 static errr init_towns(void)
773 {
774         /* Allocate the towns */
775         C_MAKE(town_info, max_towns, town_type);
776
777         for (int i = 1; i < max_towns; i++)
778         {
779                 /*** Prepare the Stores ***/
780
781                 /* Allocate the stores */
782                 C_MAKE(town_info[i].store, MAX_STORES, store_type);
783
784                 /* Fill in each store */
785                 for (int j = 0; j < MAX_STORES; j++)
786                 {
787                         /* Access the store */
788                         store_type *store_ptr = &town_info[i].store[j];
789
790                         if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) continue;
791
792                         /* Assume full stock */
793
794                         /*
795                          * 我が家が 20 ページまで使える隠し機能のための準備。
796                          * オプションが有効でもそうでなくても一応スペースを作っておく。
797                          */
798                         if (j == STORE_HOME)
799                         {
800                                 store_ptr->stock_size = (STORE_INVEN_MAX * 10);
801                         }
802                         else if (j == STORE_MUSEUM)
803                         {
804                                 store_ptr->stock_size = (STORE_INVEN_MAX * 50);
805                         }
806                         else
807                         {
808                                 store_ptr->stock_size = STORE_INVEN_MAX;
809                         }
810
811                         /* Allocate the stock */
812                         C_MAKE(store_ptr->stock, store_ptr->stock_size, object_type);
813
814                         /* No table for the black market or home */
815                         if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) continue;
816
817                         /* Assume full table */
818                         store_ptr->table_size = STORE_CHOICES;
819
820                         /* Allocate the stock */
821                         C_MAKE(store_ptr->table, store_ptr->table_size, s16b);
822
823                         /* Scan the choices */
824                         for (int k = 0; k < STORE_CHOICES; k++)
825                         {
826                                 KIND_OBJECT_IDX k_idx;
827
828                                 /* Extract the tval/sval codes */
829                                 int tv = store_table[j][k][0];
830                                 int sv = store_table[j][k][1];
831
832                                 /* Look for it */
833                                 for (k_idx = 1; k_idx < max_k_idx; k_idx++)
834                                 {
835                                         object_kind *k_ptr = &k_info[k_idx];
836
837                                         /* Found a match */
838                                         if ((k_ptr->tval == tv) && (k_ptr->sval == sv)) break;
839                                 }
840
841                                 /* Catch errors */
842                                 if (k_idx == max_k_idx) continue;
843
844                                 /* Add that item index to the table */
845                                 store_ptr->table[store_ptr->table_num++] = k_idx;
846                         }
847                 }
848         }
849
850         return 0;
851 }
852
853 /*!
854  * @brief 店情報初期化のメインルーチン /
855  * Initialize buildings
856  * @return エラーコード
857  */
858 errr init_buildings(void)
859 {
860         for (int i = 0; i < MAX_BLDG; i++)
861         {
862                 building[i].name[0] = '\0';
863                 building[i].owner_name[0] = '\0';
864                 building[i].owner_race[0] = '\0';
865
866                 for (int j = 0; j < 8; j++)
867                 {
868                         building[i].act_names[j][0] = '\0';
869                         building[i].member_costs[j] = 0;
870                         building[i].other_costs[j] = 0;
871                         building[i].letters[j] = 0;
872                         building[i].actions[j] = 0;
873                         building[i].action_restr[j] = 0;
874                 }
875
876                 for (int j = 0; j < MAX_CLASS; j++)
877                 {
878                         building[i].member_class[j] = 0;
879                 }
880
881                 for (int j = 0; j < MAX_RACES; j++)
882                 {
883                         building[i].member_race[j] = 0;
884                 }
885
886                 for (int j = 0; j < MAX_MAGIC + 1; j++)
887                 {
888                         building[i].member_realm[j] = 0;
889                 }
890         }
891
892         return 0;
893 }
894
895
896 /*!
897  * @brief クエスト情報初期化のメインルーチン /
898  * Initialize quest array
899  * @return エラーコード
900  */
901 static errr init_quests(void)
902 {
903         /* Allocate the quests */
904         C_MAKE(quest, max_q_idx, quest_type);
905
906         /* Set all quest to "untaken" */
907         for (int i = 0; i < max_q_idx; i++)
908         {
909                 quest[i].status = QUEST_STATUS_UNTAKEN;
910         }
911
912         return 0;
913 }
914
915 /*!
916  * @brief その他の初期情報更新 /
917  * Initialize some other arrays
918  * @return エラーコード
919  */
920 static errr init_other(player_type *player_ptr)
921 {
922         player_ptr->current_floor_ptr = &floor_info; // TODO:本当はこんなところで初期化したくない
923         floor_type *floor_ptr = player_ptr->current_floor_ptr;
924
925         /*** Prepare the "dungeon" information ***/
926
927         /* Allocate and Wipe the object list */
928         C_MAKE(floor_ptr->o_list, current_world_ptr->max_o_idx, object_type);
929
930         /* Allocate and Wipe the monster list */
931         C_MAKE(floor_ptr->m_list, current_world_ptr->max_m_idx, monster_type);
932
933         /* Allocate and Wipe the monster process list */
934         for (int i = 0; i < MAX_MTIMED; i++)
935         {
936                 C_MAKE(floor_ptr->mproc_list[i], current_world_ptr->max_m_idx, s16b);
937         }
938
939         /* Allocate and Wipe the max dungeon level */
940         C_MAKE(max_dlv, current_world_ptr->max_d_idx, DEPTH);
941
942         for (int i = 0; i < MAX_HGT; i++)
943         {
944                 C_MAKE(floor_ptr->grid_array[i], MAX_WID, grid_type);
945         }
946
947         /*** Prepare the various "bizarre" arrays ***/
948
949         /* Macro variables */
950         C_MAKE(macro__pat, MACRO_MAX, concptr);
951         C_MAKE(macro__act, MACRO_MAX, concptr);
952         C_MAKE(macro__cmd, MACRO_MAX, bool);
953
954         /* Macro action buffer */
955         C_MAKE(macro__buf, 1024, char);
956
957         /* Quark variables */
958         quark_init();
959
960         /* Message variables */
961         C_MAKE(message__ptr, MESSAGE_MAX, u32b);
962         C_MAKE(message__buf, MESSAGE_BUF, char);
963
964         /* Hack -- No messages yet */
965         message__tail = MESSAGE_BUF;
966
967         /*** Prepare the options ***/
968
969         /* Scan the options */
970         for (int i = 0; option_info[i].o_desc; i++)
971         {
972                 int os = option_info[i].o_set;
973                 int ob = option_info[i].o_bit;
974
975                 /* Set the "default" options */
976                 if (!option_info[i].o_var) continue;
977
978                 /* Accept */
979                 option_mask[os] |= (1L << ob);
980
981                 /* Set */
982                 if (option_info[i].o_norm)
983                 {
984                         /* Set */
985                         option_flag[os] |= (1L << ob);
986                 }
987                 else
988                 {
989                         option_flag[os] &= ~(1L << ob);
990                 }
991         }
992
993         /* Analyze the windows */
994         for (int n = 0; n < 8; n++)
995         {
996                 /* Analyze the options */
997                 for (int i = 0; i < 32; i++)
998                 {
999                         /* Accept */
1000                         if (window_flag_desc[i])
1001                         {
1002                                 /* Accept */
1003                                 window_mask[n] |= (1L << i);
1004                         }
1005                 }
1006         }
1007
1008         /*
1009          *  Set the "default" window flags
1010          *  Window 1 : Display messages
1011          *  Window 2 : Display inven/equip
1012          */
1013         window_flag[1] = 1L << A_MAX;
1014         window_flag[2] = 1L << 0;
1015
1016         /*** Pre-allocate space for the "format()" buffer ***/
1017
1018         /* Hack -- Just call the "format()" function */
1019         (void)format("%s (%s).", "Mr.Hoge", MAINTAINER);
1020         return 0;
1021 }
1022
1023
1024 /*!
1025  * @brief オブジェクト配列を初期化する /
1026  * Initialize some other arrays
1027  * @return エラーコード
1028  */
1029 static errr init_object_alloc(void)
1030 {
1031         s16b aux[MAX_DEPTH];
1032         (void)C_WIPE(&aux, MAX_DEPTH, s16b);
1033
1034         s16b num[MAX_DEPTH];
1035         (void)C_WIPE(&num, MAX_DEPTH, s16b);
1036
1037         /* Free the old "alloc_kind_table" (if it exists) */
1038         if (alloc_kind_table)
1039         {
1040                 C_KILL(alloc_kind_table, alloc_kind_size, alloc_entry);
1041         }
1042
1043         /* Size of "alloc_kind_table" */
1044         alloc_kind_size = 0;
1045
1046         /* Scan the objects */
1047         for (int i = 1; i < max_k_idx; i++)
1048         {
1049                 object_kind *k_ptr;
1050                 k_ptr = &k_info[i];
1051
1052                 /* Scan allocation pairs */
1053                 for (int j = 0; j < 4; j++)
1054                 {
1055                         /* Count the "legal" entries */
1056                         if (k_ptr->chance[j])
1057                         {
1058                                 /* Count the entries */
1059                                 alloc_kind_size++;
1060
1061                                 /* Group by level */
1062                                 num[k_ptr->locale[j]]++;
1063                         }
1064                 }
1065         }
1066
1067         /* Collect the level indexes */
1068         for (int i = 1; i < MAX_DEPTH; i++)
1069         {
1070                 /* Group by level */
1071                 num[i] += num[i - 1];
1072         }
1073
1074         if (!num[0]) quit(_("町のアイテムがない!", "No town objects!"));
1075
1076         /*** Initialize object allocation info ***/
1077
1078         /* Allocate the alloc_kind_table */
1079         C_MAKE(alloc_kind_table, alloc_kind_size, alloc_entry);
1080
1081         /* Access the table entry */
1082         alloc_entry *table;
1083         table = alloc_kind_table;
1084
1085         /* Scan the objects */
1086         for (int i = 1; i < max_k_idx; i++)
1087         {
1088                 object_kind *k_ptr;
1089                 k_ptr = &k_info[i];
1090
1091                 /* Scan allocation pairs */
1092                 for (int j = 0; j < 4; j++)
1093                 {
1094                         /* Count the "legal" entries */
1095                         if (k_ptr->chance[j] == 0) continue;
1096
1097                         /* Extract the base level */
1098                         int x = k_ptr->locale[j];
1099
1100                         /* Extract the base probability */
1101                         int p = (100 / k_ptr->chance[j]);
1102
1103                         /* Skip entries preceding our locale */
1104                         int y = (x > 0) ? num[x - 1] : 0;
1105
1106                         /* Skip previous entries at this locale */
1107                         int z = y + aux[x];
1108
1109                         /* Load the entry */
1110                         table[z].index = (KIND_OBJECT_IDX)i;
1111                         table[z].level = (DEPTH)x;
1112                         table[z].prob1 = (PROB)p;
1113                         table[z].prob2 = (PROB)p;
1114                         table[z].prob3 = (PROB)p;
1115
1116                         /* Another entry complete for this locale */
1117                         aux[x]++;
1118                 }
1119         }
1120
1121         return 0;
1122 }
1123
1124
1125 /*!
1126  * @brief モンスター配列と生成テーブルを初期化する /
1127  * Initialize some other arrays
1128  * @return エラーコード
1129  */
1130 static errr init_alloc(void)
1131 {
1132         monster_race *r_ptr;
1133         tag_type *elements;
1134
1135         /* Allocate the "r_info" array */
1136         C_MAKE(elements, max_r_idx, tag_type);
1137
1138         /* Scan the monsters */
1139         for (int i = 1; i < max_r_idx; i++)
1140         {
1141                 elements[i].tag = r_info[i].level;
1142                 elements[i].index = i;
1143         }
1144
1145         tag_sort(elements, max_r_idx);
1146
1147         /*** Initialize monster allocation info ***/
1148
1149         /* Size of "alloc_race_table" */
1150         alloc_race_size = max_r_idx;
1151
1152         /* Allocate the alloc_race_table */
1153         C_MAKE(alloc_race_table, alloc_race_size, alloc_entry);
1154
1155         /* Scan the monsters */
1156         for (int i = 1; i < max_r_idx; i++)
1157         {
1158                 /* Get the i'th race */
1159                 r_ptr = &r_info[elements[i].index];
1160
1161                 /* Count valid pairs */
1162                 if (r_ptr->rarity == 0) continue;
1163
1164                 /* Extract the base level */
1165                 int x = r_ptr->level;
1166
1167                 /* Extract the base probability */
1168                 int p = (100 / r_ptr->rarity);
1169
1170                 /* Load the entry */
1171                 alloc_race_table[i].index = (KIND_OBJECT_IDX)elements[i].index;
1172                 alloc_race_table[i].level = (DEPTH)x;
1173                 alloc_race_table[i].prob1 = (PROB)p;
1174                 alloc_race_table[i].prob2 = (PROB)p;
1175                 alloc_race_table[i].prob3 = (PROB)p;
1176         }
1177
1178         /* Free the "r_info" array */
1179         C_KILL(elements, max_r_idx, tag_type);
1180         (void)init_object_alloc();
1181         return 0;
1182 }
1183
1184
1185 /*!
1186  * @brief 画面左下にシステムメッセージを表示する /
1187  * Hack -- take notes on line 23
1188  * @return なし
1189  */
1190 static void note(concptr str)
1191 {
1192         Term_erase(0, 23, 255);
1193         Term_putstr(20, 23, -1, TERM_WHITE, str);
1194         Term_fresh();
1195 }
1196
1197
1198 /*!
1199  * @brief 全ゲームデータ読み込みのサブルーチン /
1200  * Hack -- Explain a broken "lib" folder and quit (see below).
1201  * @return なし
1202  * @note
1203  * <pre>
1204  * This function is "messy" because various things
1205  * may or may not be initialized, but the "plog()" and "quit()"
1206  * functions are "supposed" to work under any conditions.
1207  * </pre>
1208  */
1209 static void init_angband_aux(concptr why)
1210 {
1211         plog(why);
1212
1213 #ifdef JP
1214         /* Explain */
1215         plog("'lib'ディレクトリが存在しないか壊れているようです。");
1216
1217         /* More details */
1218         plog("ひょっとするとアーカイブが正しく解凍されていないのかもしれません。");
1219
1220         /* Explain */
1221         plog("該当する'README'ファイルを読んで確認してみて下さい。");
1222
1223         /* Quit with error */
1224         quit("致命的なエラー。");
1225 #else
1226         /* Explain */
1227         plog("The 'lib' directory is probably missing or broken.");
1228
1229         /* More details */
1230         plog("Perhaps the archive was not extracted correctly.");
1231
1232         /* Explain */
1233         plog("See the 'README' file for more information.");
1234
1235         /* Quit with error */
1236         quit("Fatal Error.");
1237 #endif
1238
1239 }
1240
1241
1242 /*!
1243  * @brief 全ゲームデータ読み込みのメインルーチン /
1244  * Hack -- main Angband initialization entry point
1245  * @return なし
1246  * @note
1247  * <pre>
1248  * This function is "messy" because various things
1249  * may or may not be initialized, but the "plog()" and "quit()"
1250  * functions are "supposed" to work under any conditions.
1251  * Verify some files, display the "news.txt" file, create
1252  * the high score file, initialize all internal arrays, and
1253  * load the basic "user pref files".
1254  * Be very careful to keep track of the order in which things
1255  * are initialized, in particular, the only thing *known* to
1256  * be available when this function is called is the "z-term.c"
1257  * package, and that may not be fully initialized until the
1258  * end of this function, when the default "user pref files"
1259  * are loaded and "Term_xtra(TERM_XTRA_REACT,0)" is called.
1260  * Note that this function attempts to verify the "news" file,
1261  * and the game aborts (cleanly) on failure, since without the
1262  * "news" file, it is likely that the "lib" folder has not been
1263  * correctly located.  Otherwise, the news file is displayed for
1264  * the user.
1265  * Note that this function attempts to verify (or create) the
1266  * "high score" file, and the game aborts (cleanly) on failure,
1267  * since one of the most common "extraction" failures involves
1268  * failing to extract all sub-directories (even empty ones), such
1269  * as by failing to use the "-d" option of "pkunzip", or failing
1270  * to use the "save empty directories" option with "Compact Pro".
1271  * This error will often be caught by the "high score" creation
1272  * code below, since the "lib/apex" directory, being empty in the
1273  * standard distributions, is most likely to be "lost", making it
1274  * impossible to create the high score file.
1275  * Note that various things are initialized by this function,
1276  * including everything that was once done by "init_some_arrays".
1277  * This initialization involves the parsing of special files
1278  * in the "lib/data" and sometimes the "lib/edit" directories.
1279  * Note that the "template" files are initialized first, since they
1280  * often contain errors.  This means that macros and message recall
1281  * and things like that are not available until after they are done.
1282  * We load the default "user pref files" here in case any "color"
1283  * changes are needed before character creation.
1284  * Note that the "graf-xxx.prf" file must be loaded separately,
1285  * if needed, in the first (?) pass through "TERM_XTRA_REACT".
1286  * </pre>
1287  */
1288 void init_angband(player_type *player_ptr, void(*process_autopick_file_command)(char*))
1289 {
1290         /*** Verify the "news" file ***/
1291         char buf[1024];
1292         path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
1293
1294         /* Attempt to open the file */
1295         int fd = fd_open(buf, O_RDONLY);
1296
1297         /* Failure */
1298         if (fd < 0)
1299         {
1300                 char why[1024];
1301
1302                 sprintf(why, _("'%s'ファイルにアクセスできません!", "Cannot access the '%s' file!"), buf);
1303
1304                 /* Crash and burn */
1305                 init_angband_aux(why);
1306         }
1307
1308         (void)fd_close(fd);
1309
1310         /*** Display the "news" file ***/
1311         Term_clear();
1312         path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
1313
1314         /* Open the News file */
1315         FILE *fp;
1316         fp = angband_fopen(buf, "r");
1317
1318         /* Dump */
1319         if (fp)
1320         {
1321                 /* Dump the file to the screen */
1322                 int i = 0;
1323                 while (0 == angband_fgets(fp, buf, sizeof(buf)))
1324                 {
1325                         /* Display and advance */
1326                         Term_putstr(0, i++, -1, TERM_WHITE, buf);
1327                 }
1328
1329                 angband_fclose(fp);
1330         }
1331
1332         Term_flush();
1333
1334         /*** Verify (or create) the "high score" file ***/
1335         path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
1336
1337         /* Attempt to open the high score file */
1338         fd = fd_open(buf, O_RDONLY);
1339
1340         BIT_FLAGS file_permission = 0664;
1341         if (fd < 0)
1342         {
1343                 /* Grab permissions */
1344                 safe_setuid_grab();
1345
1346                 /* Create a new high score file */
1347                 fd = fd_make(buf, file_permission);
1348
1349                 /* Drop permissions */
1350                 safe_setuid_drop();
1351
1352                 /* Failure */
1353                 if (fd < 0)
1354                 {
1355                         char why[1024];
1356
1357                         sprintf(why, _("'%s'ファイルを作成できません!", "Cannot create the '%s' file!"), buf);
1358
1359                         /* Crash and burn */
1360                         init_angband_aux(why);
1361                 }
1362         }
1363
1364         (void)fd_close(fd);
1365
1366         put_title();
1367
1368         /*** Initialize some arrays ***/
1369
1370         /* Initialize misc. values */
1371         note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]"));
1372         if (init_misc(player_ptr)) quit(_("その他の変数を初期化できません", "Cannot initialize misc. values"));
1373
1374         /* Initialize feature info */
1375 #ifdef JP
1376         note("[データの初期化中... (地形)]");
1377         if (init_f_info()) quit("地形初期化不能");
1378         if (init_feat_variables()) quit("地形初期化不能");
1379 #else
1380         note("[Initializing arrays... (features)]");
1381         if (init_f_info()) quit("Cannot initialize features");
1382         if (init_feat_variables()) quit("Cannot initialize features");
1383 #endif
1384
1385         /* Initialize object info */
1386         note(_("[データの初期化中... (アイテム)]", "[Initializing arrays... (objects)]"));
1387         if (init_k_info()) quit(_("アイテム初期化不能", "Cannot initialize objects"));
1388
1389         /* Initialize artifact info */
1390         note(_("[データの初期化中... (伝説のアイテム)]", "[Initializing arrays... (artifacts)]"));
1391         if (init_a_info()) quit(_("伝説のアイテム初期化不能", "Cannot initialize artifacts"));
1392
1393
1394         /* Initialize ego-item info */
1395         note(_("[データの初期化中... (名のあるアイテム)]", "[Initializing arrays... (ego-items)]"));
1396         if (init_e_info()) quit(_("名のあるアイテム初期化不能", "Cannot initialize ego-items"));
1397
1398
1399         /* Initialize monster info */
1400         note(_("[データの初期化中... (モンスター)]", "[Initializing arrays... (monsters)]"));
1401         if (init_r_info()) quit(_("モンスター初期化不能", "Cannot initialize monsters"));
1402
1403
1404         /* Initialize dungeon info */
1405         note(_("[データの初期化中... (ダンジョン)]", "[Initializing arrays... (dungeon)]"));
1406         if (init_d_info()) quit(_("ダンジョン初期化不能", "Cannot initialize dungeon"));
1407         {
1408                 for (int i = 1; i < current_world_ptr->max_d_idx; i++)
1409                         if (d_info[i].final_guardian)
1410                                 r_info[d_info[i].final_guardian].flags7 |= RF7_GUARDIAN;
1411         }
1412
1413         /* Initialize magic info */
1414         note(_("[データの初期化中... (魔法)]", "[Initializing arrays... (magic)]"));
1415         if (init_m_info()) quit(_("魔法初期化不能", "Cannot initialize magic"));
1416
1417         /* Initialize weapon_exp info */
1418         note(_("[データの初期化中... (熟練度)]", "[Initializing arrays... (skill)]"));
1419         if (init_s_info()) quit(_("熟練度初期化不能", "Cannot initialize skill"));
1420
1421         /* Initialize wilderness array */
1422         note(_("[配列を初期化しています... (荒野)]", "[Initializing arrays... (wilderness)]"));
1423
1424         if (init_wilderness()) quit(_("荒野を初期化できません", "Cannot initialize wilderness"));
1425
1426         /* Initialize town array */
1427         note(_("[配列を初期化しています... (街)]", "[Initializing arrays... (towns)]"));
1428         if (init_towns()) quit(_("街を初期化できません", "Cannot initialize towns"));
1429
1430         /* Initialize building array */
1431         note(_("[配列を初期化しています... (建物)]", "[Initializing arrays... (buildings)]"));
1432         if (init_buildings()) quit(_("建物を初期化できません", "Cannot initialize buildings"));
1433
1434         /* Initialize quest array */
1435         note(_("[配列を初期化しています... (クエスト)]", "[Initializing arrays... (quests)]"));
1436         if (init_quests()) quit(_("クエストを初期化できません", "Cannot initialize quests"));
1437
1438         /* Initialize vault info */
1439         if (init_v_info()) quit(_("vault 初期化不能", "Cannot initialize vaults"));
1440
1441         /* Initialize some other arrays */
1442         note(_("[データの初期化中... (その他)]", "[Initializing arrays... (other)]"));
1443         if (init_other(player_ptr)) quit(_("その他のデータ初期化不能", "Cannot initialize other stuff"));
1444
1445         /* Initialize some other arrays */
1446         note(_("[データの初期化中... (アロケーション)]", "[Initializing arrays... (alloc)]"));
1447         if (init_alloc()) quit(_("アロケーション・スタッフ初期化不能", "Cannot initialize alloc stuff"));
1448
1449         /*** Load default user pref files ***/
1450
1451         /* Initialize feature info */
1452         note(_("[ユーザー設定ファイルを初期化しています...]", "[Initializing user pref files...]"));
1453
1454         /* Access the "basic" pref file */
1455         strcpy(buf, "pref.prf");
1456
1457         /* Process that file */
1458         process_pref_file(player_ptr, buf, process_autopick_file_command);
1459
1460         /* Access the "basic" system pref file */
1461         sprintf(buf, "pref-%s.prf", ANGBAND_SYS);
1462
1463         /* Process that file */
1464         process_pref_file(player_ptr, buf, process_autopick_file_command);
1465
1466         note(_("[初期化終了]", "[Initialization complete]"));
1467 }
1468
1469
1470 /*!
1471  * @brief タイトル記述
1472  * @return なし
1473  */
1474 static void put_title(void)
1475 {
1476         char title[120];
1477 #if H_VER_EXTRA > 0
1478         sprintf(title, _("変愚蛮怒 %d.%d.%d.%d(%s)", "Hengband %d.%d.%d.%d(%s)"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH, H_VER_EXTRA,
1479 #else
1480         sprintf(title, _("変愚蛮怒 %d.%d.%d(%s)", "Hengband %d.%d.%d(%s)"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH,
1481 #endif
1482                 IS_STABLE_VERSION ? _("安定版", "Stable") : _("開発版", "Developing"));
1483         int col = (80 - strlen(title)) / 2;
1484         col = col < 0 ? 0 : col;
1485     const int VER_INFO_ROW = 3; //!< タイトル表記(行)
1486         prt(title, VER_INFO_ROW, col);
1487 }
1488
1489
1490 /*!
1491  * @brief チェックサム情報を出力 / Get check sum in string form
1492  * @return チェックサム情報の文字列
1493  */
1494 concptr get_check_sum(void)
1495 {
1496         return format("%02x%02x%02x%02x%02x%02x%02x%02x%02x",
1497                 f_head.v_extra,
1498                 k_head.v_extra,
1499                 a_head.v_extra,
1500                 e_head.v_extra,
1501                 r_head.v_extra,
1502                 d_head.v_extra,
1503                 m_head.v_extra,
1504                 s_head.v_extra,
1505                 v_head.v_extra);
1506 }