• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision71b3928b5a73a93609414970e8231c2e789b8a39 (tree)
Time2019-06-07 01:52:04
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 ビットフラグ処理マクロを util.h へ移動.

Change Summary

Incremental Difference

--- a/src/defines.h
+++ b/src/defines.h
@@ -92,40 +92,6 @@
9292
9393 /*** Screen Locations ***/
9494
95-
96-
97-/*
98- * Object flags
99- *
100- * Old variables for object flags such as flags1, flags2, and flags3
101- * are obsolated. Now single array flgs[TR_FLAG_SIZE] contains all
102- * object flags. And each flag is refered by single index number
103- * instead of a bit mask.
104- *
105- * Therefore it's very easy to add a lot of new flags; no one need to
106- * worry about in which variable a new flag should be put, nor to
107- * modify a huge number of files all over the source directory at once
108- * to add new flag variables such as flags4, a_ability_flags1, etc...
109- *
110- * All management of flags is now treated using a set of macros
111- * instead of bit operations.
112- * Note: These macros are using division, modulo, and bit shift
113- * operations, and it seems that these operations are rather slower
114- * than original bit operation. But since index numbers are almost
115- * always given as constant, such slow operations are performed in the
116- * compile time. So there is no problem on the speed.
117- *
118- * Exceptions of new flag management is a set of flags to control
119- * object generation and the curse flags. These are not yet rewritten
120- * in new index form; maybe these have no merit of rewriting.
121- */
122-
123-#define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
124-#define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
125-#define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
126-#define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
127-#define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
128-
12995 /*
13096 * Is the monster seen by the player?
13197 */
--- a/src/util.h
+++ b/src/util.h
@@ -27,6 +27,38 @@ extern int PlayerUID;
2727 #define MAX_MACRO_MOD 12
2828 #define MAX_MACRO_TRIG 200 /*!< 登録を許すマクロ(トリガー)の最大数 */
2929
30+/*
31+ * Object flags
32+ *
33+ * Old variables for object flags such as flags1, flags2, and flags3
34+ * are obsolated. Now single array flgs[TR_FLAG_SIZE] contains all
35+ * object flags. And each flag is refered by single index number
36+ * instead of a bit mask.
37+ *
38+ * Therefore it's very easy to add a lot of new flags; no one need to
39+ * worry about in which variable a new flag should be put, nor to
40+ * modify a huge number of files all over the source directory at once
41+ * to add new flag variables such as flags4, a_ability_flags1, etc...
42+ *
43+ * All management of flags is now treated using a set of macros
44+ * instead of bit operations.
45+ * Note: These macros are using division, modulo, and bit shift
46+ * operations, and it seems that these operations are rather slower
47+ * than original bit operation. But since index numbers are almost
48+ * always given as constant, such slow operations are performed in the
49+ * compile time. So there is no problem on the speed.
50+ *
51+ * Exceptions of new flag management is a set of flags to control
52+ * object generation and the curse flags. These are not yet rewritten
53+ * in new index form; maybe these have no merit of rewriting.
54+ */
55+
56+#define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
57+#define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
58+#define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
59+#define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
60+#define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
61+
3062 /*
3163 * Sort-array element
3264 */
Show on old repository browser