OSDN Git Service

[Refactor] #3197 named_num 構造体のconcptr をstd::string に変えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 29 Apr 2023 04:15:01 +0000 (13:15 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 29 Apr 2023 11:48:10 +0000 (20:48 +0900)
src/io/gf-descriptions.h
src/io/interpret-pref-file.cpp
src/wizard/wizard-spells.cpp

index 19b5a43..ea60992 100644 (file)
@@ -1,11 +1,11 @@
 #pragma once
 
-#include "effect/attribute-types.h"
-#include "system/angband.h"
+#include <string>
 #include <vector>
 
+enum class AttributeType;
 struct named_num {
-    concptr name; /* The name of this thing */
+    std::string name; /* The name of this thing */
     AttributeType num; /* A number associated with it */
 };
 
index 3ef2a81..8d7520f 100644 (file)
@@ -364,12 +364,12 @@ static int interpret_z_token(char *buf)
     }
 
     *(t++) = '\0';
-    for (const auto &description : gf_descriptions) {
-        if (!streq(description.name, buf + 2)) {
+    for (const auto &[name, num] : gf_descriptions) {
+        if (!streq(name.data(), buf + 2)) {
             continue;
         }
 
-        gf_colors[description.num] = t;
+        gf_colors[num] = t;
         return 0;
     }
 
index 27861d8..4a1819d 100644 (file)
@@ -41,7 +41,6 @@
 #include "util/enum-converter.h"
 #include "util/flag-group.h"
 #include "view/display-messages.h"
-
 #include <string_view>
 #include <vector>
 
@@ -256,15 +255,19 @@ void wiz_kill_target(PlayerType *player_ptr, int dam, AttributeType effect_idx,
         for (auto i = 1; i <= 23; i++) {
             prt("", i, 0);
         }
+
         for (auto i = 0U; i < std::size(gf_descriptions); ++i) {
-            auto name = std::string_view(gf_descriptions[i].name).substr(3); // 先頭の"GF_"を取り除く
-            auto num = enum2i(gf_descriptions[i].num);
+            const auto &gf_description = gf_descriptions[i];
+            auto name = std::string_view(gf_description.name).substr(3); // 先頭の"GF_"を取り除く
+            auto num = enum2i(gf_description.num);
             put_str(format("%03d:%-.10s^", num, name.data()), 1 + i / 5, 1 + (i % 5) * 16);
         }
+
         if (!get_value("EffectID", 1, max - 1, &idx)) {
             screen_load();
             return;
         }
+
         screen_load();
     }