OSDN Git Service

[Refactor] #3287 Reshaped rd_options()
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 6 May 2023 13:38:37 +0000 (22:38 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Wed, 31 May 2023 13:51:45 +0000 (22:51 +0900)
src/load/option-loader.cpp
src/load/option-loader.h

index 0b4cee9..3966f30 100644 (file)
@@ -22,7 +22,7 @@
  * The window options are stored in the same way, but note that each
  * window gets 32 options, and their order is fixed by certain defines.
  */
-void rd_options(void)
+void rd_options()
 {
     strip_bytes(16);
 
@@ -63,26 +63,27 @@ void rd_options(void)
     autosave_t = rd_bool();
     autosave_freq = rd_s16b();
 
-    BIT_FLAGS flag[8];
-    for (int n = 0; n < 8; n++) {
+    uint32_t flag[8]{};
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         flag[n] = rd_u32b();
     }
 
-    BIT_FLAGS mask[8];
-    for (int n = 0; n < 8; n++) {
+    uint32_t mask[8]{};
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         mask[n] = rd_u32b();
     }
 
-    for (auto n = 0; n < 8; n++) {
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         for (auto i = 0; i < 32; i++) {
             if (none_bits(mask[n], 1U << i) || none_bits(g_option_masks[n], 1U << i)) {
                 continue;
             }
 
+            auto &option_flag = g_option_flags[n];
             if (flag[n] & (1UL << i)) {
-                g_option_flags[n] |= (1UL << i);
+                option_flag |= (1UL << i);
             } else {
-                g_option_flags[n] &= ~(1UL << i);
+                option_flag &= ~(1UL << i);
             }
         }
     }
@@ -92,27 +93,25 @@ void rd_options(void)
     }
 
     extract_option_vars();
-    for (int n = 0; n < 8; n++) {
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         flag[n] = rd_u32b();
     }
 
-    for (int n = 0; n < 8; n++) {
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         mask[n] = rd_u32b();
     }
 
-    for (int n = 0; n < 8; n++) {
+    for (auto n = 0; n < MAX_WINDOW_ENTITIES; n++) {
         for (int i = 0; i < 32; i++) {
-            if (!(mask[n] & (1UL << i))) {
-                continue;
-            }
-            if (!(g_window_masks[n] & (1UL << i))) {
+            if (none_bits(mask[n], 1U << i) || none_bits(g_window_masks[n], 1U << i)) {
                 continue;
             }
 
+            auto &window_flag = g_window_flags[n];
             if (flag[n] & (1UL << i)) {
-                g_window_flags[n].set(i2enum<SubWindowRedrawingFlag>(i));
+                window_flag.set(i2enum<SubWindowRedrawingFlag>(i));
             } else {
-                g_window_flags[n].reset(i2enum<SubWindowRedrawingFlag>(i));
+                window_flag.reset(i2enum<SubWindowRedrawingFlag>(i));
             }
         }
     }
index 6a44680..c359faa 100644 (file)
@@ -1,3 +1,3 @@
 #pragma once
 
-void rd_options(void);
+void rd_options();