Hengband  2.2.1
init.h
[詳解]
1 /*!
2  * @file init.h
3  * @brief ゲームデータ初期化処理のヘッダファイル
4  * @date 2015/01/02
5  * @author
6  * Copyright (c) 2000 Robert Ruehlmann
7  * @details
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.
11  */
12 
13 #ifndef INCLUDED_INIT_H
14 #define INCLUDED_INIT_H
15 
16 #include "h-basic.h"
17 
18 
19 #if 0
20 /*
21  * Parse errors
22  */
23 #define PARSE_ERROR_GENERIC 1
24 #define PARSE_ERROR_OBSOLETE_FILE 2
25 #define PARSE_ERROR_MISSING_RECORD_HEADER 3
26 #define PARSE_ERROR_NON_SEQUENTIAL_RECORDS 4
27 #define PARSE_ERROR_INVALID_FLAG 5
28 #define PARSE_ERROR_UNDEFINED_DIRECTIVE 6
29 #define PARSE_ERROR_OUT_OF_MEMORY 7
30 #define PARSE_ERROR_OUT_OF_BOUNDS 8
31 #define PARSE_ERROR_TOO_FEW_ARGUMENTS 9
32 #define PARSE_ERROR_TOO_MANY_ARGUMENTS 10
33 #define PARSE_ERROR_TOO_MANY_ALLOCATIONS 11
34 #define PARSE_ERROR_INVALID_SPELL_FREQ 12
35 #define PARSE_ERROR_INVALID_ITEM_NUMBER 13
36 #define PARSE_ERROR_TOO_MANY_ENTRIES 14
37 
38 #define PARSE_ERROR_MAX 15
39 #endif /* 0 */
40 
41 
42 typedef struct header header;
43 
44 typedef errr (*parse_info_txt_func)(char *buf, header *head);
45 
46 /*
47  * Size of memory reserved for initialization of some arrays
48  */
49 #define FAKE_NAME_SIZE 40 * 1024L /*!< ゲーム情報の種別毎に用意される名前用バッファの容量 */
50 #define FAKE_TEXT_SIZE 150 * 1024L /*!< ゲーム情報の種別毎に用意されるテキスト用バッファの容量 */
51 #define FAKE_TAG_SIZE 10 * 1024L /*!< ゲーム情報の種別毎に用意されるタグ用バッファの容量 */
52 
53 #define VER_INFO_ROW 3 //!< タイトル表記(行)
54 
55 /*!
56  * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
57  * @note Default: assume at most 256 macros are used
58  */
59 #define MACRO_MAX 256
60 
61 
62 /*!
63  * @struct header
64  * @brief 各初期データ用ヘッダ構造体 / Template file header information (see "init.c"). 16 bytes.
65  * @details
66  * Note that the sizes of many of the "arrays" are between 32768 and
67  * 65535, and so we must use "unsigned" values to hold the "sizes" of
68  * these arrays below. Normally, I try to avoid using unsigned values,
69  * since they can cause all sorts of bizarre problems, but I have no
70  * choice here, at least, until the "race" array is split into "normal"
71  * and "unique" monsters, which may or may not actually help.
72  *
73  * Note that, on some machines, for example, the Macintosh, the standard
74  * "read()" and "write()" functions cannot handle more than 32767 bytes
75  * at one time, so we need replacement functions, see "util.c" for details.
76  *
77  * Note that, on some machines, for example, the Macintosh, the standard
78  * "malloc()" function cannot handle more than 32767 bytes at one time,
79  * but we may assume that the "ralloc()" function can handle up to 65535
80  * butes at one time. We should not, however, assume that the "ralloc()"
81  * function can handle more than 65536 bytes at a time, since this might
82  * result in segmentation problems on certain older machines, and in fact,
83  * we should not assume that it can handle exactly 65536 bytes at a time,
84  * since the internal functions may use an unsigned short to specify size.
85  *
86  * In general, these problems occur only on machines (such as most personal
87  * computers) which use 2 byte "int" values, and which use "int" for the
88  * arguments to the relevent functions.
89  */
90 struct header
91 {
92  byte v_major; /* Version -- major */
93  byte v_minor; /* Version -- minor */
94  byte v_patch; /* Version -- patch */
95  byte v_extra; /* Version -- extra */
96 
97  u16b info_num; /* Number of "info" records */
98  int info_len; /* Size of each "info" record */
99  u16b head_size; /* Size of the "header" in bytes */
100 
101  STR_OFFSET info_size; /* Size of the "info" array in bytes */
102  STR_OFFSET name_size; /* Size of the "name" array in bytes */
103  STR_OFFSET text_size; /* Size of the "text" array in bytes */
104  STR_OFFSET tag_size; /* Size of the "tag" array in bytes */
105 
106  void *info_ptr;
107  char *name_ptr;
108  char *text_ptr;
109  char *tag_ptr;
110 
112 
113  void (*retouch)(header *head);
114 };
115 
116 extern errr init_info_txt(FILE *fp, char *buf, header *head,
117  parse_info_txt_func parse_info_txt_line);
118 
119 #ifdef ALLOW_TEMPLATES
120 extern errr parse_z_info(char *buf, header *head);
121 extern errr parse_v_info(char *buf, header *head);
122 extern errr parse_f_info(char *buf, header *head);
123 extern void retouch_f_info(header *head);
124 extern errr parse_k_info(char *buf, header *head);
125 extern errr parse_a_info(char *buf, header *head);
126 extern errr parse_e_info(char *buf, header *head);
127 extern errr parse_r_info(char *buf, header *head);
128 extern errr parse_d_info(char *buf, header *head);
129 extern errr parse_s_info(char *buf, header *head);
130 extern errr parse_m_info(char *buf, header *head);
131 
132 /*
133  * Error tracking
134  */
135 extern int error_idx;
136 extern int error_line;
137 
138 #endif /* ALLOW_TEMPLATES */
139 
140 
141 /*
142  * File headers
143  */
144 extern header z_head;
145 extern header v_head;
146 extern header f_head;
147 extern header k_head;
148 extern header a_head;
149 extern header e_head;
150 extern header r_head;
151 extern header p_head;
152 extern header h_head;
153 extern header b_head;
154 extern header g_head;
155 
156 #endif /* INCLUDED_INIT_H */
157 
158 extern s16b f_tag_to_index(concptr str);
160 extern void init_angband(void);
161 extern concptr get_check_sum(void);
162 extern void init_file_paths(char *path);
header e_head
アイテムエゴ情報のヘッダ構造体
Definition: init.c:296
header f_head
地形情報のヘッダ構造体
Definition: init.c:293
char * buf
Definition: chuukei.c:98
header r_head
モンスター種族情報のヘッダ構造体
Definition: init.c:297
void * info_ptr
Definition: init.h:106
const char * concptr
文字列定数用ポインタ定義 / A simple pointer (to unmodifiable strings)
Definition: h-type.h:47
errr(* parse_info_txt_func)(char *buf, header *head)
Definition: init.h:44
header b_head
errr init_info_txt(FILE *fp, char *buf, header *head, parse_info_txt_func parse_info_txt_line)
パース関数に基づいてデータファイルからデータを読み取る / Initialize an "*_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:1183
byte v_patch
Definition: init.h:94
byte v_major
Definition: init.h:92
errr parse_a_info(char *buf, header *head)
固定アーティファクト情報(a_info)のパース関数 / Initialize the "a_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:2367
header k_head
ペースアイテム情報のヘッダ構造体
Definition: init.c:294
byte v_minor
Definition: init.h:93
errr parse_d_info(char *buf, header *head)
ダンジョン情報(d_info)のパース関数 / Initialize the "d_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:3241
s16b f_tag_to_index_in_init(concptr str)
地形タグからIDを得る / Initialize quest array
Definition: init.c:1047
void init_file_paths(char *path)
各データファイルを読み取るためのパスを取得する Find the default paths to all of our important sub-directories.
Definition: init.c:104
errr parse_z_info(char *buf, header *head)
void init_angband(void)
全ゲームデータ読み込みのメインルーチン / Hack – main Angband initialization entry point
Definition: init.c:1707
errr parse_k_info(char *buf, header *head)
ベースアイテム(k_info)のパース関数 / Initialize the "k_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:2064
u16b head_size
Definition: init.h:99
int info_len
Definition: init.h:98
変愚時追加された基本事項のヘッダーファイル / The most basic "include" file.
header v_head
Vault情報のヘッダ構造体
Definition: init.c:292
int errr
エラーコードの定義 / Error codes for function return values
Definition: h-type.h:57
unsigned short u16b
Definition: h-type.h:99
header h_head
errr parse_v_info(char *buf, header *head)
Vault情報(v_info)のパース関数 / Initialize the "v_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:1252
int error_line
データ読み込み/初期化時に汎用的にエラー行数を保存するグローバル変数
Definition: init.c:250
char * text_ptr
Definition: init.h:108
errr parse_f_info(char *buf, header *head)
地形情報(f_info)のパース関数 / Initialize the "f_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:1635
STR_OFFSET tag_size
Definition: init.h:104
STR_OFFSET text_size
Definition: init.h:103
STR_OFFSET info_size
Definition: init.h:101
void(* retouch)(header *head)
Definition: init.h:113
s16b f_tag_to_index(concptr str)
地形タグからIDを得る / Convert a fake tag to a real feat index
Definition: dungeon-file.c:1914
header a_head
固定アーティファクト情報のヘッダ構造体
Definition: init.c:295
header z_head
errr parse_s_info(char *buf, header *head)
職業技能情報(s_info)のパース関数 / Initialize the "s_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:1337
u32b STR_OFFSET
テキストオフセットの型定義
Definition: h-type.h:212
header p_head
各初期データ用ヘッダ構造体 / Template file header information (see "init.c").
Definition: init.h:90
errr parse_e_info(char *buf, header *head)
アイテムエゴ情報(e_info)のパース関数 / Initialize the "e_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:2595
int error_idx
データ読み込み/初期化時に汎用的にエラーコードを保存するグローバル変数
Definition: init.c:249
header g_head
concptr get_check_sum(void)
サムチェック情報を出力 / Get check sum in string form
Definition: init.c:1933
signed short s16b
Definition: h-type.h:98
char * name_ptr
Definition: init.h:107
u16b info_num
Definition: init.h:97
parse_info_txt_func parse_info_txt
Definition: init.h:111
char * tag_ptr
Definition: init.h:109
STR_OFFSET name_size
Definition: init.h:102
byte v_extra
Definition: init.h:95
void retouch_f_info(header *head)
地形情報の各種タグからIDへ変換して結果を収める / Retouch fake tags of f_info
Definition: dungeon-file.c:1971
errr parse_m_info(char *buf, header *head)
職業魔法情報(m_info)のパース関数 / Initialize the "m_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:1421
errr parse_r_info(char *buf, header *head)
モンスター種族情報(r_info)のパース関数 / Initialize the "r_info" array, by parsing an ascii "template" file
Definition: dungeon-file.c:2840