3 * @brief ゲーム中に用いる変数型定義 /
10 * Note the attempt to make all basic types have 4 letters.
11 * This improves readibility and standardizes the code.
12 * Likewise, all complex types are at least 4 letters.
13 * Thus, almost every three letter word is a legal variable.
14 * But beware of certain reserved words ('for' and 'if' and 'do').
15 * Note that the type used in structures for bit flags should be uint.
16 * As long as these bit flags are sequential, they will be space smart.
17 * Note that on some machines, apparently "signed char" is illegal.
18 * It must be true that char/byte takes exactly 1 byte
19 * It must be true that sind/uind takes exactly 2 bytes
20 * It must be true that sbig/ubig takes exactly 4 bytes
21 * On Sparc's, a sint takes 4 bytes (2 is legal)
22 * On Sparc's, a uint takes 4 bytes (2 is legal)
23 * On Sparc's, a long takes 4 bytes (8 is legal)
24 * On Sparc's, a huge takes 4 bytes (8 is legal)
25 * On Sparc's, a vptr takes 4 bytes (8 is legal)
26 * On Sparc's, a real takes 8 bytes (4 is legal)
27 * Note that some files have already been included by "h-include.h"
28 * These include <stdio.h> and <sys/types>, which define some types
29 * In particular, uint is defined so we do not have to define it
30 * Also, see <limits.h> for min/max values for sind, uind, long, huge
31 * (SHRT_MIN, SHRT_MAX, USHRT_MAX, LONG_MIN, LONG_MAX, ULONG_MAX)
32 * These limits should be verified and coded into "h-constant.h".
36 #ifndef INCLUDED_H_TYPE_H
37 #define INCLUDED_H_TYPE_H
43 /*** Special 4 letter names for some standard types ***/
45 typedef void *vptr; /*!< void型ポインタ定義 / A standard pointer (to "void" because ANSI C says so) */
46 typedef const char *cptr; /*!< 文字列定数用ポインタ定義 / A simple pointer (to unmodifiable strings) */
47 typedef double real; /*!< doubleをreal型として定義 / Since float's are silly, hard code real numbers as doubles */
51 * @brief エラーコードの定義 / Error codes for function return values
53 * 一般に成功時0、失敗時負数、何らかの問題時整数とする。
54 * Success = 0, Failure = -N, Problem = +N
59 #define uint uint_hack /*!< 非マッキントッシュ環境で重複を避けるためのuint_hack型定義 / Hack -- prevent problems with non-MACINTOSH */
62 #define huge huge_hack /*!< WINDOWS環境で重複を避けるためのhuge_hack定義 / Hack -- prevent problems with WINDOWS */
65 #define byte byte_hack /*!< AMIGA環境で重複を避けるためのbyte_hack定義 / Hack -- prevent problems with AMIGA */
68 #define bool bool_hack /*!< C++環境で重複を避けるためのbool_hack定義 Hack -- prevent problems with C++ */
71 /* Note that "signed char" is not always "defined" */
72 /* So always use "s16b" to hold small signed values */
73 /* A signed byte of memory */
74 /* typedef signed char syte; */
76 typedef unsigned char byte; /*!< byte型をunsighned charとして定義 / Note that unsigned values can cause math problems / An unsigned byte of memory */
77 typedef char bool; /*!< bool型をcharとして定義 / Note that a bool is smaller than a full "int" / Simple True/False type */
78 typedef int sint; /*!< sint型をintとして定義 / A signed, standard integer (at least 2 bytes) */
79 typedef unsigned int uint; /* uint型をintとして定義 / An unsigned, "standard" integer (often pre-defined) */
82 /* The largest possible signed integer (pre-defined) */
83 /* typedef long long; */
85 /* The largest possible unsigned integer */
86 typedef unsigned long huge;
88 /* Signed/Unsigned 16 bit value */
91 typedef uint16_t u16b;
93 typedef signed short s16b;
94 typedef unsigned short u16b;
97 /* Signed/Unsigned 32 bit value */
100 typedef uint32_t u32b;
102 typedef signed long s32b;
103 typedef unsigned long u32b;
107 typedef s16b idx; /*!< ゲーム中のID型を定義 */
108 typedef byte position; /*!< ゲーム中の座標型を定義 */
109 typedef s16b hit_point; /*!< ゲーム中のHP/ダメージ型を定義 */
110 typedef s16b hit_prob; /*!< ゲーム中の命中修正値を定義 */
111 typedef s16b base_status; /*!< ゲーム中の基礎能力値型を定義 */
112 typedef byte item_number; /*!< ゲーム中のアイテム数型を定義 */
113 typedef s16b action_energy; /*!< ゲーム中の行動エネルギー型を定義 */
114 typedef s16b armour_class; /*!< ゲーム中の行動アーマークラス型を定義 */
115 typedef s16b time_effect; /*!< ゲーム中の時限期間の型を定義 */
117 /*** Pointers to all the basic types defined above ***/
119 typedef real *real_ptr;
120 typedef errr *errr_ptr;
121 typedef char *char_ptr;
122 typedef byte *byte_ptr;
123 typedef bool *bool_ptr;
124 typedef sint *sint_ptr;
125 typedef uint *uint_ptr;
126 typedef long *long_ptr;
127 typedef huge *huge_ptr;
128 typedef s16b *s16b_ptr;
129 typedef u16b *u16b_ptr;
130 typedef s32b *s32b_ptr;
131 typedef u32b *u32b_ptr;
132 typedef vptr *vptr_ptr;
133 typedef cptr *cptr_ptr;
137 /*** Pointers to Functions of special types (for various purposes) ***/
139 /* A generic function takes a user data and a special data */
140 typedef errr (*func_gen)(vptr, vptr);
142 /* An equality testing function takes two things to compare (bool) */
143 typedef bool (*func_eql)(vptr, vptr);
145 /* A comparison function takes two things and to compare (-1,0,+1) */
146 typedef sint (*func_cmp)(vptr, vptr);
148 /* A hasher takes a thing (and a max hash size) to hash (0 to siz - 1) */
149 typedef uint (*func_hsh)(vptr, uint);
151 /* A key extractor takes a thing and returns (a pointer to) some key */
152 typedef vptr (*func_key)(vptr);