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 s32b POSITION; /*!< ゲーム中の座標型を定義 */
109 typedef s32b HIT_POINT; /*!< ゲーム中のHP/ダメージ型を定義 */
110 typedef s32b MANA_POINT; /*!< ゲーム中のMP型を定義 */
111 typedef s16b HIT_PROB; /*!< ゲーム中の命中修正値を定義 */
112 typedef s16b BASE_STATUS; /*!< ゲーム中の基礎能力値型を定義 */
113 typedef s32b ITEM_NUMBER; /*!< ゲーム中のアイテム数型を定義 */
114 typedef s16b ACTION_ENERGY; /*!< ゲーム中の行動エネルギー型を定義 */
115 typedef s16b ARMOUR_CLASS; /*!< ゲーム中の行動アーマークラス型を定義 */
116 typedef s16b TIME_EFFECT; /*!< ゲーム中の時限期間の型を定義 */
117 typedef byte CHARACTER_IDX; /*!< ゲーム中のキャラクター特性各種IDの型を定義 */
118 typedef byte DISCOUNT_RATE; /*!< ゲーム中の値引き率の型を定義 */
120 typedef s16b PLAYER_LEVEL; /*!< ゲーム中のプレイヤーレベルの型を定義 */
121 typedef int DIRECTION; /*!< ゲーム中の方角の型定義 */
122 typedef s32b EXP; /*!< ゲーム中の主経験値の型定義 */
123 typedef s16b SUB_EXP; /*!< ゲーム中の副経験値の型定義 */
125 typedef byte OBJECT_TYPE_VALUE; /*!< ゲーム中のアイテム主分類の型定義 */
126 typedef byte OBJECT_SUBTYPE_VALUE; /*!< ゲーム中のアイテム副分類の型定義 */
127 typedef s16b PARAMETER_VALUE; /*!< ゲーム中のアイテム能力値の型定義 */
128 typedef s16b WEIGHT; /*!< ゲーム中の重量の型定義 */
130 typedef int DICE_NUMBER; /*!< ゲーム中のダイス数の型定義 */
131 typedef int DICE_SID; /*!< ゲーム中のダイス面の型定義 */
132 typedef s32b PRICE; /*!< ゲーム中の金額価値の型定義 */
134 typedef u32b STR_OFFSET; /*!< テキストオフセットの型定義 */
136 typedef s32b DEPTH; /*!< ゲーム中の階層レベルの型定義 */
137 typedef byte RARITY; /*!< ゲーム中の希少度の型定義 */
139 typedef s32b GAME_TURN; /*!< ゲーム中のターンの型定義 */
141 typedef s16b PERCENTAGE; /*!< ゲーム中のパーセント表記の型定義 */
143 typedef u32b BIT_FLAGS; /*!< 32ビットのフラグ配列の型定義 */
144 typedef byte BIT_FLAGS8; /*!< 8ビットのフラグ配列の型定義 */
146 typedef s16b COMMAND_CODE; /*!< コマンド内容の型定義 */
148 typedef int TERM_POSITION; /*!< コンソール表示座標の型定義 */
149 typedef byte SYMBOL_COLOR; /*!< キャラの色の型定義 */
150 typedef byte SYMBOL_CODE; /*!< キャラの文字の型定義 */
152 /*** Pointers to all the basic types defined above ***/
154 typedef real *real_ptr;
155 typedef errr *errr_ptr;
156 typedef char *char_ptr;
157 typedef byte *byte_ptr;
158 typedef bool *bool_ptr;
159 typedef sint *sint_ptr;
160 typedef uint *uint_ptr;
161 typedef long *long_ptr;
162 typedef huge *huge_ptr;
163 typedef s16b *s16b_ptr;
164 typedef u16b *u16b_ptr;
165 typedef s32b *s32b_ptr;
166 typedef u32b *u32b_ptr;
167 typedef vptr *vptr_ptr;
168 typedef cptr *cptr_ptr;
172 /*** Pointers to Functions of special types (for various purposes) ***/
174 /* A generic function takes a user data and a special data */
175 typedef errr (*func_gen)(vptr, vptr);
177 /* An equality testing function takes two things to compare (bool) */
178 typedef bool (*func_eql)(vptr, vptr);
180 /* A comparison function takes two things and to compare (-1,0,+1) */
181 typedef sint (*func_cmp)(vptr, vptr);
183 /* A hasher takes a thing (and a max hash size) to hash (0 to siz - 1) */
184 typedef uint (*func_hsh)(vptr, uint);
186 /* A key extractor takes a thing and returns (a pointer to) some key */
187 typedef vptr (*func_key)(vptr);