OSDN Git Service

[Refactor] #37353 MAC_MPWのプリプロを削除 (CARBON と MACH_O_CARBONは保留) / Removed preprocessor...
[hengband/hengband.git] / src / util.h
index 01d6027..96224ca 100644 (file)
@@ -1,12 +1,94 @@
-#pragma once
+#pragma once
 
-#define KEYMAP_MODE_ORIG       0 /*!< \83I\83\8a\83W\83i\83\8b\83L\81[\94z\92u / Mode for original keyset commands */
-#define KEYMAP_MODE_ROGUE      1 /*!< \83\8d\81[\83O\83\89\83C\83N\83L\81[\94z\92u / Mode for roguelike keyset commands */
-#define KEYMAP_MODES           2 /*!< \83L\81[\94z\92u\82Ì\90\94 / Number of keymap modes */
+#include "geometry.h"
 
 /*
- * Sort-array element
+ * Hack -- allow use of "ASCII" and "EBCDIC" for "indexes", "digits",
+ * and "Control-Characters".
+ *
+ * Note that all "index" values must be "lowercase letters", while
+ * all "digits" must be "digits".  Control characters can be made
+ * from any legal characters.
+ */
+#define A2I(X) ((X) - 'a')
+#define I2A(X) ((char)(X) + 'a')
+#define D2I(X) ((X) - '0')
+#define I2D(X) ((X) + '0')
+#define KTRL(X)        ((X) & 0x1F)
+#define ESCAPE '\033'
+
+ /*
+  * Hack -- Prepare to use the "Secure" routines
+  */
+#if defined(SET_UID) && defined(SECURE)
+extern int PlayerUID;
+# define getuid() PlayerUID
+# define geteuid() PlayerUID
+#endif
+
+#define KEYMAP_MODE_ORIG       0 /*!< オリジナルキー配置 / Mode for original keyset commands */
+#define KEYMAP_MODE_ROGUE      1 /*!< ローグライクキー配置 / Mode for roguelike keyset commands */
+#define KEYMAP_MODES           2 /*!< キー配置の数 / Number of keymap modes */
+
+#define SCREEN_BUF_MAX_SIZE (4 * 65536) /*!< Max size of screen dump buffer */
+
+/* Cheat Info Type */
+#define CHEAT_OBJECT 0
+#define CHEAT_MONSTER 1
+#define CHEAT_DUNGEON 2
+#define CHEAT_MISC 3
+
+/*
+ * Max numbers of macro trigger names
  */
+#define MAX_MACRO_MOD 12
+#define MAX_MACRO_TRIG 200 /*!< 登録を許すマクロ(トリガー)の最大数 */
+
+ /*
+  * Object flags
+  *
+  * Old variables for object flags such as flags1, flags2, and flags3
+  * are obsolated.  Now single array flgs[TR_FLAG_SIZE] contains all
+  * object flags.  And each flag is refered by single index number
+  * instead of a bit mask.
+  *
+  * Therefore it's very easy to add a lot of new flags; no one need to
+  * worry about in which variable a new flag should be put, nor to
+  * modify a huge number of files all over the source directory at once
+  * to add new flag variables such as flags4, a_ability_flags1, etc...
+  *
+  * All management of flags is now treated using a set of macros
+  * instead of bit operations.
+  * Note: These macros are using division, modulo, and bit shift
+  * operations, and it seems that these operations are rather slower
+  * than original bit operation.  But since index numbers are almost
+  * always given as constant, such slow operations are performed in the
+  * compile time.  So there is no problem on the speed.
+  *
+  * Exceptions of new flag management is a set of flags to control
+  * object generation and the curse flags.  These are not yet rewritten
+  * in new index form; maybe these have no merit of rewriting.
+  */
+
+#define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
+#define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
+#define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
+#define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
+#define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
+
+  /*
+       Language selection macro
+  */
+#ifdef JP
+#define _(JAPANESE,ENGLISH) (JAPANESE)
+#else
+#define _(JAPANESE,ENGLISH) (ENGLISH)
+#endif
+
+
+  /*
+  * Sort-array element
+  */
 typedef struct tag_type tag_type;
 
 struct tag_type
@@ -59,6 +141,12 @@ extern bool inkey_xtra;
 extern bool inkey_scan;
 extern bool inkey_flag;
 
+extern bool use_menu;
+
+extern pos_list tmp_pos;
+
+extern STR_OFFSET quark__num;
+extern concptr *quark__str;
 /*
  * Automatically generated "variable" declarations
  */
@@ -103,7 +191,7 @@ extern concptr keymap_act[KEYMAP_MODES][256];
 #define MUSIC_BASIC_QUEST_CLEAR 18
 #define MUSIC_BASIC_FINAL_QUEST_CLEAR 19
 #define MUSIC_BASIC_AMBUSH    20
