OSDN Git Service

[Refactor] #3264 BASE_STATUS 型エイリアスを削除した
[hengbandforosx/hengbandosx.git] / src / system / h-type.h
1 #pragma once
2
3 /*!
4  * @file h-type.h
5  * @brief ゲーム中に用いる変数型定義 / Basic "types".
6  * @date 2017/12/03
7  * @author
8  * 不明(変愚蛮怒スタッフ?)
9  * @details
10  * <pre>
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".
33  * </pre>
34  */
35
36 #include <cassert>
37 #include <stdint.h>
38
39 /*** Special 4 letter names for some standard types ***/
40 typedef void *vptr; /*!< void型ポインタ定義 / A standard pointer (to "void" because ANSI C says so) */
41
42 /*!
43  * @brief 文字列定数用ポインタ定義 / Unmodifiable strings
44  * @todo std::stringに置換したい.
45  */
46 typedef const char *concptr;
47
48 /*!
49  * @brief エラーコードの定義 / Error codes for function return values
50  * @details
51  * 一般に成功時0、失敗時負数、何らかの問題時正数とする。
52  * Success = 0, Failure = -N, Problem = +N
53  */
54 typedef int errr;
55
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) */
58
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 */
62
63 /*!
64  * @brief 符号なし整数の簡潔な定義
65  */
66 typedef unsigned char byte;
67 typedef unsigned short ushort;
68 typedef unsigned int uint;
69 typedef unsigned long ulong;
70
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); // 将来のための予約.
76
77 typedef int16_t IDX; /*!< ゲーム中のID型を定義 */
78
79 typedef int16_t FEAT_IDX; /*!< ゲーム中の地形ID型を定義 */
80 typedef int16_t FLOOR_IDX; /*!< ゲーム中のフロアID型を定義 */
81
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型を定義 */
86
87 typedef int16_t INVENTORY_IDX; /*!< ゲーム中の所持品ID型を定義 */
88 typedef int16_t OBJECT_IDX; /*!< ゲーム中のアイテムID型を定義 */
89 typedef int MUTATION_IDX; /*!< 突然変異のID型を定義 */
90
91 typedef int32_t POSITION; /*!< ゲーム中の座標型を定義 */
92 typedef int16_t POSITION_IDX; /*!< ゲーム中の座標リストID型 */
93
94 typedef byte FEAT_SUBTYPE; /*!< 地形情報の副値 (トラップ種別/パターン種別/店舗種別)*/
95
96 typedef char GAME_TEXT; /*!< ゲーム中のテキスト型定義 */
97
98 /*!
99  * @var typedef int32_t MANA_POINT
100  * @brief MPとその増減量の型定義
101  * @details
102  * MANA_POINTはプレイヤーのMPの各値とその増減量の型である。
103  */
104 typedef int32_t MANA_POINT; /*!< ゲーム中のMP型を定義 */
105
106 typedef int16_t HIT_PROB; /*!< ゲーム中の装備命中修正値を定義 */
107
108 typedef int32_t MONSTER_NUMBER; /*!< ゲーム中のモンスター数型を定義 */
109 typedef int32_t ITEM_NUMBER; /*!< ゲーム中のアイテム数型を定義 */
110
111 typedef int16_t ACTION_ENERGY; /*!< ゲーム中の行動エネルギー型を定義 */
112 typedef int16_t ARMOUR_CLASS; /*!< ゲーム中の行動アーマークラス型を定義 */
113 typedef int16_t TIME_EFFECT; /*!< ゲーム中の時限期間の型を定義 */
114
115 /*!
116  * @var typedef int16_t ENEGRY
117  * @brief 行動エネルギーの型定義
118  * @details
119  * ENERGYはプレイヤーとモンスターの行動順を定める行動エネルギーを示す型定義である。
120  */
121 typedef int16_t ENERGY; /*!< ゲーム中の行動エネルギーの型定義 */
122
123 typedef int16_t SLEEP_DEGREE; /*!< モンスターの睡眠度の型定義 */
124
125 typedef int16_t PLAYER_LEVEL; /*!< ゲーム中のプレイヤーレベルの型を定義 */
126 typedef int DIRECTION; /*!< ゲーム中の方角の型定義 */
127 typedef int32_t EXP; /*!< ゲーム中の主経験値の型定義 */
128 typedef int16_t SUB_EXP; /*!< ゲーム中の副経験値の型定義 */
129
130 typedef int32_t OBJECT_SUBTYPE_VALUE; /*!< ゲーム中のアイテム副分類の型定義 */
131 typedef int16_t PARAMETER_VALUE; /*!< ゲーム中のアイテム能力値の型定義 */
132 typedef int32_t WEIGHT; /*!< ゲーム中の重量の型定義(ポンド) */
133
134 typedef int DICE_NUMBER; /*!< ゲーム中のダイス数の型定義 */
135 typedef int DICE_SID; /*!< ゲーム中のダイス面の型定義 */
136 typedef int32_t PRICE; /*!< ゲーム中の金額価値の型定義 */
137
138 typedef int POWER; /*!< 魔法の効力定義*/
139
140 typedef int32_t DEPTH; /*!< ゲーム中の階層レベルの型定義 */
141 typedef byte RARITY; /*!< ゲーム中の希少度の型定義 */
142
143 typedef int32_t GAME_TURN; /*!< ゲーム中のターンの型定義 */
144 typedef uint32_t REAL_TIME; /*!< 実時刻の型定義 */
145
146 typedef int32_t PERCENTAGE; /*!< ゲーム中のパーセント表記の型定義(/100倍) */
147 typedef int16_t MULTIPLY; /*!< ゲーム中の倍率の型定義(/10倍) */
148
149 typedef uint32_t BIT_FLAGS; /*!< 32ビットのフラグ配列の型定義 */
150 typedef uint16_t BIT_FLAGS16; /*!< 16ビットのフラグ配列の型定義 */
151 typedef byte BIT_FLAGS8; /*!< 8ビットのフラグ配列の型定義 */
152
153 typedef int16_t COMMAND_CODE; /*!< コマンド内容の型定義 */
154 typedef int16_t COMMAND_ARG; /*!< コマンド引数の型定義 */
155
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; /*!< 地形強度の型定義 */
161
162 typedef int QUANTITY; /*!< インターフェース上の指定個数 */
163
164 typedef int16_t ACTION_SKILL_POWER; /*!< 行動技能値 */
165
166 enum class ProcessResult {
167     PROCESS_FALSE = 0,
168     PROCESS_TRUE = 1,
169     PROCESS_CONTINUE = 2,
170     PROCESS_LOOP_CONTINUE = 3,
171     PROCESS_LOOP_BREAK = 4,
172 };