OSDN Git Service

[Refactor] #2138 Separated confirm_command() from request_command()
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 19 Feb 2022 10:06:50 +0000 (19:06 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 20 Feb 2022 14:51:52 +0000 (23:51 +0900)
src/io/input-key-requester.cpp
src/io/input-key-requester.h

index 2b513d9..91ce62b 100644 (file)
@@ -68,23 +68,12 @@ void InputKeyRequestor::request_command()
     this->change_shopping_command();
     auto caret_command = this->get_caret_command();
     for (auto i = enum2i(INVEN_MAIN_HAND); i < INVEN_TOTAL; i++) {
-        auto *o_ptr = &this->player_ptr->inventory_list[i];
-        if ((o_ptr->k_idx == 0) || (o_ptr->inscription == 0)) {
+        auto &o_ref = this->player_ptr->inventory_list[i];
+        if ((o_ref.k_idx == 0) || (o_ref.inscription == 0)) {
             continue;
         }
 
-        auto s = quark_str(o_ptr->inscription);
-        s = angband_strchr(s, '^');
-        while (s) {
-            auto sure = _((s[1] == caret_command) || (s[1] == '*'), (s[1] == command_cmd) || (s[1] == '*'));
-            if (sure) {
-                if (!get_check(_("本当ですか? ", "Are you sure? "))) {
-                    command_cmd = ' ';
-                }
-            }
-
-            s = angband_strchr(s + 1, '^');
-        }
+        this->confirm_command(o_ref, caret_command);
     }
 
     prt("", 0, 0);
@@ -431,3 +420,24 @@ int InputKeyRequestor::get_caret_command()
     return 0;
 #endif
 }
+
+void InputKeyRequestor::confirm_command(ObjectType &o_ref, const int caret_command)
+{
+    auto s = quark_str(o_ref.inscription);
+    s = angband_strchr(s, '^');
+    while (s) {
+#ifdef JP
+        auto sure = (s[1] == caret_command) || (s[1] == '*');
+#else
+        auto sure = (s[1] == command_cmd) || (s[1] == '*');
+        (void)caret_command;
+#endif
+        if (sure) {
+            if (!get_check(_("本当ですか? ", "Are you sure? "))) {
+                command_cmd = ' ';
+            }
+        }
+
+        s = angband_strchr(s + 1, '^');
+    }
+}
index 4cdf631..4d5bf2e 100644 (file)
@@ -16,6 +16,7 @@ extern TERM_LEN command_gap;
 extern int16_t command_wrk;
 extern int16_t command_new;
 
+class ObjectType;
 class PlayerType;
 class InputKeyRequestor {
 public:
@@ -37,4 +38,5 @@ private:
     void process_control_command(short *cmd);
     void change_shopping_command();
     int get_caret_command();
+    void confirm_command(ObjectType &o_ref, const int caret_command);
 };