OSDN Git Service

[Refactor] #37353 MAC_MPWのプリプロを削除 (CARBON と MACH_O_CARBONは保留) / Removed preprocessor...
[hengband/hengband.git] / src / util.h
index f9ca5df..96224ca 100644 (file)
@@ -1,17 +1,34 @@
-#pragma once
+#pragma once
+
+#include "geometry.h"
 
 /*
- * Hack -- Prepare to use the "Secure" routines
+ * 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 /*!< \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 */
+#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 */
 
@@ -25,33 +42,33 @@ extern int PlayerUID;
  * Max numbers of macro trigger names
  */
 #define MAX_MACRO_MOD 12
-#define MAX_MACRO_TRIG 200 /*!< \93o\98^\82ð\8b\96\82·\83}\83N\83\8d\81i\83g\83\8a\83K\81[\81j\82Ì\8dÅ\91å\90\94 */
+#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.
- */
+ /*
 * 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)))
@@ -59,9 +76,9 @@ extern int PlayerUID;
 #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
- */
 /*
+       Language selection macro
 */
 #ifdef JP
 #define _(JAPANESE,ENGLISH) (JAPANESE)
 #else
@@ -69,9 +86,9 @@ extern int PlayerUID;
 #endif
 
 
- /*
- * Sort-array element
- */
 /*
 * Sort-array element
 */
 typedef struct tag_type tag_type;
 
 struct tag_type
@@ -128,6 +145,8 @@ extern bool use_menu;
 
 extern pos_list tmp_pos;
 
+extern STR_OFFSET quark__num;
+extern concptr *quark__str;
 /*
  * Automatically generated "variable" declarations
  */
@@ -172,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 ***/
 
@@ -248,69 +267,85 @@ extern concptr keymap_act[KEYMAP_MODES][256];
 #define SOUND_GLASS     65 /*!< A glass feature was crashed */
 #define SOUND_REFLECT   66 /*!< A bolt was reflected */
 
-/*
- * Mega-Hack -- maximum known sounds
- */
-#define SOUND_MAX 67 /*!< \8cø\89Ê\89¹\92è\8b`\82Ì\8dÅ\91å\90\94 */
-
-/*!
* @brief \96Á\8fî\95ñ\82Ì\8dÅ\91å\90\94 / 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>
- */
+ /*
 * Mega-Hack -- maximum known sounds
 */
+#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
- */
+   /*
      * 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
- */
+       /*
       * 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"
- */
+        /*
        * 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);
-#endif
-#endif
-
 #ifndef HAVE_USLEEP
 extern int usleep(huge usecs);
 #endif
 
-#if defined(MAC_MPW) && defined(CARBON)
-extern void convert_pathname(char *path);
-#endif
-
 #if defined(MACH_O_CARBON)
 extern void fsetfileinfo(concptr path, u32b fcreator, u32b ftype);
 #endif
 
-#if defined(MAC_MPW) || defined(MACH_O_CARBON)
+#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];
 
 extern errr path_parse(char *buf, int max, concptr file);
@@ -334,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);
@@ -355,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);
@@ -381,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);