OSDN Git Service

[Refactor] #3642 VS2022の警告 (関数戻り値のムーブ)を解消した
[hengbandforosx/hengbandosx.git] / src / window / display-sub-windows.cpp
index 4175d50..ad76e5b 100644 (file)
@@ -1,5 +1,4 @@
-#include "window/display-sub-windows.h"
-#include "core/window-redrawer.h"
+#include "window/display-sub-windows.h"
 #include "flavor/flavor-describer.h"
 #include "floor/cave.h"
 #include "game-option/option-flags.h"
@@ -7,7 +6,6 @@
 #include "game-option/text-display-options.h"
 #include "grid/feature.h"
 #include "inventory/inventory-describer.h"
-#include "inventory/inventory-slot-types.h"
 #include "inventory/inventory-util.h"
 #include "locale/japanese.h"
 #include "main/sound-of-music.h"
 #include "mind/mind-sniper.h"
 #include "mind/mind-types.h"
 #include "monster-race/monster-race.h"
-#include "monster-race/race-flags1.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-description-types.h"
-#include "monster/monster-flag-types.h"
-#include "monster/monster-info.h"
-#include "monster/monster-status.h"
 #include "object/item-tester-hooker.h"
 #include "object/object-info.h"
-#include "object/object-mark-types.h"
 #include "player-base/player-class.h"
 #include "player-info/class-info.h"
 #include "player/player-status-flags.h"
 #include "player/player-status-table.h"
 #include "player/player-status.h"
 #include "realm/realm-names-table.h"
-#include "spell-kind/magic-item-recharger.h"
 #include "spell/spells-execution.h"
-#include "spell/technic-info-table.h"
-#include "system/baseitem-info.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
 #include "system/item-entity.h"
 #include "system/monster-entity.h"
 #include "system/monster-race-info.h"
-#include "system/player-type-definition.h"
-#include "system/redrawing-flags-updater.h"
 #include "system/terrain-type-definition.h"
-#include "target/target-describer.h"
 #include "target/target-preparation.h"
-#include "target/target-setter.h"
-#include "target/target-types.h"
 #include "term/gameterm.h"
 #include "term/screen-processor.h"
-#include "term/term-color-types.h"
-#include "term/z-form.h"
 #include "timed-effect/player-hallucination.h"
 #include "timed-effect/player-stun.h"
 #include "timed-effect/timed-effects.h"
-#include "util/bit-flags-calculator.h"
 #include "util/int-char-converter.h"
 #include "view/display-lore.h"
 #include "view/display-map.h"
@@ -149,7 +131,7 @@ static void print_monster_line(TERM_LEN x, TERM_LEN y, MonsterEntity *m_ptr, int
     MonsterRaceId r_idx = m_ptr->ap_r_idx;
     auto *r_ptr = &monraces_info[r_idx];
 
-    term_erase(0, y, 255);
+    term_erase(0, y);
     term_gotoxy(x, y);
     if (!r_ptr) {
         return;
@@ -231,7 +213,7 @@ void print_monster_list(FloorType *floor_ptr, const std::vector<MONSTER_IDX> &mo
     }
 
     for (; line < max_lines; line++) {
-        term_erase(0, line, 255);
+        term_erase(0, line);
     }
 }
 
@@ -239,10 +221,10 @@ static void print_pet_list_oneline(PlayerType *player_ptr, const MonsterEntity &
 {
     const auto &monrace = monraces_info[monster.ap_r_idx];
     const auto name = monster_desc(player_ptr, &monster, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE | MD_NO_OWNER);
-    const auto [bar_color, bar_len] = monster.get_hp_bar_data();
+    const auto &[bar_color, bar_len] = monster.get_hp_bar_data();
     const auto is_visible = monster.ml && !player_ptr->effects()->hallucination()->is_hallucinated();
 
-    term_erase(0, y, 255);
+    term_erase(0, y);
     if (is_visible) {
         term_putstr(x, y, -1, TERM_WHITE, "[----------]");
         term_putstr(x + 1, y, bar_len, bar_color, "**********");
@@ -268,14 +250,14 @@ static void print_pet_list(PlayerType *player_ptr, const std::vector<MONSTER_IDX
         print_pet_list_oneline(player_ptr, monster, x, line, width);
 
         if ((line == height - 2) && (n < pets.size() - 2)) {
-            term_erase(0, line + 1, 255);
+            term_erase(0, line + 1);
             term_putstr(x, line + 1, -1, TERM_WHITE, "-- and more --");
             break;
         }
     }
 
     for (int n = pets.size(); n < height; ++n) {
-        term_erase(0, y + n, 255);
+        term_erase(0, y + n);
     }
 }
 
@@ -290,10 +272,9 @@ void fix_monster_list(PlayerType *player_ptr)
 
     display_sub_windows(SubWindowRedrawingFlag::SIGHT_MONSTERS,
         [player_ptr, &once] {
-            int w, h;
-            term_get_size(&w, &h);
+            const auto &[wid, hgt] = term_get_size();
             std::call_once(once, target_sensing_monsters_prepare, player_ptr, monster_list);
-            print_monster_list(player_ptr->current_floor_ptr, monster_list, 0, 0, h);
+            print_monster_list(player_ptr->current_floor_ptr, monster_list, 0, 0, hgt);
         });
 
     if (use_music && has_monster_music) {
@@ -309,10 +290,9 @@ void fix_pet_list(PlayerType *player_ptr)
 {
     display_sub_windows(SubWindowRedrawingFlag::PETS,
         [player_ptr] {
-            int w, h;
-            term_get_size(&w, &h);
+            const auto &[wid, hgt] = term_get_size();
             const auto pets = target_pets_prepare(player_ptr);
-            print_pet_list(player_ptr, pets, 0, 0, w, h);
+            print_pet_list(player_ptr, pets, 0, 0, wid, hgt);
         });
 }
 
@@ -326,8 +306,7 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes
         return;
     }
 
-    TERM_LEN wid, hgt;
-    term_get_size(&wid, &hgt);
+    const auto &[wid, hgt] = term_get_size();
     byte attr = TERM_WHITE;
     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
         int cur_row = i - INVEN_MAIN_HAND;
@@ -345,7 +324,7 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes
         }
 
         int cur_col = 3;
-        term_erase(cur_col, cur_row, 255);
+        term_erase(cur_col, cur_row);
         term_putstr(0, cur_row, cur_col, TERM_WHITE, tmp_val);
 
         std::string item_name;
@@ -389,7 +368,7 @@ static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tes
     }
 
     for (int i = INVEN_TOTAL - INVEN_MAIN_HAND; i < hgt; i++) {
-        term_erase(0, i, 255);
+        term_erase(0, i);
     }
 }
 
