OSDN Git Service

[Refactor] #3484 get_aim_dir() のinput_command() シグネチャを変える準備
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 1 Jul 2023 02:17:01 +0000 (11:17 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sat, 1 Jul 2023 11:07:50 +0000 (20:07 +0900)
src/target/target-getter.cpp
src/target/target-getter.h

index 107e1de..f5bf2a2 100644 (file)
@@ -20,6 +20,7 @@
 #include "timed-effect/player-confusion.h"
 #include "timed-effect/timed-effects.h"
 #include "view/display-messages.h"
+#include <string>
 
 /*
  * Get an "aiming direction" from the user.
  *
  * Note that confusion over-rides any (explicit?) user choice.
  */
-bool get_aim_dir(PlayerType *player_ptr, DIRECTION *dp)
+bool get_aim_dir(PlayerType *player_ptr, int *dp)
 {
-    DIRECTION dir = command_dir;
+    auto dir = command_dir;
     if (use_old_target && target_okay(player_ptr)) {
         dir = 5;
     }
 
-    COMMAND_CODE code;
+    short code;
     if (repeat_pull(&code)) {
         if (!(code == 5 && !target_okay(player_ptr))) {
-            dir = (DIRECTION)code;
+            dir = code;
         }
     }
 
-    *dp = (DIRECTION)code;
-    char command;
-    while (!dir) {
-        concptr p;
+    *dp = code;
+    while (dir == 0) {
+        std::string prompt;
         if (!target_okay(player_ptr)) {
-            p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
+            prompt = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
         } else {
-            p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
+            prompt = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
         }
 
-        if (!input_command(p, &command, true)) {
+        char command;
+        if (!input_command(prompt, &command, true)) {
             break;
         }
 
@@ -89,12 +90,12 @@ bool get_aim_dir(PlayerType *player_ptr, DIRECTION *dp)
             dir = 0;
         }
 
-        if (!dir) {
+        if (dir == 0) {
             bell();
         }
     }
 
-    if (!dir) {
+    if (dir == 0) {
         project_length = 0;
         return false;
     }
index 0024ca8..987b620 100644 (file)
@@ -3,6 +3,6 @@
 #include "system/angband.h"
 
 class PlayerType;
-bool get_aim_dir(PlayerType *player_ptr, DIRECTION *dp);
+bool get_aim_dir(PlayerType *player_ptr, int *dp);
 bool get_direction(PlayerType *player_ptr, DIRECTION *dp, bool allow_under, bool with_steed);
 bool get_rep_dir(PlayerType *player_ptr, DIRECTION *dp, bool under);