-#define MUSIC_BASIC_MAX       21 /*!< BGM\92è\8b`\82Ì\8dÅ\91å\90\94 */
+#define MUSIC_BASIC_MAX       21 /*!< BGM定義の最大数 */
 
 /*** Sound constants ***/
 
@@ -182,35 +270,84 @@ extern concptr keymap_act[KEYMAP_MODES][256];
  /*
   * Mega-Hack -- maximum known sounds
   */
-#define SOUND_MAX 67 /*!< \8cø\89Ê\89¹\92è\8b`\82Ì\8dÅ\91å\90\94 */
-
-
-/*
- * Hack -- The main "screen"
- */
+#define SOUND_MAX 67 /*!< 効果音定義の最大数 */
+
+  /*!
+   * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
+   * @note
+   * Default: assume at most 512 different inscriptions are used<br>
+   * Was 512... 256 quarks added for random artifacts<br>
+   */
+#define QUARK_MAX       768
+
+   /*
+       * OPTION: Maximum number of messages to remember (see "io.c")
+       * Default: assume maximal memorization of 2048 total messages
+       */
+#define MESSAGE_MAX  81920
+
+       /*
+        * OPTION: Maximum space for the message text buffer (see "io.c")
+        * Default: assume that each of the 2048 messages is repeated an
+        * average of three times, and has an average length of 48
+        */
+#define MESSAGE_BUF 655360
+
+        /*
+         * Hack -- The main "screen"
+         */
 #define term_screen     (angband_term[0])
 
-/*
- * Hack -- conditional (or "bizarre") externs
- */
+         /*
         * Hack -- conditional (or "bizarre") externs
         */
 
 #ifdef SET_UID
 extern void user_name(char *buf, int id);
 #endif
 
-#if 0
-#ifndef HAS_STRICMP
-extern int stricmp(concptr a, concptr b);
+#ifndef HAVE_USLEEP
+extern int usleep(huge usecs);
 #endif
+
+#if defined(MACH_O_CARBON)
+extern void fsetfileinfo(concptr path, u32b fcreator, u32b ftype);
 #endif
 
-#ifndef HAVE_USLEEP
-extern int usleep(huge usecs);
+#if defined(MACH_O_CARBON)
+/* Globals needed */
+extern  u32b _ftype;
+extern  u32b _fcreator;
+#endif
+
+/*
+ * Hack -- force definitions -- see fd_seek()
+ */
+#ifndef SEEK_SET
+# define SEEK_SET      0
+#endif
+#ifndef SEEK_CUR
+# define SEEK_CUR      1
+#endif
+#ifndef SEEK_END
+# define SEEK_END      2
+#endif
+
+ /*
+  * Hack -- force definitions -- see fd_lock()
+  */
+#ifndef F_UNLCK
+# define F_UNLCK       0
+#endif
+#ifndef F_RDLCK
+# define F_RDLCK       1
+#endif
+#ifndef F_WRLCK
+# define F_WRLCK       2
 #endif
 
 extern const char hexsym[16];
 
-/* util.c */
 extern errr path_parse(char *buf, int max, concptr file);
 extern errr path_build(char *buf, int max, concptr path, concptr file);
 extern FILE *my_fopen(concptr file, concptr mode);
@@ -232,7 +369,7 @@ extern errr fd_close(int fd);
 extern void flush(void);
 extern void bell(void);
 extern errr play_music(int type, int num);
-extern void select_floor_music(void);
+extern void select_floor_music(player_type *player_ptr);
 extern void sound(int num);
 extern void move_cursor(int row, int col);
 extern void text_to_ascii(char *buf, concptr str);
@@ -253,8 +390,8 @@ extern void msg_print_wizard(int cheat_type, concptr msg);
 extern void msg_format(concptr fmt, ...);
 extern void msg_format_wizard(int cheat_type, concptr fmt, ...);
 #endif /* SWIG */
-extern void screen_save(void);
-extern void screen_load(void);
+extern void screen_save();
+extern void screen_load();
 extern void c_put_str(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
 extern void put_str(concptr str, TERM_LEN row, TERM_LEN col);
 extern void c_prt(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
@@ -279,7 +416,7 @@ extern bool get_check_strict(concptr prompt, BIT_FLAGS mode);
 extern bool get_com(concptr prompt, char *command, bool z_escape);
 extern QUANTITY get_quantity(concptr prompt, QUANTITY max);
 extern void pause_line(int row);
-extern void request_command(int shopping);
+extern void request_command(player_type *player_ptr, int shopping);
 extern bool is_a_vowel(int ch);
 extern int get_keymap_dir(char ch);
 extern errr type_string(concptr str, uint len);