OSDN Git Service

Merge branch 'develop' into macos-develop
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-floor.cpp
index af5fdb2..2abd7e8 100644 (file)
@@ -1,4 +1,4 @@
-#include "cmd-io/cmd-floor.h"
+#include "cmd-io/cmd-floor.h"
 #include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "core/window-redrawer.h"
@@ -40,7 +40,11 @@ void do_cmd_target(PlayerType *player_ptr)
  */
 void do_cmd_look(PlayerType *player_ptr)
 {
-    set_bits(player_ptr->window_flags, PW_SIGHT_MONSTERS | PW_FLOOR_ITEMS);
+    static constexpr auto flags = {
+        SubWindowRedrawingFlag::SIGHT_MONSTERS,
+        SubWindowRedrawingFlag::FLOOR_ITEMS,
+    };
+    RedrawingFlagsUpdater::get_instance().set_flags(flags);
     handle_stuff(player_ptr);
     if (target_set(player_ptr, TARGET_LOOK)) {
         msg_print(_("ターゲット決定。", "Target Selected."));
@@ -53,36 +57,33 @@ void do_cmd_look(PlayerType *player_ptr)
  */
 void do_cmd_locate(PlayerType *player_ptr)
 {
-    const char *dirstrings[3][3] = {
-        { _("北西", " northwest of"), _("北", " north of"), _("北東", " northeast of") },
-        { _("西", " west of"), _("真上", ""), _("東", " east of") },
-        { _("南西", " southwest of"), _("南", " south of"), _("南東", " southeast of") },
-    };
-    DIRECTION dir;
+    static constexpr std::array<std::array<std::string_view, 3>, 3> dirstrings = { {
+        { { _("北西", " northwest of"), _("北", " north of"), _("北東", " northeast of") } },
+        { { _("西", " west of"), _("真上", ""), _("東", " east of") } },
+        { { _("南西", " southwest of"), _("南", " south of"), _("南東", " southeast of") } },
+    } };
     POSITION y1, x1;
-    TERM_LEN wid, hgt;
-    get_screen_size(&wid, &hgt);
+    const auto &[wid, hgt] = get_screen_size();
     POSITION y2 = y1 = panel_row_min;
     POSITION x2 = x1 = panel_col_min;
     constexpr auto fmt = _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?");
     while (true) {
-        std::string_view dirstring = dirstrings[(y2 < y1) ? 0 : ((y2 > y1) ? 2 : 1)][(x2 < x1) ? 0 : ((x2 > x1) ? 2 : 1)];
-        std::string out_val = format(fmt, y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), dirstring.data());
-
-        dir = 0;
-        while (!dir) {
-            char command;
-            if (!get_com(out_val, &command, true)) {
+        const auto &dirstring = dirstrings[(y2 < y1) ? 0 : ((y2 > y1) ? 2 : 1)][(x2 < x1) ? 0 : ((x2 > x1) ? 2 : 1)];
+        const auto prompt = format(fmt, y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), dirstring.data());
+        auto dir = 0;
+        while (dir == 0) {
+            const auto command = input_command(prompt, true);
+            if (!command) {
                 break;
             }
 
-            dir = get_keymap_dir(command);
-            if (!dir) {
+            dir = get_keymap_dir(*command);
+            if (dir == 0) {
                 bell();
             }
         }
 
-        if (!dir) {
+        if (dir == 0) {
             break;
         }
 
@@ -94,8 +95,12 @@ void do_cmd_locate(PlayerType *player_ptr)
 
     verify_panel(player_ptr);
     auto &rfu = RedrawingFlagsUpdater::get_instance();
-    rfu.set_flag(StatusRedrawingFlag::MONSTER_STATUSES);
+    rfu.set_flag(StatusRecalculatingFlag::MONSTER_STATUSES);
     rfu.set_flag(MainWindowRedrawingFlag::MAP);
-    player_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
+    static constexpr auto flags = {
+        SubWindowRedrawingFlag::OVERHEAD,
+        SubWindowRedrawingFlag::DUNGEON,
+    };
+    rfu.set_flags(flags);
     handle_stuff(player_ptr);
 }