5 * @brief ゲーム中に用いる変数型定義 / Basic "types".
11 * Note the attempt to make all basic types have 4 letters.
12 * This improves readibility and standardizes the code.
13 * Likewise, all complex types are at least 4 letters.
14 * Thus, almost every three letter word is a legal variable.
15 * But beware of certain reserved words ('for' and 'if' and 'do').
16 * Note that the type used in structures for bit flags should be uint.
17 * As long as these bit flags are sequential, they will be space smart.
18 * Note that on some machines, apparently "signed char" is illegal.
19 * It must be true that char/byte takes exactly 1 byte
20 * It must be true that sind/uind takes exactly 2 bytes
21 * It must be true that sbig/ubig takes exactly 4 bytes
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".
39 /*** Special 4 letter names for some standard types ***/
40 typedef void *vptr; /*!< void型ポインタ定義 / A standard pointer (to "void" because ANSI C says so) */
43 * @brief 文字列定数用ポインタ定義 / Unmodifiable strings
44 * @todo std::stringに置換したい.
46 typedef const char *concptr;
49 * @brief エラーコードの定義 / Error codes for function return values
51 * 一般に成功時0、失敗時負数、何らかの問題時正数とする。
52 * Success = 0, Failure = -N, Problem = +N
56 #define MAX_UCHAR 255 /*!< Maximum value storable in a "byte" (hard-coded) */
57 #define MAX_SHORT 32767 /*!< Maximum value storable in a "int16_t" (hard-coded) */
59 #define MAX_NLEN 160 /*!< Maximum length of object's name */
60 #define MAX_INSCRIPTION _(76, 69) /*!< Maximum length of object's inscription */
61 #define MAX_MONSTER_NAME 160 /*!< モンスター名称の最大バイト数 / Max characters of monster's name */
66 typedef unsigned char byte;
67 typedef unsigned short ushort;
68 typedef unsigned int uint;
69 typedef unsigned long ulong;
71 // 整数型のバイト数が2021年現在の通常環境と異なるならばコンパイルを通さない.
72 static_assert(sizeof(char) == 1);
73 static_assert(sizeof(short) == 2);
74 static_assert(sizeof(int) == 4);
75 // static_assert(sizeof(long) == 8); // 将来のための予約.
77 typedef int16_t IDX; /*!< ゲーム中のID型を定義 */
79 typedef int16_t FEAT_IDX; /*!< ゲーム中の地形ID型を定義 */
80 typedef int16_t FLOOR_IDX; /*!< ゲーム中のフロアID型を定義 */
82 typedef int16_t MONSTER_IDX; /*!< ゲーム中のモンスター個体ID型を定義 */
83 typedef int16_t DUNGEON_IDX; /*!< ゲーム中のダンジョンID型を定義 */
84 typedef int16_t EGO_IDX; /*!< アイテムエゴのID型を定義 */
85 typedef int16_t QUEST_IDX; /*!< ゲーム中のクエストID型を定義 */
87 typedef int16_t INVENTORY_IDX; /*!< ゲーム中の所持品ID型を定義 */
88 typedef int16_t OBJECT_IDX; /*!< ゲーム中のアイテムID型を定義 */
89 typedef int MUTATION_IDX; /*!< 突然変異のID型を定義 */
91 typedef int32_t POSITION; /*!< ゲーム中の座標型を定義 */
92 typedef int16_t POSITION_IDX; /*!< ゲーム中の座標リストID型 */
94 typedef byte FEAT_SUBTYPE; /*!< 地形情報の副値 (トラップ種別/パターン種別/店舗種別)*/
96 typedef char GAME_TEXT; /*!< ゲーム中のテキスト型定義 */
99 * @var typedef int32_t MANA_POINT
100 * @brief MPとその増減量の型定義
102 * MANA_POINTはプレイヤーのMPの各値とその増減量の型である。
104 typedef int32_t MANA_POINT; /*!< ゲーム中のMP型を定義 */
106 typedef int16_t HIT_PROB; /*!< ゲーム中の装備命中修正値を定義 */
108 typedef int32_t MONSTER_NUMBER; /*!< ゲーム中のモンスター数型を定義 */
109 typedef int32_t ITEM_NUMBER; /*!< ゲーム中のアイテム数型を定義 */
111 typedef int16_t ACTION_ENERGY; /*!< ゲーム中の行動エネルギー型を定義 */
112 typedef int16_t ARMOUR_CLASS; /*!< ゲーム中の行動アーマークラス型を定義 */
113 typedef int16_t TIME_EFFECT; /*!< ゲーム中の時限期間の型を定義 */
116 * @var typedef int16_t ENEGRY
119 * ENERGYはプレイヤーとモンスターの行動順を定める行動エネルギーを示す型定義である。
121 typedef int16_t ENERGY; /*!< ゲーム中の行動エネルギーの型定義 */
123 typedef int16_t SLEEP_DEGREE; /*!< モンスターの睡眠度の型定義 */
125 typedef int16_t PLAYER_LEVEL; /*!< ゲーム中のプレイヤーレベルの型を定義 */
126 typedef int DIRECTION; /*!< ゲーム中の方角の型定義 */
127 typedef int32_t EXP; /*!< ゲーム中の主経験値の型定義 */
128 typedef int16_t SUB_EXP; /*!< ゲーム中の副経験値の型定義 */
130 typedef int32_t OBJECT_SUBTYPE_VALUE; /*!< ゲーム中のアイテム副分類の型定義 */
131 typedef int16_t PARAMETER_VALUE; /*!< ゲーム中のアイテム能力値の型定義 */
132 typedef int32_t WEIGHT; /*!< ゲーム中の重量の型定義(ポンド) */
134 typedef int DICE_NUMBER; /*!< ゲーム中のダイス数の型定義 */
135 typedef int DICE_SID; /*!< ゲーム中のダイス面の型定義 */
136 typedef int32_t PRICE; /*!< ゲーム中の金額価値の型定義 */
138 typedef int POWER; /*!< 魔法の効力定義*/
140 typedef int32_t DEPTH; /*!< ゲーム中の階層レベルの型定義 */
141 typedef byte RARITY; /*!< ゲーム中の希少度の型定義 */
143 typedef int32_t GAME_TURN; /*!< ゲーム中のターンの型定義 */
144 typedef uint32_t REAL_TIME; /*!< 実時刻の型定義 */
146 typedef int32_t PERCENTAGE; /*!< ゲーム中のパーセント表記の型定義(/100倍) */
147 typedef int16_t MULTIPLY; /*!< ゲーム中の倍率の型定義(/10倍) */
149 typedef uint32_t BIT_FLAGS; /*!< 32ビットのフラグ配列の型定義 */
150 typedef uint16_t BIT_FLAGS16; /*!< 16ビットのフラグ配列の型定義 */
151 typedef byte BIT_FLAGS8; /*!< 8ビットのフラグ配列の型定義 */
153 typedef int16_t COMMAND_CODE; /*!< コマンド内容の型定義 */
154 typedef int16_t COMMAND_ARG; /*!< コマンド引数の型定義 */
156 typedef int TERM_LEN; /*!< コンソール表示座標の型定義 */
157 typedef byte TERM_COLOR; /*!< テキスト表示色の型定義 */
158 typedef int32_t SPELL_IDX; /*!< 各魔法領域/職業能力ごとの呪文ID型定義 */
159 typedef int16_t PROB; /*!< 確率の重みの型定義 */
160 typedef byte FEAT_POWER; /*!< 地形強度の型定義 */
162 typedef int QUANTITY; /*!< インターフェース上の指定個数 */
164 typedef int16_t ACTION_SKILL_POWER; /*!< 行動技能値 */
166 enum class ProcessResult {
169 PROCESS_CONTINUE = 2,
170 PROCESS_LOOP_CONTINUE = 3,
171 PROCESS_LOOP_BREAK = 4,