5 * @brief 主要なマクロ定義ヘッダ / Purpose: global constants and macro definitions
8 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\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
14 * Do not edit this file unless you know *exactly* what you are doing.\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
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
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
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
38 * You have been warned.\n
43 * @brief 表示上の基本的なパネル単位(垂直方向、BLOCK_HGTの倍数で設定すること)
44 * Number of grids in each panel (vertically) Must be a multiple of BLOCK_HGT
49 * @brief 表示上の基本的なパネル単位(水平方向、BLOCK_WIDの倍数で設定すること)
50 * Number of grids in each panel (horizontally) Must be a multiple of BLOCK_WID
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.
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.
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.
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.
81 #define ARENA_DEFEATED_OLD_VER (-(MAX_SHORT)) /*<! 旧バージョンの闘技場敗北定義 */
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 /*!< 性格の最大定義数 */
87 #define MAX_MIND_POWERS 21 /*!< 超能力の数 / Mindcraft */
90 * Size of memory reserved for initialization of some arrays
92 #define FAKE_NAME_SIZE 40 * 1024L /*!< ゲーム情報の種別毎に用意される名前用バッファの容量 */
93 #define FAKE_TEXT_SIZE 150 * 1024L /*!< ゲーム情報の種別毎に用意されるテキスト用バッファの容量 */
94 #define FAKE_TAG_SIZE 10 * 1024L /*!< ゲーム情報の種別毎に用意されるタグ用バッファの容量 */
96 #define MAX_HISCORES 999 /*!< スコア情報保存の最大数 / Maximum number of high scores in the high score file */
99 * @brief プレイヤー用光源処理配列サイズ / Maximum size of the "lite" array (see "current_floor_ptr->grid_array.c")
100 * @details Note that the "lite radius" will NEVER exceed 14, and we would
101 * never require more than 581 entries in the array for circular "lite".
106 * @brief モンスター用光源処理配列サイズ / Maximum size of the "mon_lite" array (see "current_floor_ptr->grid_array.c")
107 * @details Note that the "view radius" will NEVER exceed 20, monster illumination
108 * flags are dependent on CAVE_VIEW, and even if the "view" was octagonal,
109 * we would never require more than 1520 entries in the array.
111 #define MON_LITE_MAX 1536
114 * @brief 視界処理配列サイズ / Maximum size of the "view" array (see "current_floor_ptr->grid_array.c")
115 * @details Note that the "view radius" will NEVER exceed 20, and even if the "view"
116 * was octagonal, we would never require more than 1520 entries in the array.
118 #define VIEW_MAX 1536
121 * @brief 視界及び光源の過渡処理配列サイズ / Maximum size of the "temp" array (see "current_floor_ptr->grid_array.c")
122 * @details We must be as large as "VIEW_MAX" and "LITE_MAX" for proper functioning
123 * of "update_view()" and "update_lite()". We must also be as large as the
124 * largest illuminatable room, but no room is larger than 800 grids. We
125 * must also be large enough to allow "good enough" use as a circular queue,
126 * to calculate monster flow, but note that the flow code is "paranoid".
128 #define TEMP_MAX 2298
131 * @brief 再描画処理用配列サイズ / Maximum size of the "redraw" array (see "current_floor_ptr->grid_array.c")
132 * @details We must be large for proper functioning of delayed redrawing.
133 * We must also be as large as two times of the largest view area.
134 * Note that maximum view grids are 1149 entries.
136 #define REDRAW_MAX 2298
140 * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
141 * @note Default: assume at most 256 macros are used
143 #define MACRO_MAX 256
146 * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
148 * Default: assume at most 512 different inscriptions are used<br>
149 * Was 512... 256 quarks added for random artifacts<br>
151 #define QUARK_MAX 768
154 * OPTION: Maximum number of messages to remember (see "io.c")
155 * Default: assume maximal memorization of 2048 total messages
157 #define MESSAGE_MAX 81920
160 * OPTION: Maximum space for the message text buffer (see "io.c")
161 * Default: assume that each of the 2048 messages is repeated an
162 * average of three times, and has an average length of 48
164 #define MESSAGE_BUF 655360
168 * Maximum number of "normal" pack slots, and the index of the "overflow"
169 * slot, which can hold an item, but only temporarily, since it causes the
170 * pack to "overflow", dropping the "last" item onto the ground. Since this
171 * value is used as an actual slot, it must be less than "INVEN_RARM" (below).
172 * Note that "INVEN_PACK" is probably hard-coded by its use in savefiles, and
173 * by the fact that the screen can only show 23 items plus a one-line prompt.
175 #define INVEN_PACK 23 /*!< アイテムスロット…所持品(0~) */
178 * Player sex constants (hard-coded by save-files, arrays, etc)
185 * Player class constants (hard-coded by save-files, arrays, etc)
187 #define CLASS_WARRIOR 0
189 #define CLASS_PRIEST 2
190 #define CLASS_ROGUE 3
191 #define CLASS_RANGER 4
192 #define CLASS_PALADIN 5
193 #define CLASS_WARRIOR_MAGE 6
194 #define CLASS_CHAOS_WARRIOR 7
196 #define CLASS_MINDCRAFTER 9
197 #define CLASS_HIGH_MAGE 10
198 #define CLASS_TOURIST 11
199 #define CLASS_IMITATOR 12
200 #define CLASS_BEASTMASTER 13
201 #define CLASS_SORCERER 14
202 #define CLASS_ARCHER 15
203 #define CLASS_MAGIC_EATER 16
204 #define CLASS_BARD 17
205 #define CLASS_RED_MAGE 18
206 #define CLASS_SAMURAI 19
207 #define CLASS_FORCETRAINER 20
208 #define CLASS_BLUE_MAGE 21
209 #define CLASS_CAVALRY 22
210 #define CLASS_BERSERKER 23
211 #define CLASS_SMITH 24
212 #define CLASS_MIRROR_MASTER 25
213 #define CLASS_NINJA 26
214 #define CLASS_SNIPER 27
216 #define SEIKAKU_FUTUU 0
217 #define SEIKAKU_CHIKARA 1
218 #define SEIKAKU_KIREMONO 2
219 #define SEIKAKU_SHIAWASE 3
220 #define SEIKAKU_SUBASI 4
221 #define SEIKAKU_INOCHI 5
222 #define SEIKAKU_COMBAT 6
223 #define SEIKAKU_NAMAKE 7
224 #define SEIKAKU_SEXY 8
225 #define SEIKAKU_LUCKY 9
226 #define SEIKAKU_GAMAN 10
227 #define SEIKAKU_MUNCHKIN 11
228 #define SEIKAKU_CHARGEMAN 12
230 /*** Screen Locations ***/
232 #define VER_INFO_ROW 3 //!< タイトル表記(行)
239 /* Which features are dynamic */
240 #define have_dynamic_flags(ARRAY) \
241 (!!((ARRAY)[(FF_INSTANT / 32)] & \
242 ((1UL << (FF_INSTANT % 32)) | \
243 (1UL << (FF_EXPLODE % 32)) | \
244 (1UL << (FF_TIMED % 32)) | \
245 (1UL << (FF_ERUPT % 32)) | \
246 (1UL << (FF_STRIKE % 32)) | \
247 (1UL << (FF_SPREAD % 32)))))
251 * Feature action flags
253 #define FAF_DESTROY 0x01
254 #define FAF_NO_DROP 0x02
255 #define FAF_CRASH_GLASS 0x04
258 #define DOOR_DEFAULT -1
260 #define DOOR_GLASS_DOOR 1
261 #define DOOR_CURTAIN 2
263 #define MAX_DOOR_TYPES 3
265 #define feat_locked_door_random(DOOR_TYPE) \
266 (feat_door[(DOOR_TYPE)].num_locked ? \
267 feat_door[(DOOR_TYPE)].locked[randint0(feat_door[(DOOR_TYPE)].num_locked)] : feat_none)
269 #define feat_jammed_door_random(DOOR_TYPE) \
270 (feat_door[(DOOR_TYPE)].num_jammed ? \
271 feat_door[(DOOR_TYPE)].jammed[randint0(feat_door[(DOOR_TYPE)].num_jammed)] : feat_none)
275 * Bit flags for the *_can_enter() and monster_can_cross_terrain()
277 #define CEM_RIDING 0x0001
278 #define CEM_P_CAN_ENTER_PATTERN 0x0002
281 #define OBJ_GOLD_LIST 480 /* First "gold" entry */
282 #define MAX_GOLD 18 /* Number of "gold" entries */
284 /*** General flag values ***/
287 /* Empty hand status */
288 #define EMPTY_HAND_NONE 0x0000 /* Both hands are used */
289 #define EMPTY_HAND_LARM 0x0001 /* Left hand is empty */
290 #define EMPTY_HAND_RARM 0x0002 /* Right hand is empty */
292 /*** General index values ***/
296 /*** Object flag values ***/
302 * Old variables for object flags such as flags1, flags2, and flags3
303 * are obsolated. Now single array flgs[TR_FLAG_SIZE] contains all
304 * object flags. And each flag is refered by single index number
305 * instead of a bit mask.
307 * Therefore it's very easy to add a lot of new flags; no one need to
308 * worry about in which variable a new flag should be put, nor to
309 * modify a huge number of files all over the source directory at once
310 * to add new flag variables such as flags4, a_ability_flags1, etc...
312 * All management of flags is now treated using a set of macros
313 * instead of bit operations.
314 * Note: These macros are using division, modulo, and bit shift
315 * operations, and it seems that these operations are rather slower
316 * than original bit operation. But since index numbers are almost
317 * always given as constant, such slow operations are performed in the
318 * compile time. So there is no problem on the speed.
320 * Exceptions of new flag management is a set of flags to control
321 * object generation and the curse flags. These are not yet rewritten
322 * in new index form; maybe these have no merit of rewriting.
325 #define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
326 #define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
327 #define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
328 #define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
329 #define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
334 * Hack -- "torch" masks
336 #define RF7_LITE_MASK \
337 (RF7_HAS_LITE_1 | RF7_SELF_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_2)
339 #define RF7_DARK_MASK \
340 (RF7_HAS_DARK_1 | RF7_SELF_DARK_1 | RF7_HAS_DARK_2 | RF7_SELF_DARK_2)
342 #define RF7_HAS_LD_MASK \
343 (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_HAS_DARK_1 | RF7_HAS_DARK_2)
345 #define RF7_SELF_LD_MASK \
346 (RF7_SELF_LITE_1 | RF7_SELF_LITE_2 | RF7_SELF_DARK_1 | RF7_SELF_DARK_2)
349 * Hack -- effective elemental and poison immunity mask
351 #define RFR_EFF_IM_ACID_MASK (RFR_IM_ACID | RFR_RES_ALL)
352 #define RFR_EFF_IM_ELEC_MASK (RFR_IM_ELEC | RFR_RES_ALL)
353 #define RFR_EFF_IM_FIRE_MASK (RFR_IM_FIRE | RFR_RES_ALL)
354 #define RFR_EFF_IM_COLD_MASK (RFR_IM_COLD | RFR_RES_ALL)
355 #define RFR_EFF_IM_POIS_MASK (RFR_IM_POIS | RFR_RES_ALL)
356 #define RFR_EFF_RES_SHAR_MASK (RFR_RES_SHAR | RFR_RES_ALL)
357 #define RFR_EFF_RES_CHAO_MASK (RFR_RES_CHAO | RFR_RES_ALL)
358 #define RFR_EFF_RES_NEXU_MASK (RFR_RES_NEXU | RFR_RES_ALL)
361 #define MR1_SINKA 0x01
365 * Is the monster seen by the player?
368 ((bool)((A)->ml && (!ignore_unview || p_ptr->inside_battle || \
369 (player_can_see_bold((A)->fy, (A)->fx) && projectable(p_ptr->y, p_ptr->x, (A)->fy, (A)->fx)))))
372 /*** Macro Definitions ***/
374 * Convert an "attr"/"char" pair into a "pict" (P)
377 ((((u16b)(A)) << 8) | ((byte)(C)))
380 * Convert a "pict" (P) into an "attr" (A)
386 * Convert a "pict" (P) into an "char" (C)
393 * Hack -- Prepare to use the "Secure" routines
395 #if defined(SET_UID) && defined(SECURE)
396 extern int PlayerUID;
397 # define getuid() PlayerUID
398 # define geteuid() PlayerUID
403 /*** Color constants ***/
406 * Not using graphical tiles for this feature?
408 #define is_ascii_graphics(A) (!((A) & 0x80))
415 * Hack -- attempt to reduce various values
419 # define MACRO_MAX 128
421 # define QUARK_MAX 128
423 # define MESSAGE_MAX 128
425 # define MESSAGE_BUF 4096
433 * Available graphic modes
435 #define GRAPHICS_NONE 0
436 #define GRAPHICS_ORIGINAL 1
437 #define GRAPHICS_ADAM_BOLT 2
438 #define GRAPHICS_HENGBAND 3
448 * Modes for the tokenizer
450 #define TOKENIZE_CHECKQUOTE 0x01 /* Special handling of single quotes */
455 #define SECRET_TOWN 5
459 #define MAX_MONSPELLS 96
460 #define MONSPELL_TYPE_BOLT 1
461 #define MONSPELL_TYPE_BALL 2
462 #define MONSPELL_TYPE_BREATH 3
463 #define MONSPELL_TYPE_SUMMON 4
464 #define MONSPELL_TYPE_OTHER 5
467 #define EATER_CHARGE 0x10000L
468 #define EATER_ROD_CHARGE 0x10L
471 #define DETECT_RAD_DEFAULT 30
472 #define DETECT_RAD_MAP 30
473 #define DETECT_RAD_ALL 255
475 /* Maximum "Nazguls" number */
476 #define MAX_NAZGUL_NUM 5
478 #define DO_AUTOPICK 0x01
479 #define DO_AUTODESTROY 0x02
480 #define DO_DISPLAY 0x04
481 #define DONT_AUTOPICK 0x08
482 #define ITEM_DISPLAY 0x10
483 #define DO_QUERY_AUTOPICK 0x20
485 #define VIRTUE_LARGE 1
486 #define VIRTUE_SMALL 2
488 #define SPELL_DD_S 27
489 #define SPELL_DD_T 13
491 #define SPELL_KABE 20
493 #define KNOW_STAT 0x01
494 #define KNOW_HPRATE 0x02
498 #define DUNGEON_FEAT_PROB_NUM 3
501 * Flags for save/load temporal saved floor file
503 #define SLF_SECOND 0x0001 /* Called from another save/load function */
504 #define SLF_NO_KILL 0x0002 /* Don't kill temporal files */
507 #define prace_is_(A) (!p_ptr->mimic_form && (p_ptr->prace == A))
509 /* Sub-alignment flags for neutral monsters */
510 #define SUB_ALIGN_NEUTRAL 0x0000
511 #define SUB_ALIGN_EVIL 0x0001
512 #define SUB_ALIGN_GOOD 0x0002
514 /* Multishadow effects is determined by current_world_ptr->game_turn */
515 #define CHECK_MULTISHADOW() (p_ptr->multishadow && (current_world_ptr->game_turn & 1))
517 /* Is "teleport level" ineffective to this target? */
518 #define TELE_LEVEL_IS_INEFF(TARGET) \
519 (p_ptr->inside_arena || p_ptr->inside_battle || \
520 (p_ptr->inside_quest && !random_quest_number(current_floor_ptr->dun_level)) || \
521 (((TARGET) <= 0) && (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) && \
522 (current_floor_ptr->dun_level >= 1) && ironman_downward))
526 * Max numbers of macro trigger names
528 #define MAX_MACRO_MOD 12
529 #define MAX_MACRO_TRIG 200 /*!< 登録を許すマクロ(トリガー)の最大数 */
531 /* Max size of screen dump buffer */
532 #define SCREEN_BUF_MAX_SIZE (4 * 65536)
534 #define MTIMED_CSLEEP 0 /* Monster is sleeping */
535 #define MTIMED_FAST 1 /* Monster is temporarily fast */
536 #define MTIMED_SLOW 2 /* Monster is temporarily slow */
537 #define MTIMED_STUNNED 3 /* Monster is stunned */
538 #define MTIMED_CONFUSED 4 /* Monster is confused */
539 #define MTIMED_MONFEAR 5 /* Monster is afraid */
540 #define MTIMED_INVULNER 6 /* Monster is temporarily invulnerable */
544 #define MON_CSLEEP(M_PTR) ((M_PTR)->mtimed[MTIMED_CSLEEP])
545 #define MON_FAST(M_PTR) ((M_PTR)->mtimed[MTIMED_FAST])
546 #define MON_SLOW(M_PTR) ((M_PTR)->mtimed[MTIMED_SLOW])
547 #define MON_STUNNED(M_PTR) ((M_PTR)->mtimed[MTIMED_STUNNED])
548 #define MON_CONFUSED(M_PTR) ((M_PTR)->mtimed[MTIMED_CONFUSED])
549 #define MON_MONFEAR(M_PTR) ((M_PTR)->mtimed[MTIMED_MONFEAR])
550 #define MON_INVULNER(M_PTR) ((M_PTR)->mtimed[MTIMED_INVULNER])
553 * Bit flags for screen_object()
555 #define SCROBJ_FAKE_OBJECT 0x00000001
556 #define SCROBJ_FORCE_DETAIL 0x00000002
559 * For travel command (auto run)
563 #define CONCENT_RADAR_THRESHOLD 2
564 #define CONCENT_TELE_THRESHOLD 5
567 #define hex_spelling_any() \
568 ((p_ptr->realm1 == REALM_HEX) && (p_ptr->magic_num1[0]))
569 #define hex_spelling(X) \
570 ((p_ptr->realm1 == REALM_HEX) && (p_ptr->magic_num1[0] & (1L << (X))))
571 #define CASTING_HEX_FLAGS(P_PTR) ((P_PTR)->magic_num1[0])
572 #define CASTING_HEX_NUM(P_PTR) ((P_PTR)->magic_num2[0])
573 #define HEX_REVENGE_POWER(P_PTR) ((P_PTR)->magic_num1[2])
574 #define HEX_REVENGE_TURN(P_PTR) ((P_PTR)->magic_num2[2])
575 #define HEX_REVENGE_TYPE(P_PTR) ((P_PTR)->magic_num2[1])
578 Language selection macro
581 #define _(JAPANESE,ENGLISH) (JAPANESE)
583 #define _(JAPANESE,ENGLISH) (ENGLISH)
586 /* Lite flag macro */
587 #define have_lite_flag(ARRAY) \
588 (have_flag(ARRAY, TR_LITE_1) || have_flag(ARRAY, TR_LITE_2) || have_flag(ARRAY, TR_LITE_3))
590 #define have_dark_flag(ARRAY) \
591 (have_flag(ARRAY, TR_LITE_M1) || have_flag(ARRAY, TR_LITE_M2) || have_flag(ARRAY, TR_LITE_M3))
593 /* Spell Type flag */
594 #define MONSTER_TO_PLAYER 0x01
595 #define MONSTER_TO_MONSTER 0x02
597 /* summoning number */
598 #define S_NUM_6 (easy_band ? 2 : 6)
599 #define S_NUM_4 (easy_band ? 1 : 4)
601 /* monster spell number */
602 #define RF4_SPELL_START 32 * 3
603 #define RF5_SPELL_START 32 * 4
604 #define RF6_SPELL_START 32 * 5
606 #define RF4_SPELL_SIZE 32
607 #define RF5_SPELL_SIZE 32
608 #define RF6_SPELL_SIZE 32
610 /* Spell Damage Calc Flag*/
620 /* Cheat Info Type */
621 #define CHEAT_OBJECT 0
622 #define CHEAT_MONSTER 1
623 #define CHEAT_DUNGEON 2
626 #define COMMAND_ARG_REST_UNTIL_DONE -2 /*!<休憩コマンド引数 … 必要な分だけ回復 */
627 #define COMMAND_ARG_REST_FULL_HEALING -1 /*!<休憩コマンド引数 … HPとMPが全回復するまで */
630 * チートオプションの最大数 / Number of cheating options