3 * @brief ゲームデータ初期化2 / Initialization (part 2) -BEN-
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
11 * 2014 Deskull rearranged comment for Doxygen.\n
15 * This file is used to initialize various variables and arrays for the
16 * Angband game. Note the use of "fd_read()" and "fd_write()" to bypass
17 * the common limitation of "read()" and "write()" to only 32767 bytes
19 * Several of the arrays for Angband are built from "template" files in
20 * the "lib/file" directory, from which quick-load binary "image" files
21 * are constructed whenever they are not present in the "lib/data"
22 * directory, or if those files become obsolete, if we are allowed.
23 * Warning -- the "ascii" file parsers use a minor hack to collect the
24 * name and text information in a single pass. Thus, the game will not
25 * be able to load any template file with more than 20K of names or 60K
26 * of text, even though technically, up to 64K should be legal.
27 * The "init1.c" file is used only to parse the ascii template files,
28 * to create the binary image files. If you include the binary image
29 * files instead of the ascii template files, then you can undefine
30 * "ALLOW_TEMPLATES", saving about 20K by removing "init1.c". Note
31 * that the binary image files are extremely system dependant.
44 #ifdef CHECK_MODIFICATION_TIME
45 #include <sys/types.h>
47 #endif /* CHECK_MODIFICATION_TIME */
50 static void put_title(void);
53 * @brief 各データファイルを読み取るためのパスを取得する
54 * Set the default paths to all of our important sub-directories.
55 * @param configpath Is the base path for ANGBAND_DIR_PREF and
57 * @param libpath パス保管先の文字列
58 * @param datapath Is the base path for directories that have files which
59 * are not read-only: ANGBAND_DIR_APEX, ANGBAND_DIR_BONE, ANGBAND_DIR_DATA,
60 * ANGBAND_DIR_SCRIPT, and ANGBAND_DIR_SAVE. It is not used if the
61 * PRIVATE_USER_PATH preprocessor macro has been set.
65 * The purpose of each sub-directory is described in "variable.c".
66 * The traditional behavior was to put all of the sub-directories within
67 * one directory, "lib". PosChengband allows the possibility of using
68 * three different directories and that has been adopted here. Further
69 * customization may be done later in response to command line options, but
70 * that is done after this function, see change_path() in main.c.
71 * configpath, libpath, and datapath should end in the appropriate "PATH_SEP"
72 * string. All of the "sub-directory" paths (created below or supplied
73 * by the user) will NOT end in the "PATH_SEP" string, see the special
74 * "path_build()" function in "util.c" for more information.
75 * Mega-Hack -- support fat raw files under NEXTSTEP, using special
76 * "suffixed" directories for the "ANGBAND_DIR_DATA" directory, but
77 * requiring the directories to be created by hand by the user.
78 * Hack -- first we free all the strings, since this is known
79 * to succeed even if the strings have not been allocated yet,
80 * as long as the variables start out as "NULL". This allows
81 * this function to be called multiple times, for example, to
82 * try several base "path" values until a good one is found.
85 void init_file_paths(concptr configpath, concptr libpath, concptr datapath)
87 #ifdef PRIVATE_USER_PATH
90 #endif /* PRIVATE_USER_PATH */
92 /*** Free everything ***/
94 /* Free the main path */
95 string_free(ANGBAND_DIR);
97 /* Free the sub-paths */
98 string_free(ANGBAND_DIR_APEX);
99 string_free(ANGBAND_DIR_BONE);
100 string_free(ANGBAND_DIR_DATA);
101 string_free(ANGBAND_DIR_EDIT);
102 string_free(ANGBAND_DIR_SCRIPT);
103 string_free(ANGBAND_DIR_FILE);
104 string_free(ANGBAND_DIR_HELP);
105 string_free(ANGBAND_DIR_INFO);
106 string_free(ANGBAND_DIR_SAVE);
107 string_free(ANGBAND_DIR_USER);
108 string_free(ANGBAND_DIR_XTRA);
111 /*** Prepare the "path" ***/
113 /* Hack -- save the main directory */
114 ANGBAND_DIR = string_make(libpath);
116 /*** Build the sub-directory names ***/
118 ANGBAND_DIR_EDIT = string_make(format("%sedit", configpath));
119 ANGBAND_DIR_FILE = string_make(format("%sfile", libpath));
120 ANGBAND_DIR_HELP = string_make(format("%shelp", libpath));
121 ANGBAND_DIR_INFO = string_make(format("%sinfo", libpath));
122 ANGBAND_DIR_PREF = string_make(format("%spref", configpath));
123 ANGBAND_DIR_XTRA = string_make(format("%sxtra", libpath));
125 #ifdef PRIVATE_USER_PATH
126 /* Build the path to the user specific directory */
127 path_parse(base, sizeof(base), PRIVATE_USER_PATH);
128 path_build(buf, sizeof(buf), base, VERSION_NAME);
130 ANGBAND_DIR_USER = string_make(buf);
132 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "apex");
133 ANGBAND_DIR_APEX = string_make(buf);
135 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "bone");
136 ANGBAND_DIR_BONE = string_make(buf);
138 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "data");
139 ANGBAND_DIR_DATA = string_make(buf);
141 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "save");
142 ANGBAND_DIR_SAVE = string_make(buf);
144 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "script");
145 ANGBAND_DIR_SCRIPT = string_make(buf);
147 #else /* PRIVATE_USER_PATH */
148 ANGBAND_DIR_USER = string_make(format("%suser", datapath));
149 ANGBAND_DIR_APEX = string_make(format("%sapex", datapath));
150 ANGBAND_DIR_BONE = string_make(format("%sbone", datapath));
151 ANGBAND_DIR_DATA = string_make(format("%sdata", datapath));
152 ANGBAND_DIR_SAVE = string_make(format("%ssave", datapath));
153 ANGBAND_DIR_SCRIPT = string_make(format("%sscript", datapath));
154 #endif /* PRIVATE_USER_PATH */
158 /* Allow "fat binary" usage with NeXT */
179 /* Use special directory */
182 /* Forget the old path name */
183 string_free(ANGBAND_DIR_DATA);
185 /* Build a new path name */
186 ANGBAND_DIR_DATA = string_make(format("%sdata-%s", datapath, next));
196 * Helper function for create_needed_dirs(). Copied over from PosChengband.
198 bool dir_exists(concptr path)
201 if (stat(path, &buf) != 0)
204 else if (buf.st_mode & S_IFDIR)
206 else if (S_ISDIR(buf.st_mode))
215 * Helper function for create_needed_dirs(). Copied over from PosChengband
216 * but use the global definition for the path separator rather than a local
217 * one in PosChengband's code and check for paths that end with the path
220 bool dir_create(concptr path)
223 /* If the directory already exists then we're done */
224 if (dir_exists(path)) return TRUE;
230 /* If the directory already exists then we're done */
231 if (dir_exists(path)) return TRUE;
232 /* Iterate through the path looking for path segements. At each step,
233 * create the path segment if it doesn't already exist. */
234 for (ptr = path; *ptr; ptr++)
236 if (*ptr == PATH_SEP[0])
238 /* Find the length of the parent path string */
239 size_t len = (size_t)(ptr - path);
241 /* Skip the initial slash */
242 if (len == 0) continue;
243 /* If this is a duplicate path separator, continue */
244 if (*(ptr - 1) == PATH_SEP[0]) continue;
246 /* We can't handle really big filenames */
247 if (len - 1 > 512) return FALSE;
249 /* Create the parent path string, plus null-padding */
250 my_strcpy(buf, path, len + 1);
252 /* Skip if the parent exists */
253 if (dir_exists(buf)) continue;
255 /* The parent doesn't exist, so create it or fail */
256 if (mkdir(buf, 0755) != 0) return FALSE;
260 * The path ends on a path separator so have created it already in
263 if (*(ptr-1) == PATH_SEP[0])
267 return mkdir(path, 0755) == 0 ? TRUE : FALSE;
273 * Create any missing directories. We create only those dirs which may be
274 * empty (user/, save/, apex/, bone/, script/). The others are assumed
275 * to contain required files and therefore must exist at startup
276 * (edit/, pref/, file/, xtra/).
278 * ToDo: Only create the directories when actually writing files.
279 * Copied over from PosChengband to support main-cocoa.m. Dropped
280 * creation of help/ (and removed it and info/ in the comment)
281 * since init_file_paths() puts those in libpath which may not be writable
282 * by the user running the application. Added bone/ and script/ since
283 * init_file_paths() puts those in datapath.
285 void create_needed_dirs(void)
289 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_USER, "");
290 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
292 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_SAVE, "");
293 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
295 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_APEX, "");
296 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
298 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_BONE, "");
299 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
301 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_DATA, "");
302 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
304 path_build(dirpath, sizeof(dirpath), ANGBAND_DIR_SCRIPT, "");
305 if (!dir_create(dirpath)) quit_fmt("Cannot create '%s'", dirpath);
309 #ifdef ALLOW_TEMPLATES
313 * Hack -- help give useful error messages
315 int error_idx; /*!< データ読み込み/初期化時に汎用的にエラーコードを保存するグローバル変数 */
316 int error_line; /*!< データ読み込み/初期化時に汎用的にエラー行数を保存するグローバル変数 */
320 * エラーメッセージの名称定義 / Standard error message text
322 concptr err_str[PARSE_ERROR_MAX] =
339 "missing record header",
340 "non-sequential records",
341 "invalid flag specification",
342 "undefined directive",
344 "coordinates out of bounds",
346 "undefined terrain tag",
352 #endif /* ALLOW_TEMPLATES */
358 header v_head; /*!< Vault情報のヘッダ構造体 */
359 header f_head; /*!< 地形情報のヘッダ構造体 */
360 header k_head; /*!< ペースアイテム情報のヘッダ構造体 */
361 header a_head; /*!< 固定アーティファクト情報のヘッダ構造体 */
362 header e_head; /*!< アイテムエゴ情報のヘッダ構造体 */
363 header r_head; /*!< モンスター種族情報のヘッダ構造体 */
364 header d_head; /*!< ダンジョン情報のヘッダ構造体 */
365 header s_head; /*!< プレイヤー職業技能情報のヘッダ構造体 */
366 header m_head; /*!< プレイヤー職業魔法情報のヘッダ構造体 */
368 #ifdef CHECK_MODIFICATION_TIME
371 * @brief テキストファイルとrawファイルの更新時刻を比較する
372 * Find the default paths to all of our important sub-directories.
373 * @param fd ファイルディスクリプタ
374 * @param template_file ファイル名
375 * @return テキストの方が新しいか、rawファイルがなく更新の必要がある場合-1、更新の必要がない場合0。
377 static errr check_modification_date(int fd, concptr template_file)
381 struct stat txt_stat, raw_stat;
383 /* Build the filename */
384 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, template_file);
386 /* Access stats on text file */
387 if (stat(buf, &txt_stat))
389 /* No text file - continue */
392 /* Access stats on raw file */
393 else if (fstat(fd, &raw_stat))
399 /* Ensure text file is not newer than raw file */
400 else if (txt_stat.st_mtime > raw_stat.st_mtime)
402 /* Reprocess text file */
409 #endif /* CHECK_MODIFICATION_TIME */
413 /*** Initialize from binary image files ***/
417 * @brief rawファイルからのデータの読み取り処理
418 * Initialize the "*_info" array, by parsing a binary "image" file
419 * @param fd ファイルディスクリプタ
420 * @param head rawファイルのヘッダ
423 static errr init_info_raw(int fd, header *head)
427 /* Read and Verify the header */
428 if (fd_read(fd, (char*)(&test), sizeof(header)) ||
429 (test.v_major != head->v_major) ||
430 (test.v_minor != head->v_minor) ||
431 (test.v_patch != head->v_patch) ||
432 (test.info_num != head->info_num) ||
433 (test.info_len != head->info_len) ||
434 (test.head_size != head->head_size) ||
435 (test.info_size != head->info_size))
442 /* Accept the header */
446 /* Allocate the "*_info" array */
447 C_MAKE(head->info_ptr, head->info_size, char);
449 /* Read the "*_info" array */
450 fd_read(fd, head->info_ptr, head->info_size);
455 /* Allocate the "*_name" array */
456 C_MAKE(head->name_ptr, head->name_size, char);
458 /* Read the "*_name" array */
459 fd_read(fd, head->name_ptr, head->name_size);
465 /* Allocate the "*_text" array */
466 C_MAKE(head->text_ptr, head->text_size, char);
468 /* Read the "*_text" array */
469 fd_read(fd, head->text_ptr, head->text_size);
475 /* Allocate the "*_tag" array */
476 C_MAKE(head->tag_ptr, head->tag_size, char);
478 /* Read the "*_tag" array */
479 fd_read(fd, head->tag_ptr, head->tag_size);
491 * Initialize the header of an *_info.raw file.
492 * @param head rawファイルのヘッダ
497 static void init_header(header *head, IDX num, int len)
499 /* Save the "version" */
500 head->v_major = FAKE_VER_MAJOR;
501 head->v_minor = FAKE_VER_MINOR;
502 head->v_patch = FAKE_VER_PATCH;
505 /* Save the "record" information */
506 head->info_num = (IDX)num;
507 head->info_len = len;
509 /* Save the size of "*_head" and "*_info" */
510 head->head_size = sizeof(header);
511 head->info_size = head->info_num * head->info_len;
517 * Initialize the "*_info" array
518 * @param filename ファイル名(拡張子txt/raw)
519 * @param head 処理に用いるヘッダ構造体
520 * @param info データ保管先の構造体ポインタ
521 * @param name 名称用可変文字列の保管先
522 * @param text テキスト用可変文字列の保管先
523 * @param tag タグ用可変文字列の保管先
526 * Note that we let each entry have a unique "name" and "text" string,
527 * even if the string happens to be empty (everyone has a unique '\0').
529 static errr init_info(concptr filename, header *head,
530 void **info, char **name, char **text, char **tag)
534 BIT_FLAGS mode = 0644;
544 #ifdef ALLOW_TEMPLATES
546 /*** Load the binary image file ***/
548 /* Build the filename */
549 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
552 /* Attempt to open the "raw" file */
553 fd = fd_open(buf, O_RDONLY);
555 /* Process existing "raw" file */
558 #ifdef CHECK_MODIFICATION_TIME
560 err = check_modification_date(fd, format("%s.txt", filename));
562 #endif /* CHECK_MODIFICATION_TIME */
564 /* Attempt to parse the "raw" file */
566 err = init_info_raw(fd, head);
571 /* Do we have to parse the *.txt file? */
574 /*** Make the fake arrays ***/
576 /* Allocate the "*_info" array */
577 C_MAKE(head->info_ptr, head->info_size, char);
579 /* Hack -- make "fake" arrays */
580 if (name) C_MAKE(head->name_ptr, FAKE_NAME_SIZE, char);
581 if (text) C_MAKE(head->text_ptr, FAKE_TEXT_SIZE, char);
582 if (tag) C_MAKE(head->tag_ptr, FAKE_TAG_SIZE, char);
584 if (info) (*info) = head->info_ptr;
585 if (name) (*name) = head->name_ptr;
586 if (text) (*text) = head->text_ptr;
587 if (tag) (*tag) = head->tag_ptr;
589 /*** Load the ascii template file ***/
591 /* Build the filename */
593 path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, format("%s.txt", filename));
596 fp = my_fopen(buf, "r");
599 if (!fp) quit(format(_("'%s.txt'ファイルをオープンできません。", "Cannot open '%s.txt' file."), filename));
602 err = init_info_txt(fp, buf, head, head->parse_info_txt);
612 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "未知の");
614 msg_format("'%s.txt'ファイルの %d 行目にエラー。", filename, error_line);
615 msg_format("レコード %d は '%s' エラーがあります。", error_idx, oops);
616 msg_format("構文 '%s'。", buf);
620 quit(format("'%s.txt'ファイルにエラー", filename));
623 oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
625 msg_format("Error %d at line %d of '%s.txt'.", err, error_line, filename);
626 msg_format("Record %d contains a '%s' error.", error_idx, oops);
627 msg_format("Parsing '%s'.", buf);
631 quit(format("Error in '%s.txt' file.", filename));
637 /*** Make final retouch on fake tags ***/
641 (*head->retouch)(head);
645 /*** Dump the binary image file ***/
647 /* File type is "DATA" */
648 FILE_TYPE(FILE_TYPE_DATA);
650 /* Build the filename */
651 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
654 /* Grab permissions */
657 /* Kill the old file */
660 /* Attempt to create the raw file */
661 fd = fd_make(buf, mode);
663 /* Drop permissions */
666 /* Dump to the file */
670 fd_write(fd, (concptr)(head), head->head_size);
672 /* Dump the "*_info" array */
673 fd_write(fd, head->info_ptr, head->info_size);
675 /* Dump the "*_name" array */
676 fd_write(fd, head->name_ptr, head->name_size);
678 /* Dump the "*_text" array */
679 fd_write(fd, head->text_ptr, head->text_size);
681 /* Dump the "*_tag" array */
682 fd_write(fd, head->tag_ptr, head->tag_size);
689 /*** Kill the fake arrays ***/
691 /* Free the "*_info" array */
692 C_KILL(head->info_ptr, head->info_size, char);
694 /* Hack -- Free the "fake" arrays */
695 if (name) C_KILL(head->name_ptr, FAKE_NAME_SIZE, char);
696 if (text) C_KILL(head->text_ptr, FAKE_TEXT_SIZE, char);
697 if (tag) C_KILL(head->tag_ptr, FAKE_TAG_SIZE, char);
699 #endif /* ALLOW_TEMPLATES */
702 /*** Load the binary image file ***/
704 /* Build the filename */
705 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
707 /* Attempt to open the "raw" file */
708 fd = fd_open(buf, O_RDONLY);
710 /* Process existing "raw" file */
711 if (fd < 0) quit(format(_("'%s_j.raw'ファイルをロードできません。", "Cannot load '%s.raw' file."), filename));
713 /* Attempt to parse the "raw" file */
714 err = init_info_raw(fd, head);
718 if (err) quit(format(_("'%s_j.raw'ファイルを解析できません。", "Cannot parse '%s.raw' file."), filename));
720 #ifdef ALLOW_TEMPLATES
724 if (info) (*info) = head->info_ptr;
725 if (name) (*name) = head->name_ptr;
726 if (text) (*text) = head->text_ptr;
727 if (tag) (*tag) = head->tag_ptr;
735 * @brief 地形情報読み込みのメインルーチン /
736 * Initialize the "f_info" array
739 static errr init_f_info(void)
741 /* Init the header */
742 init_header(&f_head, max_f_idx, sizeof(feature_type));
744 #ifdef ALLOW_TEMPLATES
746 /* Save a pointer to the parsing function */
747 f_head.parse_info_txt = parse_f_info;
749 /* Save a pointer to the retouch fake tags */
750 f_head.retouch = retouch_f_info;
752 #endif /* ALLOW_TEMPLATES */
754 return init_info("f_info", &f_head,
755 (void*)&f_info, &f_name, NULL, &f_tag);
760 * @brief ベースアイテム情報読み込みのメインルーチン /
761 * Initialize the "k_info" array
764 static errr init_k_info(void)
766 /* Init the header */
767 init_header(&k_head, max_k_idx, sizeof(object_kind));
769 #ifdef ALLOW_TEMPLATES
771 /* Save a pointer to the parsing function */
772 k_head.parse_info_txt = parse_k_info;
774 #endif /* ALLOW_TEMPLATES */
776 return init_info("k_info", &k_head,
777 (void*)&k_info, &k_name, &k_text, NULL);
783 * @brief 固定アーティファクト情報読み込みのメインルーチン /
784 * Initialize the "a_info" array
787 static errr init_a_info(void)
789 /* Init the header */
790 init_header(&a_head, max_a_idx, sizeof(artifact_type));
792 #ifdef ALLOW_TEMPLATES
794 /* Save a pointer to the parsing function */
795 a_head.parse_info_txt = parse_a_info;
797 #endif /* ALLOW_TEMPLATES */
799 return init_info("a_info", &a_head,
800 (void*)&a_info, &a_name, &a_text, NULL);
806 * @brief 固定アーティファクト情報読み込みのメインルーチン /
807 * Initialize the "e_info" array
810 static errr init_e_info(void)
812 /* Init the header */
813 init_header(&e_head, max_e_idx, sizeof(ego_item_type));
815 #ifdef ALLOW_TEMPLATES
817 /* Save a pointer to the parsing function */
818 e_head.parse_info_txt = parse_e_info;
820 #endif /* ALLOW_TEMPLATES */
822 return init_info("e_info", &e_head,
823 (void*)&e_info, &e_name, &e_text, NULL);
829 * @brief モンスター種族情報読み込みのメインルーチン /
830 * Initialize the "r_info" array
833 static errr init_r_info(void)
835 /* Init the header */
836 init_header(&r_head, max_r_idx, sizeof(monster_race));
838 #ifdef ALLOW_TEMPLATES
840 /* Save a pointer to the parsing function */
841 r_head.parse_info_txt = parse_r_info;
843 #endif /* ALLOW_TEMPLATES */
845 return init_info("r_info", &r_head,
846 (void*)&r_info, &r_name, &r_text, NULL);
852 * @brief ダンジョン情報読み込みのメインルーチン /
853 * Initialize the "d_info" array
856 static errr init_d_info(void)
858 /* Init the header */
859 init_header(&d_head, max_d_idx, sizeof(dungeon_type));
861 #ifdef ALLOW_TEMPLATES
863 /* Save a pointer to the parsing function */
864 d_head.parse_info_txt = parse_d_info;
866 #endif /* ALLOW_TEMPLATES */
868 return init_info("d_info", &d_head,
869 (void*)&d_info, &d_name, &d_text, NULL);
874 * @brief Vault情報読み込みのメインルーチン /
875 * Initialize the "v_info" array
878 * Note that we let each entry have a unique "name" and "text" string,
879 * even if the string happens to be empty (everyone has a unique '\0').
881 errr init_v_info(void)
883 /* Init the header */
884 init_header(&v_head, max_v_idx, sizeof(vault_type));
886 #ifdef ALLOW_TEMPLATES
888 /* Save a pointer to the parsing function */
889 v_head.parse_info_txt = parse_v_info;
891 #endif /* ALLOW_TEMPLATES */
893 return init_info("v_info", &v_head,
894 (void*)&v_info, &v_name, &v_text, NULL);
899 * @brief 職業技能情報読み込みのメインルーチン /
900 * Initialize the "s_info" array
903 static errr init_s_info(void)
905 /* Init the header */
906 init_header(&s_head, MAX_CLASS, sizeof(skill_table));
908 #ifdef ALLOW_TEMPLATES
910 /* Save a pointer to the parsing function */
911 s_head.parse_info_txt = parse_s_info;
913 #endif /* ALLOW_TEMPLATES */
915 return init_info("s_info", &s_head,
916 (void*)&s_info, NULL, NULL, NULL);
921 * @brief 職業魔法情報読み込みのメインルーチン /
922 * Initialize the "m_info" array
925 static errr init_m_info(void)
927 /* Init the header */
928 init_header(&m_head, MAX_CLASS, sizeof(player_magic));
930 #ifdef ALLOW_TEMPLATES
932 /* Save a pointer to the parsing function */
933 m_head.parse_info_txt = parse_m_info;
935 #endif /* ALLOW_TEMPLATES */
937 return init_info("m_info", &m_head,
938 (void*)&m_info, NULL, NULL, NULL);
946 * @brief 基本情報読み込みのメインルーチン /
947 * Initialize misc. values
950 static errr init_misc(void)
952 /* Initialize the values */
953 process_dungeon_file("misc.txt", 0, 0, 0, 0);
960 * @brief 町情報読み込みのメインルーチン /
961 * Initialize town array
964 static errr init_towns(void)
968 /*** Prepare the Towns ***/
970 /* Allocate the towns */
971 C_MAKE(town_info, max_towns, town_type);
973 for (i = 1; i < max_towns; i++)
975 /*** Prepare the Stores ***/
977 /* Allocate the stores */
978 C_MAKE(town_info[i].store, MAX_STORES, store_type);
980 /* Fill in each store */
981 for (j = 0; j < MAX_STORES; j++)
983 /* Access the store */
984 store_type *st_ptr = &town_info[i].store[j];
986 if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) continue;
988 /* Assume full stock */
991 * 我が家が 20 ページまで使える隠し機能のための準備。
992 * オプションが有効でもそうでなくても一応スペース
997 st_ptr->stock_size = (STORE_INVEN_MAX * 10);
999 else if (j == STORE_MUSEUM)
1001 st_ptr->stock_size = (STORE_INVEN_MAX * 50);
1005 st_ptr->stock_size = STORE_INVEN_MAX;
1007 /* Allocate the stock */
1008 C_MAKE(st_ptr->stock, st_ptr->stock_size, object_type);
1010 /* No table for the black market or home */
1011 if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) continue;
1013 /* Assume full table */
1014 st_ptr->table_size = STORE_CHOICES;
1016 /* Allocate the stock */
1017 C_MAKE(st_ptr->table, st_ptr->table_size, s16b);
1019 /* Scan the choices */
1020 for (k = 0; k < STORE_CHOICES; k++)
1022 KIND_OBJECT_IDX k_idx;
1024 /* Extract the tval/sval codes */
1025 int tv = store_table[j][k][0];
1026 int sv = store_table[j][k][1];
1029 for (k_idx = 1; k_idx < max_k_idx; k_idx++)
1031 object_kind *k_ptr = &k_info[k_idx];
1034 if ((k_ptr->tval == tv) && (k_ptr->sval == sv)) break;
1038 if (k_idx == max_k_idx) continue;
1040 /* Add that item index to the table */
1041 st_ptr->table[st_ptr->table_num++] = k_idx;
1050 * @brief 店情報初期化のメインルーチン /
1051 * Initialize buildings
1054 errr init_buildings(void)
1058 for (i = 0; i < MAX_BLDG; i++)
1060 building[i].name[0] = '\0';
1061 building[i].owner_name[0] = '\0';
1062 building[i].owner_race[0] = '\0';
1064 for (j = 0; j < 8; j++)
1066 building[i].act_names[j][0] = '\0';
1067 building[i].member_costs[j] = 0;
1068 building[i].other_costs[j] = 0;
1069 building[i].letters[j] = 0;
1070 building[i].actions[j] = 0;
1071 building[i].action_restr[j] = 0;
1074 for (j = 0; j < MAX_CLASS; j++)
1076 building[i].member_class[j] = 0;
1079 for (j = 0; j < MAX_RACES; j++)
1081 building[i].member_race[j] = 0;
1084 for (j = 0; j < MAX_MAGIC+1; j++)
1086 building[i].member_realm[j] = 0;
1095 * @brief クエスト情報初期化のメインルーチン /
1096 * Initialize quest array
1099 static errr init_quests(void)
1103 /*** Prepare the quests ***/
1105 /* Allocate the quests */
1106 C_MAKE(quest, max_q_idx, quest_type);
1108 /* Set all quest to "untaken" */
1109 for (i = 0; i < max_q_idx; i++)
1111 quest[i].status = QUEST_STATUS_UNTAKEN;
1117 /*! 地形タグ情報から地形IDを得られなかった場合にTRUEを返すグローバル変数 */
1118 static bool feat_tag_is_not_found = FALSE;
1121 * @brief 地形タグからIDを得る /
1122 * Initialize quest array
1125 s16b f_tag_to_index_in_init(concptr str)
1127 FEAT_IDX feat = f_tag_to_index(str);
1129 if (feat < 0) feat_tag_is_not_found = TRUE;
1136 * @brief 地形の汎用定義をタグを通じて取得する /
1137 * Initialize feature variables
1140 static errr init_feat_variables(void)
1145 feat_none = f_tag_to_index_in_init("NONE");
1148 feat_floor = f_tag_to_index_in_init("FLOOR");
1151 feat_glyph = f_tag_to_index_in_init("GLYPH");
1152 feat_explosive_rune = f_tag_to_index_in_init("EXPLOSIVE_RUNE");
1153 feat_mirror = f_tag_to_index_in_init("MIRROR");
1156 feat_door[DOOR_DOOR].open = f_tag_to_index_in_init("OPEN_DOOR");
1157 feat_door[DOOR_DOOR].broken = f_tag_to_index_in_init("BROKEN_DOOR");
1158 feat_door[DOOR_DOOR].closed = f_tag_to_index_in_init("CLOSED_DOOR");
1161 for (i = 1; i < MAX_LJ_DOORS; i++)
1163 s16b door = f_tag_to_index(format("LOCKED_DOOR_%d", i));
1164 if (door < 0) break;
1165 feat_door[DOOR_DOOR].locked[i - 1] = door;
1167 if (i == 1) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
1168 feat_door[DOOR_DOOR].num_locked = i - 1;
1171 for (i = 0; i < MAX_LJ_DOORS; i++)
1173 s16b door = f_tag_to_index(format("JAMMED_DOOR_%d", i));
1174 if (door < 0) break;
1175 feat_door[DOOR_DOOR].jammed[i] = door;
1177 if (!i) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
1178 feat_door[DOOR_DOOR].num_jammed = i;
1181 feat_door[DOOR_GLASS_DOOR].open = f_tag_to_index_in_init("OPEN_GLASS_DOOR");
1182 feat_door[DOOR_GLASS_DOOR].broken = f_tag_to_index_in_init("BROKEN_GLASS_DOOR");
1183 feat_door[DOOR_GLASS_DOOR].closed = f_tag_to_index_in_init("CLOSED_GLASS_DOOR");
1185 /* Locked glass doors */
1186 for (i = 1; i < MAX_LJ_DOORS; i++)
1188 s16b door = f_tag_to_index(format("LOCKED_GLASS_DOOR_%d", i));
1189 if (door < 0) break;
1190 feat_door[DOOR_GLASS_DOOR].locked[i - 1] = door;
1192 if (i == 1) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
1193 feat_door[DOOR_GLASS_DOOR].num_locked = i - 1;
1195 /* Jammed glass doors */
1196 for (i = 0; i < MAX_LJ_DOORS; i++)
1198 s16b door = f_tag_to_index(format("JAMMED_GLASS_DOOR_%d", i));
1199 if (door < 0) break;
1200 feat_door[DOOR_GLASS_DOOR].jammed[i] = door;
1202 if (!i) return PARSE_ERROR_UNDEFINED_TERRAIN_TAG;
1203 feat_door[DOOR_GLASS_DOOR].num_jammed = i;
1206 feat_door[DOOR_CURTAIN].open = f_tag_to_index_in_init("OPEN_CURTAIN");
1207 feat_door[DOOR_CURTAIN].broken = feat_door[DOOR_CURTAIN].open;
1208 feat_door[DOOR_CURTAIN].closed = f_tag_to_index_in_init("CLOSED_CURTAIN");
1209 feat_door[DOOR_CURTAIN].locked[0] = feat_door[DOOR_CURTAIN].closed;
1210 feat_door[DOOR_CURTAIN].num_locked = 1;
1211 feat_door[DOOR_CURTAIN].jammed[0] = feat_door[DOOR_CURTAIN].closed;
1212 feat_door[DOOR_CURTAIN].num_jammed = 1;
1215 feat_up_stair = f_tag_to_index_in_init("UP_STAIR");
1216 feat_down_stair = f_tag_to_index_in_init("DOWN_STAIR");
1217 feat_entrance = f_tag_to_index_in_init("ENTRANCE");
1220 init_normal_traps();
1223 feat_trap_open = f_tag_to_index_in_init("TRAP_OPEN");
1224 feat_trap_armageddon = f_tag_to_index_in_init("TRAP_ARMAGEDDON");
1225 feat_trap_piranha = f_tag_to_index_in_init("TRAP_PIRANHA");
1228 feat_rubble = f_tag_to_index_in_init("RUBBLE");
1231 feat_magma_vein = f_tag_to_index_in_init("MAGMA_VEIN");
1232 feat_quartz_vein = f_tag_to_index_in_init("QUARTZ_VEIN");
1235 feat_granite = f_tag_to_index_in_init("GRANITE");
1236 feat_permanent = f_tag_to_index_in_init("PERMANENT");
1239 feat_glass_floor = f_tag_to_index_in_init("GLASS_FLOOR");
1242 feat_glass_wall = f_tag_to_index_in_init("GLASS_WALL");
1243 feat_permanent_glass_wall = f_tag_to_index_in_init("PERMANENT_GLASS_WALL");
1246 feat_pattern_start = f_tag_to_index_in_init("PATTERN_START");
1247 feat_pattern_1 = f_tag_to_index_in_init("PATTERN_1");
1248 feat_pattern_2 = f_tag_to_index_in_init("PATTERN_2");
1249 feat_pattern_3 = f_tag_to_index_in_init("PATTERN_3");
1250 feat_pattern_4 = f_tag_to_index_in_init("PATTERN_4");
1251 feat_pattern_end = f_tag_to_index_in_init("PATTERN_END");
1252 feat_pattern_old = f_tag_to_index_in_init("PATTERN_OLD");
1253 feat_pattern_exit = f_tag_to_index_in_init("PATTERN_EXIT");
1254 feat_pattern_corrupted = f_tag_to_index_in_init("PATTERN_CORRUPTED");
1257 feat_black_market = f_tag_to_index_in_init("BLACK_MARKET");
1258 feat_town = f_tag_to_index_in_init("TOWN");
1261 feat_deep_water = f_tag_to_index_in_init("DEEP_WATER");
1262 feat_shallow_water = f_tag_to_index_in_init("SHALLOW_WATER");
1263 feat_deep_lava = f_tag_to_index_in_init("DEEP_LAVA");
1264 feat_shallow_lava = f_tag_to_index_in_init("SHALLOW_LAVA");
1265 feat_heavy_cold_zone = f_tag_to_index_in_init("HEAVY_COLD_ZONE");
1266 feat_cold_zone = f_tag_to_index_in_init("COLD_ZONE");
1267 feat_heavy_electrical_zone = f_tag_to_index_in_init("HEAVY_ELECTRICAL_ZONE");
1268 feat_electrical_zone = f_tag_to_index_in_init("ELECTRICAL_ZONE");
1269 feat_deep_acid_puddle = f_tag_to_index_in_init("DEEP_ACID_PUDDLE");
1270 feat_shallow_acid_puddle = f_tag_to_index_in_init("SHALLOW_ACID_PUDDLE");
1271 feat_deep_poisonous_puddle = f_tag_to_index_in_init("DEEP_POISONOUS_PUDDLE");
1272 feat_shallow_poisonous_puddle = f_tag_to_index_in_init("SHALLOW_POISONOUS_PUDDLE");
1273 feat_dirt = f_tag_to_index_in_init("DIRT");
1274 feat_grass = f_tag_to_index_in_init("GRASS");
1275 feat_flower = f_tag_to_index_in_init("FLOWER");
1276 feat_brake = f_tag_to_index_in_init("BRAKE");
1277 feat_tree = f_tag_to_index_in_init("TREE");
1278 feat_mountain = f_tag_to_index_in_init("MOUNTAIN");
1279 feat_swamp = f_tag_to_index_in_init("SWAMP");
1281 /* Unknown grid (not detected) */
1282 feat_undetected = f_tag_to_index_in_init("UNDETECTED");
1284 /* Wilderness terrains */
1285 init_wilderness_terrains();
1287 return feat_tag_is_not_found ? PARSE_ERROR_UNDEFINED_TERRAIN_TAG : 0;
1292 * @brief その他の初期情報更新 /
1293 * Initialize some other arrays
1296 static errr init_other(void)
1301 /*** Prepare the "dungeon" information ***/
1303 /* Allocate and Wipe the object list */
1304 C_MAKE(current_floor_ptr->o_list, current_floor_ptr->max_o_idx, object_type);
1306 /* Allocate and Wipe the monster list */
1307 C_MAKE(current_floor_ptr->m_list, current_floor_ptr->max_m_idx, monster_type);
1309 /* Allocate and Wipe the monster process list */
1310 for (i = 0; i < MAX_MTIMED; i++)
1312 C_MAKE(current_floor_ptr->mproc_list[i], current_floor_ptr->max_m_idx, s16b);
1315 /* Allocate and Wipe the max dungeon level */
1316 C_MAKE(max_dlv, max_d_idx, DEPTH);
1318 /* Allocate and wipe each line of the current_floor_ptr->grid_array */
1319 for (i = 0; i < MAX_HGT; i++)
1321 /* Allocate one row of the current_floor_ptr->grid_array */
1322 C_MAKE(current_floor_ptr->grid_array[i], MAX_WID, grid_type);
1326 /*** Prepare the various "bizarre" arrays ***/
1328 /* Macro variables */
1329 C_MAKE(macro__pat, MACRO_MAX, concptr);
1330 C_MAKE(macro__act, MACRO_MAX, concptr);
1331 C_MAKE(macro__cmd, MACRO_MAX, bool);
1333 /* Macro action buffer */
1334 C_MAKE(macro__buf, 1024, char);
1336 /* Quark variables */
1339 /* Message variables */
1340 C_MAKE(message__ptr, MESSAGE_MAX, u32b);
1341 C_MAKE(message__buf, MESSAGE_BUF, char);
1343 /* Hack -- No messages yet */
1344 message__tail = MESSAGE_BUF;
1347 /*** Prepare the Player inventory ***/
1350 C_MAKE(inventory, INVEN_TOTAL, object_type);
1353 /*** Prepare the options ***/
1355 /* Scan the options */
1356 for (i = 0; option_info[i].o_desc; i++)
1358 int os = option_info[i].o_set;
1359 int ob = option_info[i].o_bit;
1361 /* Set the "default" options */
1362 if (option_info[i].o_var)
1365 option_mask[os] |= (1L << ob);
1368 if (option_info[i].o_norm)
1371 option_flag[os] |= (1L << ob);
1378 option_flag[os] &= ~(1L << ob);
1383 /* Analyze the windows */
1384 for (n = 0; n < 8; n++)
1386 /* Analyze the options */
1387 for (i = 0; i < 32; i++)
1390 if (window_flag_desc[i])
1393 window_mask[n] |= (1L << i);
1399 * Set the "default" window flags
1400 * Window 1 : Display messages
1401 * Window 2 : Display inven/equip
1403 window_flag[1] = 1L << A_MAX;
1404 window_flag[2] = 1L << 0;
1407 /*** Pre-allocate space for the "format()" buffer ***/
1409 /* Hack -- Just call the "format()" function */
1410 (void)format("%s (%s).", "Mr.Hoge", MAINTAINER);
1419 * @brief オブジェクト配列を初期化する /
1420 * Initialize some other arrays
1423 static errr init_object_alloc(void)
1428 s16b num[MAX_DEPTH];
1429 s16b aux[MAX_DEPTH];
1432 /*** Analyze object allocation info ***/
1434 /* Clear the "aux" array */
1435 (void)C_WIPE(&aux, MAX_DEPTH, s16b);
1437 /* Clear the "num" array */
1438 (void)C_WIPE(&num, MAX_DEPTH, s16b);
1440 /* Free the old "alloc_kind_table" (if it exists) */
1441 if (alloc_kind_table)
1443 C_KILL(alloc_kind_table, alloc_kind_size, alloc_entry);
1446 /* Size of "alloc_kind_table" */
1447 alloc_kind_size = 0;
1449 /* Scan the objects */
1450 for (i = 1; i < max_k_idx; i++)
1454 /* Scan allocation pairs */
1455 for (j = 0; j < 4; j++)
1457 /* Count the "legal" entries */
1458 if (k_ptr->chance[j])
1460 /* Count the entries */
1463 /* Group by level */
1464 num[k_ptr->locale[j]]++;
1469 /* Collect the level indexes */
1470 for (i = 1; i < MAX_DEPTH; i++)
1472 /* Group by level */
1475 if (!num[0]) quit(_("町のアイテムがない!", "No town objects!"));
1477 /*** Initialize object allocation info ***/
1479 /* Allocate the alloc_kind_table */
1480 C_MAKE(alloc_kind_table, alloc_kind_size, alloc_entry);
1482 /* Access the table entry */
1483 table = alloc_kind_table;
1485 /* Scan the objects */
1486 for (i = 1; i < max_k_idx; i++)
1490 /* Scan allocation pairs */
1491 for (j = 0; j < 4; j++)
1493 /* Count the "legal" entries */
1494 if (k_ptr->chance[j])
1498 /* Extract the base level */
1499 x = k_ptr->locale[j];
1501 /* Extract the base probability */
1502 p = (100 / k_ptr->chance[j]);
1504 /* Skip entries preceding our locale */
1505 y = (x > 0) ? num[x-1] : 0;
1507 /* Skip previous entries at this locale */
1510 /* Load the entry */
1511 table[z].index = (KIND_OBJECT_IDX)i;
1512 table[z].level = (DEPTH)x;
1513 table[z].prob1 = (PROB)p;
1514 table[z].prob2 = (PROB)p;
1515 table[z].prob3 = (PROB)p;
1517 /* Another entry complete for this locale */
1529 * @brief モンスター配列と生成テーブルを初期化する /
1530 * Initialize some other arrays
1533 static errr init_alloc(void)
1536 monster_race *r_ptr;
1542 /* Allocate the "r_info" array */
1543 C_MAKE(elements, max_r_idx, tag_type);
1545 /* Scan the monsters */
1546 for (i = 1; i < max_r_idx; i++)
1548 elements[i].tag = r_info[i].level;
1549 elements[i].index = i;
1552 tag_sort(elements, max_r_idx);
1554 /*** Initialize monster allocation info ***/
1556 /* Size of "alloc_race_table" */
1557 alloc_race_size = max_r_idx;
1559 /* Allocate the alloc_race_table */
1560 C_MAKE(alloc_race_table, alloc_race_size, alloc_entry);
1562 /* Scan the monsters */
1563 for (i = 1; i < max_r_idx; i++)
1565 /* Get the i'th race */
1566 r_ptr = &r_info[elements[i].index];
1568 /* Count valid pairs */
1573 /* Extract the base level */
1576 /* Extract the base probability */
1577 p = (100 / r_ptr->rarity);
1579 /* Load the entry */
1580 alloc_race_table[i].index = (KIND_OBJECT_IDX)elements[i].index;
1581 alloc_race_table[i].level = (DEPTH)x;
1582 alloc_race_table[i].prob1 = (PROB)p;
1583 alloc_race_table[i].prob2 = (PROB)p;
1584 alloc_race_table[i].prob3 = (PROB)p;
1588 /* Free the "r_info" array */
1589 C_KILL(elements, max_r_idx, tag_type);
1591 #else /* SORT_R_INFO */
1595 s16b num[MAX_DEPTH];
1596 s16b aux[MAX_DEPTH];
1598 /*** Analyze monster allocation info ***/
1600 /* Clear the "aux" array */
1601 C_WIPE(&aux, MAX_DEPTH, s16b);
1603 /* Clear the "num" array */
1604 C_WIPE(&num, MAX_DEPTH, s16b);
1606 /* Size of "alloc_race_table" */
1607 alloc_race_size = 0;
1609 /* Scan the monsters */
1610 for (i = 1; i < max_r_idx; i++)
1612 /* Get the i'th race */
1615 /* Legal monsters */
1618 /* Count the entries */
1621 /* Group by level */
1622 num[r_ptr->level]++;
1626 /* Collect the level indexes */
1627 for (i = 1; i < MAX_DEPTH; i++)
1629 /* Group by level */
1632 if (!num[0]) quit(_("町のモンスターがない!", "No town monsters!"));
1634 /*** Initialize monster allocation info ***/
1636 /* Allocate the alloc_race_table */
1637 C_MAKE(alloc_race_table, alloc_race_size, alloc_entry);
1639 /* Access the table entry */
1640 table = alloc_race_table;
1642 /* Scan the monsters */
1643 for (i = 1; i < max_r_idx; i++)
1645 /* Get the i'th race */
1648 /* Count valid pairs */
1653 /* Extract the base level */
1656 /* Extract the base probability */
1657 p = (100 / r_ptr->rarity);
1659 /* Skip entries preceding our locale */
1660 y = (x > 0) ? num[x-1] : 0;
1662 /* Skip previous entries at this locale */
1665 /* Load the entry */
1672 /* Another entry complete for this locale */
1677 #endif /* SORT_R_INFO */
1679 /* Init the "alloc_kind_table" */
1680 (void)init_object_alloc();
1689 * @brief 画面左下にシステムメッセージを表示する /
1690 * Hack -- take notes on line 23
1693 static void note(concptr str)
1695 Term_erase(0, 23, 255);
1696 Term_putstr(20, 23, -1, TERM_WHITE, str);
1703 * @brief 全ゲームデータ読み込みのサブルーチン /
1704 * Hack -- Explain a broken "lib" folder and quit (see below).
1708 * This function is "messy" because various things
1709 * may or may not be initialized, but the "plog()" and "quit()"
1710 * functions are "supposed" to work under any conditions.
1713 static void init_angband_aux(concptr why)
1720 plog("'lib'ディレクトリが存在しないか壊れているようです。");
1723 plog("ひょっとするとアーカイブが正しく解凍されていないのかもしれません。");
1726 plog("該当する'README'ファイルを読んで確認してみて下さい。");
1728 /* Quit with error */
1732 plog("The 'lib' directory is probably missing or broken.");
1735 plog("Perhaps the archive was not extracted correctly.");
1738 plog("See the 'README' file for more information.");
1740 /* Quit with error */
1741 quit("Fatal Error.");
1748 * @brief 全ゲームデータ読み込みのメインルーチン /
1749 * Hack -- main Angband initialization entry point
1753 * This function is "messy" because various things
1754 * may or may not be initialized, but the "plog()" and "quit()"
1755 * functions are "supposed" to work under any conditions.
1756 * Verify some files, display the "news.txt" file, create
1757 * the high score file, initialize all internal arrays, and
1758 * load the basic "user pref files".
1759 * Be very careful to keep track of the order in which things
1760 * are initialized, in particular, the only thing *known* to
1761 * be available when this function is called is the "z-term.c"
1762 * package, and that may not be fully initialized until the
1763 * end of this function, when the default "user pref files"
1764 * are loaded and "Term_xtra(TERM_XTRA_REACT,0)" is called.
1765 * Note that this function attempts to verify the "news" file,
1766 * and the game aborts (cleanly) on failure, since without the
1767 * "news" file, it is likely that the "lib" folder has not been
1768 * correctly located. Otherwise, the news file is displayed for
1770 * Note that this function attempts to verify (or create) the
1771 * "high score" file, and the game aborts (cleanly) on failure,
1772 * since one of the most common "extraction" failures involves
1773 * failing to extract all sub-directories (even empty ones), such
1774 * as by failing to use the "-d" option of "pkunzip", or failing
1775 * to use the "save empty directories" option with "Compact Pro".
1776 * This error will often be caught by the "high score" creation
1777 * code below, since the "lib/apex" directory, being empty in the
1778 * standard distributions, is most likely to be "lost", making it
1779 * impossible to create the high score file.
1780 * Note that various things are initialized by this function,
1781 * including everything that was once done by "init_some_arrays".
1782 * This initialization involves the parsing of special files
1783 * in the "lib/data" and sometimes the "lib/edit" directories.
1784 * Note that the "template" files are initialized first, since they
1785 * often contain errors. This means that macros and message recall
1786 * and things like that are not available until after they are done.
1787 * We load the default "user pref files" here in case any "color"
1788 * changes are needed before character creation.
1789 * Note that the "graf-xxx.prf" file must be loaded separately,
1790 * if needed, in the first (?) pass through "TERM_XTRA_REACT".
1793 void init_angband(void)
1797 BIT_FLAGS mode = 0664;
1804 /*** Verify the "news" file ***/
1806 /* Build the filename */
1807 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
1809 /* Attempt to open the file */
1810 fd = fd_open(buf, O_RDONLY);
1817 sprintf(why, _("'%s'ファイルにアクセスできません!", "Cannot access the '%s' file!"), buf);
1819 /* Crash and burn */
1820 init_angband_aux(why);
1825 /*** Display the "news" file ***/
1828 /* Build the filename */
1829 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
1831 /* Open the News file */
1832 fp = my_fopen(buf, "r");
1839 /* Dump the file to the screen */
1840 while (0 == my_fgets(fp, buf, sizeof(buf)))
1842 /* Display and advance */
1843 Term_putstr(0, i++, -1, TERM_WHITE, buf);
1854 /*** Verify (or create) the "high score" file ***/
1856 /* Build the filename */
1857 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
1859 /* Attempt to open the high score file */
1860 fd = fd_open(buf, O_RDONLY);
1865 /* File type is "DATA" */
1866 FILE_TYPE(FILE_TYPE_DATA);
1868 /* Grab permissions */
1871 /* Create a new high score file */
1872 fd = fd_make(buf, mode);
1874 /* Drop permissions */
1882 sprintf(why, _("'%s'ファイルを作成できません!", "Cannot create the '%s' file!"), buf);
1884 /* Crash and burn */
1885 init_angband_aux(why);
1892 /*** Initialize some arrays ***/
1894 /* Initialize misc. values */
1895 note(_("[変数を初期化しています...(その他)", "[Initializing values... (misc)]"));
1896 if (init_misc()) quit(_("その他の変数を初期化できません", "Cannot initialize misc. values"));
1898 /* Initialize feature info */
1900 note("[データの初期化中... (地形)]");
1901 if (init_f_info()) quit("地形初期化不能");
1902 if (init_feat_variables()) quit("地形初期化不能");
1904 note("[Initializing arrays... (features)]");
1905 if (init_f_info()) quit("Cannot initialize features");
1906 if (init_feat_variables()) quit("Cannot initialize features");
1910 /* Initialize object info */
1911 note(_("[データの初期化中... (アイテム)]", "[Initializing arrays... (objects)]"));
1912 if (init_k_info()) quit(_("アイテム初期化不能", "Cannot initialize objects"));
1915 /* Initialize artifact info */
1916 note(_("[データの初期化中... (伝説のアイテム)]", "[Initializing arrays... (artifacts)]"));
1917 if (init_a_info()) quit(_("伝説のアイテム初期化不能", "Cannot initialize artifacts"));
1920 /* Initialize ego-item info */
1921 note(_("[データの初期化中... (名のあるアイテム)]", "[Initializing arrays... (ego-items)]"));
1922 if (init_e_info()) quit(_("名のあるアイテム初期化不能", "Cannot initialize ego-items"));
1925 /* Initialize monster info */
1926 note(_("[データの初期化中... (モンスター)]", "[Initializing arrays... (monsters)]"));
1927 if (init_r_info()) quit(_("モンスター初期化不能", "Cannot initialize monsters"));
1930 /* Initialize dungeon info */
1931 note(_("[データの初期化中... (ダンジョン)]", "[Initializing arrays... (dungeon)]"));
1932 if (init_d_info()) quit(_("ダンジョン初期化不能", "Cannot initialize dungeon"));
1935 for (i = 1; i < max_d_idx; i++)
1936 if (d_info[i].final_guardian)
1937 r_info[d_info[i].final_guardian].flags7 |= RF7_GUARDIAN;
1940 /* Initialize magic info */
1941 note(_("[データの初期化中... (魔法)]", "[Initializing arrays... (magic)]"));
1942 if (init_m_info()) quit(_("魔法初期化不能", "Cannot initialize magic"));
1944 /* Initialize weapon_exp info */
1945 note(_("[データの初期化中... (熟練度)]", "[Initializing arrays... (skill)]"));
1946 if (init_s_info()) quit(_("熟練度初期化不能", "Cannot initialize skill"));
1948 /* Initialize wilderness array */
1949 note(_("[配列を初期化しています... (荒野)]", "[Initializing arrays... (wilderness)]"));
1951 if (init_wilderness()) quit(_("荒野を初期化できません", "Cannot initialize wilderness"));
1954 /* Initialize town array */
1955 note(_("[配列を初期化しています... (街)]", "[Initializing arrays... (towns)]"));
1956 if (init_towns()) quit(_("街を初期化できません", "Cannot initialize towns"));
1959 /* Initialize building array */
1960 note(_("[配列を初期化しています... (建物)]", "[Initializing arrays... (buildings)]"));
1961 if (init_buildings()) quit(_("建物を初期化できません", "Cannot initialize buildings"));
1964 /* Initialize quest array */
1965 note(_("[配列を初期化しています... (クエスト)]", "[Initializing arrays... (quests)]"));
1966 if (init_quests()) quit(_("クエストを初期化できません", "Cannot initialize quests"));
1968 /* Initialize vault info */
1969 if (init_v_info()) quit(_("vault 初期化不能", "Cannot initialize vaults"));
1971 /* Initialize some other arrays */
1972 note(_("[データの初期化中... (その他)]", "[Initializing arrays... (other)]"));
1973 if (init_other()) quit(_("その他のデータ初期化不能", "Cannot initialize other stuff"));
1976 /* Initialize some other arrays */
1977 note(_("[データの初期化中... (アロケーション)]", "[Initializing arrays... (alloc)]"));
1978 if (init_alloc()) quit(_("アロケーション・スタッフ初期化不能", "Cannot initialize alloc stuff"));
1982 /*** Load default user pref files ***/
1984 /* Initialize feature info */
1985 note(_("[ユーザー設定ファイルを初期化しています...]", "[Initializing user pref files...]"));
1987 /* Access the "basic" pref file */
1988 strcpy(buf, "pref.prf");
1990 /* Process that file */
1991 process_pref_file(buf);
1993 /* Access the "basic" system pref file */
1994 sprintf(buf, "pref-%s.prf", ANGBAND_SYS);
1996 /* Process that file */
1997 process_pref_file(buf);
1999 note(_("[初期化終了]", "[Initialization complete]"));
2006 static void put_title(void)
2011 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,
2013 sprintf(title, _("変愚蛮怒 %d.%d.%d(%s)", "Hengband %d.%d.%d(%s)"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH,
2015 IS_STABLE_VERSION ? _("安定版", "Stable") : _("開発版", "Developing"));
2016 col = (80 - strlen(title)) / 2;
2017 col = col < 0 ? 0 : col;
2018 prt(title, VER_INFO_ROW, col);
2022 * @brief サムチェック情報を出力 / Get check sum in string form
2023 * @return サムチェック情報の文字列
2025 concptr get_check_sum(void)
2027 return format("%02x%02x%02x%02x%02x%02x%02x%02x%02x",