OSDN Git Service

[Refactor] #37353 VIEW_MAX を floor.h へ移動.
[hengband/hengband.git] / src / defines.h
1 #pragma once
2
3 /*!
4  *  @file defines.h
5  *  @brief 主要なマクロ定義ヘッダ / Purpose: global constants and macro definitions
6  *  @date 2014/01/02
7  *  @author
8  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
9  *\n
10  * This software may be copied and distributed for educational, research,\n
11  * and not for profit purposes provided that this copyright and statement\n
12  * are included in all such copies.  Other copyrights may also apply.\n
13  *  @details
14  * Do not edit this file unless you know *exactly* what you are doing.\n
15  *\n
16  * Some of the values in this file were chosen to preserve game balance,\n
17  * while others are hard-coded based on the format of old save-files, the\n
18  * definition of arrays in various places, mathematical properties, fast\n
19  * computation, storage limits, or the format of external text files.\n
20  *\n
21  * Changing some of these values will induce crashes or memory errors or\n
22  * savefile mis-reads.  Most of the comments in this file are meant as\n
23  * reminders, not complete descriptions, and even a complete knowledge\n
24  * of the source may not be sufficient to fully understand the effects\n
25  * of changing certain definitions.\n
26  *\n
27  * Lastly, note that the code does not always use the symbolic constants\n
28  * below, and sometimes uses various hard-coded values that may not even\n
29  * be defined in this file, but which may be related to definitions here.\n
30  * This is of course bad programming practice, but nobody is perfect...\n
31  *\n
32  * For example, there are MANY things that depend on the screen being\n
33  * 80x24, with the top line used for messages, the bottom line being\n
34  * used for status, and exactly 22 lines used to show the dungeon.\n
35  * Just because your screen can hold 46 lines does not mean that the\n
36  * game will work if you try to use 44 lines to show the dungeon.\n
37  *\n
38  * You have been warned.\n
39  */
40
41
42 /*!
43  * @brief 表示上の基本的なパネル単位(垂直方向、BLOCK_HGTの倍数で設定すること)
44  * Number of grids in each panel (vertically) Must be a multiple of BLOCK_HGT
45  */
46 #define PANEL_HGT 11
47
48 /*!
49  * @brief 表示上の基本的なパネル単位(水平方向、BLOCK_WIDの倍数で設定すること)
50  * Number of grids in each panel (horizontally) Must be a multiple of BLOCK_WID
51  */
52 #define PANEL_WID 33
53
54 /*!
55  * @brief 表示上の基本的なブロック単位(垂直方向、PANEL_HGTの倍数で設定すること)
56  * Number of grids used to display the dungeon (vertically). Must be a multiple of 11, probably hard-coded to 22.
57  */
58 #define SCREEN_HGT 22
59
60 /*!
61  * @brief 表示上の基本的なブロック単位(水平方向、PANEL_WIDの倍数で設定すること)
62  * Number of grids used to display the dungeon (horizontally). Must be a multiple of 33, probably hard-coded to 66.
63  */
64 #define SCREEN_WID 66
65
66 /*!
67  * @brief 表示上のダンジョンの最大垂直サイズ(SCREEN_HGTの3倍が望ましい)
68  * Maximum dungeon height in grids, must be a multiple of SCREEN_HGT, probably hard-coded to SCREEN_HGT * 3.
69  */
70 #define MAX_HGT 66
71
72 /*!
73  * @brief 表示上のダンジョンの最大水平サイズ(SCREEN_WIDの3倍が望ましい)
74  * Maximum dungeon width in grids, must be a multiple of SCREEN_WID, probably hard-coded to SCREEN_WID * 3.
75  */
76 #define MAX_WID 198
77
78 /*
79  * Arena constants
80  */
81 #define ARENA_DEFEATED_OLD_VER (-(MAX_SHORT)) /*<! 旧バージョンの闘技場敗北定義 */
82
83 #define MAX_SEXES        2 /*!< 性別の定義最大数 / Maximum number of player "sex" types (see "table.c", etc) */
84 #define MAX_CLASS       28 /*!< 職業の最大定義数 Maximum number of player "class" types (see "table.c", etc) */
85 #define MAX_SEIKAKU     13 /*!< 性格の最大定義数 */
86
87 #define MAX_MIND_POWERS  21 /*!< 超能力の数 / Mindcraft */
88
89 /*!
90  * @brief 視界及び光源の過渡処理配列サイズ / Maximum size of the "temp" array (see "current_floor_ptr->grid_array.c")
91  * @details We must be as large as "VIEW_MAX" and "LITE_MAX" for proper functioning
92  * of "update_view()" and "update_lite()".  We must also be as large as the
93  * largest illuminatable room, but no room is larger than 800 grids.  We
94  * must also be large enough to allow "good enough" use as a circular queue,
95  * to calculate monster flow, but note that the flow code is "paranoid".
96  */
97 #define TEMP_MAX 2298
98
99 /*!
100  * @brief 再描画処理用配列サイズ / Maximum size of the "redraw" array (see "current_floor_ptr->grid_array.c")
101  * @details We must be large for proper functioning of delayed redrawing.
102  * We must also be as large as two times of the largest view area.
103  * Note that maximum view grids are 1149 entries.
104  */
105 #define REDRAW_MAX 2298
106
107
108 /*!
109  * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
110  * @note Default: assume at most 256 macros are used
111  */
112 #define MACRO_MAX       256
113
114 /*!
115  * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
116  * @note 
117  * Default: assume at most 512 different inscriptions are used<br>
118  * Was 512... 256 quarks added for random artifacts<br>
119  */
120 #define QUARK_MAX       768
121
122 /*
123  * OPTION: Maximum number of messages to remember (see "io.c")
124  * Default: assume maximal memorization of 2048 total messages
125  */
126 #define MESSAGE_MAX  81920
127
128 /*
129  * OPTION: Maximum space for the message text buffer (see "io.c")
130  * Default: assume that each of the 2048 messages is repeated an
131  * average of three times, and has an average length of 48
132  */
133 #define MESSAGE_BUF 655360
134
135
136 /*
137  * Maximum number of "normal" pack slots, and the index of the "overflow"
138  * slot, which can hold an item, but only temporarily, since it causes the
139  * pack to "overflow", dropping the "last" item onto the ground.  Since this
140  * value is used as an actual slot, it must be less than "INVEN_RARM" (below).
141  * Note that "INVEN_PACK" is probably hard-coded by its use in savefiles, and
142  * by the fact that the screen can only show 23 items plus a one-line prompt.
143  */
144 #define INVEN_PACK      23 /*!< アイテムスロット…所持品(0~) */
145
146 /*
147  * Player sex constants (hard-coded by save-files, arrays, etc)
148  */
149 #define SEX_FEMALE              0
150 #define SEX_MALE                1
151
152 /*** Screen Locations ***/
153
154 #define VER_INFO_ROW 3   //!< タイトル表記(行)
155
156
157 #define ROW_MAP                 0
158 #define COL_MAP                 12
159
160
161 /* Which features are dynamic */
162 #define have_dynamic_flags(ARRAY) \
163         (!!((ARRAY)[(FF_INSTANT / 32)] & \
164             ((1UL << (FF_INSTANT % 32)) | \
165              (1UL << (FF_EXPLODE % 32)) | \
166              (1UL << (FF_TIMED % 32)) | \
167              (1UL << (FF_ERUPT % 32)) | \
168              (1UL << (FF_STRIKE % 32)) | \
169              (1UL << (FF_SPREAD % 32)))))
170
171 #define feat_locked_door_random(DOOR_TYPE) \
172         (feat_door[(DOOR_TYPE)].num_locked ? \
173          feat_door[(DOOR_TYPE)].locked[randint0(feat_door[(DOOR_TYPE)].num_locked)] : feat_none)
174
175 #define feat_jammed_door_random(DOOR_TYPE) \
176         (feat_door[(DOOR_TYPE)].num_jammed ? \
177          feat_door[(DOOR_TYPE)].jammed[randint0(feat_door[(DOOR_TYPE)].num_jammed)] : feat_none)
178
179
180 /*
181  * Bit flags for the *_can_enter() and monster_can_cross_terrain()
182  */
183 #define CEM_RIDING              0x0001
184 #define CEM_P_CAN_ENTER_PATTERN 0x0002
185
186
187 #define OBJ_GOLD_LIST   480     /* First "gold" entry */
188 #define MAX_GOLD        18      /* Number of "gold" entries */
189
190 /*
191  * Object flags
192  *
193  * Old variables for object flags such as flags1, flags2, and flags3
194  * are obsolated.  Now single array flgs[TR_FLAG_SIZE] contains all
195  * object flags.  And each flag is refered by single index number
196  * instead of a bit mask.
197  *
198  * Therefore it's very easy to add a lot of new flags; no one need to
199  * worry about in which variable a new flag should be put, nor to
200  * modify a huge number of files all over the source directory at once
201  * to add new flag variables such as flags4, a_ability_flags1, etc...
202  *
203  * All management of flags is now treated using a set of macros
204  * instead of bit operations.
205  * Note: These macros are using division, modulo, and bit shift
206  * operations, and it seems that these operations are rather slower
207  * than original bit operation.  But since index numbers are almost
208  * always given as constant, such slow operations are performed in the
209  * compile time.  So there is no problem on the speed.
210  *
211  * Exceptions of new flag management is a set of flags to control
212  * object generation and the curse flags.  These are not yet rewritten
213  * in new index form; maybe these have no merit of rewriting.
214  */
215
216 #define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
217 #define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
218 #define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
219 #define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
220 #define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
221
222 /*
223  * Is the monster seen by the player?
224  */
225 #define is_seen(A) \
226         ((bool)((A)->ml && (!ignore_unview || p_ptr->inside_battle || \
227          (player_can_see_bold((A)->fy, (A)->fx) && projectable(p_ptr->y, p_ptr->x, (A)->fy, (A)->fx)))))
228
229
230 /*** Color constants ***/
231
232
233 /*
234  * Hack -- attempt to reduce various values
235  */
236 #ifdef ANGBAND_LITE
237 # undef MACRO_MAX
238 # define MACRO_MAX      128
239 # undef QUARK_MAX
240 # define QUARK_MAX      128
241 # undef MESSAGE_MAX
242 # define MESSAGE_MAX    128
243 # undef MESSAGE_BUF
244 # define MESSAGE_BUF    4096
245 #endif
246
247 #ifdef JP
248 #define JVERB_AND 1
249 #define JVERB_TO  2
250 #define JVERB_OR  3
251 #endif
252
253 /*
254  * Modes for the tokenizer
255  */
256
257
258 #define MAX_MANE 16
259
260
261 #define EATER_EXT 36
262 #define EATER_CHARGE 0x10000L
263 #define EATER_ROD_CHARGE 0x10L
264
265
266 #define DETECT_RAD_DEFAULT 30
267 #define DETECT_RAD_MAP     30
268 #define DETECT_RAD_ALL     255
269
270 /* Maximum "Nazguls" number */
271 #define MAX_NAZGUL_NUM 5
272
273 #define VIRTUE_LARGE 1
274 #define VIRTUE_SMALL 2
275
276 #define SPELL_DD_S 27
277 #define SPELL_DD_T 13
278 #define SPELL_SW   22
279 #define SPELL_KABE 20
280
281 #define KNOW_STAT   0x01
282 #define KNOW_HPRATE 0x02
283
284
285
286 #define DUNGEON_FEAT_PROB_NUM 3
287
288 /*
289  * Flags for save/load temporal saved floor file
290  */
291 #define SLF_SECOND       0x0001  /* Called from another save/load function */
292 #define SLF_NO_KILL      0x0002  /* Don't kill temporal files */
293
294 /*
295  * Max numbers of macro trigger names
296  */
297 #define MAX_MACRO_MOD 12
298 #define MAX_MACRO_TRIG 200 /*!< 登録を許すマクロ(トリガー)の最大数 */
299
300 /* Max size of screen dump buffer */
301 #define SCREEN_BUF_MAX_SIZE (4 * 65536)
302
303 #define MTIMED_CSLEEP   0 /* Monster is sleeping */
304 #define MTIMED_FAST     1 /* Monster is temporarily fast */
305 #define MTIMED_SLOW     2 /* Monster is temporarily slow */
306 #define MTIMED_STUNNED  3 /* Monster is stunned */
307 #define MTIMED_CONFUSED 4 /* Monster is confused */
308 #define MTIMED_MONFEAR  5 /* Monster is afraid */
309 #define MTIMED_INVULNER 6 /* Monster is temporarily invulnerable */
310
311 #define MAX_MTIMED      7
312
313 #define MON_CSLEEP(M_PTR)   ((M_PTR)->mtimed[MTIMED_CSLEEP])
314 #define MON_FAST(M_PTR)     ((M_PTR)->mtimed[MTIMED_FAST])
315 #define MON_SLOW(M_PTR)     ((M_PTR)->mtimed[MTIMED_SLOW])
316 #define MON_STUNNED(M_PTR)  ((M_PTR)->mtimed[MTIMED_STUNNED])
317 #define MON_CONFUSED(M_PTR) ((M_PTR)->mtimed[MTIMED_CONFUSED])
318 #define MON_MONFEAR(M_PTR)  ((M_PTR)->mtimed[MTIMED_MONFEAR])
319 #define MON_INVULNER(M_PTR) ((M_PTR)->mtimed[MTIMED_INVULNER])
320
321 /*
322  * For travel command (auto run)
323  */
324 #define TRAVEL
325
326 #define CONCENT_RADAR_THRESHOLD 2
327 #define CONCENT_TELE_THRESHOLD  5
328
329 /*
330   Language selection macro
331 */
332 #ifdef JP
333 #define _(JAPANESE,ENGLISH) (JAPANESE)
334 #else
335 #define _(JAPANESE,ENGLISH) (ENGLISH)
336 #endif
337
338 /* Lite flag macro */
339 #define have_lite_flag(ARRAY) \
340         (have_flag(ARRAY, TR_LITE_1) || have_flag(ARRAY, TR_LITE_2) || have_flag(ARRAY, TR_LITE_3))
341
342 #define have_dark_flag(ARRAY) \
343         (have_flag(ARRAY, TR_LITE_M1) || have_flag(ARRAY, TR_LITE_M2) || have_flag(ARRAY, TR_LITE_M3))
344
345 /* Cheat Info Type */
346 #define CHEAT_OBJECT 0
347 #define CHEAT_MONSTER 1
348 #define CHEAT_DUNGEON 2
349 #define CHEAT_MISC 3
350
351 #define COMMAND_ARG_REST_UNTIL_DONE -2   /*!<休憩コマンド引数 … 必要な分だけ回復 */
352 #define COMMAND_ARG_REST_FULL_HEALING -1 /*!<休憩コマンド引数 … HPとMPが全回復するまで */
353
354 /*!
355  * チートオプションの最大数 / Number of cheating options
356  */
357 #define CHEAT_MAX 10