OSDN Git Service

[Refactor] #3190 Remove macro function REM_FLG() from autopick-key-flag-process.h
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 7 May 2023 06:08:08 +0000 (15:08 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 7 May 2023 10:47:09 +0000 (19:47 +0900)
src/autopick/autopick-editor-util.cpp
src/autopick/autopick-entry.cpp
src/autopick/autopick-key-flag-process.h
src/autopick/autopick-util.cpp
src/autopick/autopick-util.h

index cb95932..1e39d7a 100644 (file)
@@ -44,29 +44,29 @@ void toggle_keyword(text_body_type *tb, BIT_FLAGS flg)
         if (FLG_NOUN_BEGIN <= flg && flg <= FLG_NOUN_END) {
             int i;
             for (i = FLG_NOUN_BEGIN; i <= FLG_NOUN_END; i++) {
-                REM_FLG(i);
+                entry->remove(i);
             }
         } else if (FLG_UNAWARE <= flg && flg <= FLG_STAR_IDENTIFIED) {
             int i;
             for (i = FLG_UNAWARE; i <= FLG_STAR_IDENTIFIED; i++) {
-                REM_FLG(i);
+                entry->remove(i);
             }
         } else if (FLG_ARTIFACT <= flg && flg <= FLG_AVERAGE) {
             int i;
             for (i = FLG_ARTIFACT; i <= FLG_AVERAGE; i++) {
-                REM_FLG(i);
+                entry->remove(i);
             }
         } else if (FLG_RARE <= flg && flg <= FLG_COMMON) {
             int i;
             for (i = FLG_RARE; i <= FLG_COMMON; i++) {
-                REM_FLG(i);
+                entry->remove(i);
             }
         }
 
         if (add) {
             ADD_FLG(flg);
         } else {
-            REM_FLG(flg);
+            entry->remove(flg);
         }
 
         tb->lines_list[y] = autopick_line_from_entry(*entry);
@@ -190,7 +190,7 @@ void add_keyword(text_body_type *tb, BIT_FLAGS flg)
         if (FLG_NOUN_BEGIN <= flg && flg <= FLG_NOUN_END) {
             int i;
             for (i = FLG_NOUN_BEGIN; i <= FLG_NOUN_END; i++) {
-                REM_FLG(i);
+                entry->remove(i);
             }
         }
 
index 3526fc0..d53c292 100644 (file)
@@ -413,7 +413,7 @@ void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, It
     }
 
     if (object_is_bounty(player_ptr, o_ptr)) {
-        REM_FLG(FLG_WORTHLESS);
+        entry->remove(FLG_WORTHLESS);
         ADD_FLG(FLG_WANTED);
     }
 
index e74ee80..13e6d39 100644 (file)
@@ -15,5 +15,4 @@
 #define ADD_KEY2(KEY) strcat(ptr, KEY)
 
 #define ADD_FLG(FLG) (entry->flags[FLG / 32] |= (1UL << (FLG % 32)))
-#define REM_FLG(FLG) (entry->flags[FLG / 32] &= ~(1UL << (FLG % 32)))
 #define ADD_FLG_NOUN(FLG) (ADD_FLG(FLG), prev_flg = FLG)
index b4b0e7a..34be26e 100644 (file)
@@ -8,6 +8,7 @@
 #include "object-enchant/item-feeling.h"
 #include "system/item-entity.h"
 #include "system/player-type-definition.h"
+#include "util/bit-flags-calculator.h"
 #include "util/quarks.h"
 
 /*!
@@ -28,6 +29,11 @@ bool autopick_type::has(int flag) const
     return this->flags[flag / 32] & (1UL << (flag % 32));
 }
 
+void autopick_type::remove(int flag)
+{
+    reset_bits(this->flags[flag / 32], 1UL << (flag % 32));
+}
+
 /*!
  * @brief Free memory of lines_list.
  */
index 4159183..b19802b 100644 (file)
@@ -32,6 +32,7 @@ struct autopick_type {
     byte dice; /*!< 武器のダイス値基準値 / Weapons which have more than 'dice' dice match */
     byte bonus; /*!< アイテムのボーナス基準値 / Items which have more than 'bonus' magical bonus match */
     bool has(int flag) const;
+    void remove(int flag);
 };
 
 /*