@@ -429,13 +408,12 @@ void fix_message(void)
 {
     display_sub_windows(SubWindowRedrawingFlag::MESSAGE,
         [] {
-            TERM_LEN w, h;
-            term_get_size(&w, &h);
-            for (short i = 0; i < h; i++) {
-                term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), *message_str(i));
+            const auto &[wid, hgt] = term_get_size();
+            for (short i = 0; i < hgt; i++) {
+                term_putstr(0, (hgt - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), *message_str(i));
                 TERM_LEN x, y;
                 term_locate(&x, &y);
-                term_erase(x, y, 255);
+                term_erase(x, y);
             }
         });
 }
@@ -452,8 +430,7 @@ void fix_overhead(PlayerType *player_ptr)
 {
     display_sub_windows(SubWindowRedrawingFlag::OVERHEAD,
         [player_ptr] {
-            TERM_LEN wid, hgt;
-            term_get_size(&wid, &hgt);
+            const auto &[wid, hgt] = term_get_size();
             if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
                 int cy, cx;
                 display_map(player_ptr, &cy, &cx);
@@ -570,13 +547,8 @@ static const MonsterEntity *monster_on_floor_items(FloorType *floor_ptr, const g
  */
 static void display_floor_item_list(PlayerType *player_ptr, const int y, const int x)
 {
-    // Term の行数を取得。
-    TERM_LEN term_h;
-    {
-        TERM_LEN term_w;
-        term_get_size(&term_w, &term_h);
-    }
-    if (term_h <= 0) {
+    const auto &[wid, hgt] = term_get_size();
+    if (hgt <= 0) {
         return;
     }
 
@@ -624,7 +596,7 @@ static void display_floor_item_list(PlayerType *player_ptr, const int y, const i
         }
 
         // 途中で行数が足りなくなったら最終行にその旨追記して終了。
-        if (term_y >= term_h) {
+        if (term_y >= hgt) {
             term_addstr(-1, TERM_WHITE, "-- more --");
             break;
         }
@@ -660,12 +632,8 @@ void fix_floor_item_list(PlayerType *player_ptr, const int y, const int x)
  */
 static void display_found_item_list(PlayerType *player_ptr)
 {
-    // Term の行数を取得。
-    TERM_LEN term_h;
-    TERM_LEN term_w;
-    term_get_size(&term_w, &term_h);
-
-    if (term_h <= 0) {
+    const auto &[wid, hgt] = term_get_size();
+    if (hgt <= 0) {
         return;
     }
 
@@ -703,7 +671,7 @@ static void display_found_item_list(PlayerType *player_ptr)
     TERM_LEN term_y = 1;
     for (auto item : found_item_list) {
         // 途中で行数が足りなくなったら終了。
-        if (term_y >= term_h) {
+        if (term_y >= hgt) {
             break;
         }
 
@@ -721,7 +689,7 @@ static void display_found_item_list(PlayerType *player_ptr)
 
         // アイテム座標表示
         const auto item_location = format("(X:%3d Y:%3d)", item->ix, item->iy);
-        prt(item_location, term_y, term_w - item_location.length() - 1);
+        prt(item_location, term_y, wid - item_location.length() - 1);
 
         ++term_y;
     }