OSDN Git Service

[Refactor] #4111 term_add_bigch() の引数をColoredChar に変え、戻り値は誰も使っていないのでvoid に変えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 19 May 2024 05:04:46 +0000 (14:04 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 19 May 2024 12:16:10 +0000 (21:16 +0900)
src/term/z-term.cpp
src/term/z-term.h
src/view/display-lore.cpp
src/window/display-sub-windows.cpp
src/window/main-window-util.cpp

index c36c021..db856c1 100644 (file)
@@ -14,6 +14,7 @@
 #include "term/gameterm.h"
 #include "term/term-color-types.h"
 #include "term/z-virt.h"
+#include "view/colored-char.h"
 
 /* Special flags in the attr data */
 #define AF_BIGTILE2 0xf0
@@ -1473,38 +1474,36 @@ errr term_addch(TERM_COLOR a, char c)
  * Otherwise, queue a pair of attr/char for display at the current
  * cursor location, and advance the cursor to the right by two.
  */
-errr term_add_bigch(TERM_COLOR a, char c)
+void term_add_bigch(const ColoredChar &cc)
 {
     if (!use_bigtile) {
-        return term_addch(a, c);
+        (void)term_addch(cc.color, cc.character);
+        return;
     }
 
     /* Handle "unusable" cursor */
     if (game_term->scr->cu) {
-        return -1;
+        return;
     }
 
     /* Paranoia -- no illegal chars */
-    if (!c) {
-        return -2;
+    if (!cc.has_character()) {
+        return;
     }
 
     /* Queue the given character for display */
-    term_queue_bigchar(game_term->scr->cx, game_term->scr->cy, a, c, 0, 0);
+    term_queue_bigchar(game_term->scr->cx, game_term->scr->cy, cc.color, cc.character, 0, 0);
 
     /* Advance the cursor */
     game_term->scr->cx += 2;
 
     /* Success */
     if (game_term->scr->cx < game_term->wid) {
-        return 0;
+        return;
     }
 
     /* Note "Useless" cursor */
     game_term->scr->cu = 1;
-
-    /* Note "Useless" cursor */
-    return 1;
 }
 
 /*
index 7e7cb73..383df2d 100644 (file)
@@ -191,6 +191,7 @@ private:
 /**** Available Variables ****/
 extern term_type *game_term;
 
+class ColoredChar;
 errr term_user(int n);
 errr term_xtra(int n, int v);
 
@@ -204,7 +205,7 @@ errr term_set_cursor(int v);
 errr term_gotoxy(TERM_LEN x, TERM_LEN y);
 errr term_draw(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
 errr term_addch(TERM_COLOR a, char c);
-errr term_add_bigch(TERM_COLOR a, char c);
+void term_add_bigch(const ColoredChar &cc);
 errr term_addstr(int n, TERM_COLOR a, std::string_view sv);
 errr term_putch(TERM_LEN x, TERM_LEN y, TERM_COLOR a, char c);
 errr term_putstr(TERM_LEN x, TERM_LEN y, int n, TERM_COLOR a, std::string_view sv);
index 9c0faf6..9b2b100 100644 (file)
@@ -23,6 +23,7 @@
 #include "term/z-form.h"
 #include "util/bit-flags-calculator.h"
 #include "util/string-processor.h"
+#include "view/colored-char.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
 void roff_top(MonsterRaceId r_idx)
 {
     auto *r_ptr = &monraces_info[r_idx];
-    char c1 = r_ptr->d_char;
-    char c2 = r_ptr->x_char;
-
     TERM_COLOR a1 = r_ptr->d_attr;
+    char c1 = r_ptr->d_char;
     TERM_COLOR a2 = r_ptr->x_attr;
+    char c2 = r_ptr->x_char;
 
     term_erase(0, 0);
     term_gotoxy(0, 0);
@@ -64,11 +64,11 @@ void roff_top(MonsterRaceId r_idx)
     term_addstr(-1, TERM_WHITE, r_ptr->name);
 
     term_addstr(-1, TERM_WHITE, " ('");
-    term_add_bigch(a1, c1);
+    term_add_bigch({ a1, c1 });
     term_addstr(-1, TERM_WHITE, "')");
 
     term_addstr(-1, TERM_WHITE, "/('");
-    term_add_bigch(a2, c2);
+    term_add_bigch({ a2, c2 });
     term_addstr(-1, TERM_WHITE, "'):");
 }
 
index 44ccee3..493c419 100644 (file)
@@ -14,6 +14,7 @@
 #include "mind/mind-sniper.h"
 #include "mind/mind-types.h"
 #include "monster-race/monster-race.h"
+#include "monster-race/race-indice-types.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-description-types.h"
 #include "object/item-tester-hooker.h"
@@ -128,34 +129,33 @@ void fix_inventory(PlayerType *player_ptr)
  */
 static void print_monster_line(TERM_LEN x, TERM_LEN y, MonsterEntity *m_ptr, int n_same, int n_awake)
 {
-    std::string buf;
-    MonsterRaceId r_idx = m_ptr->ap_r_idx;
-    auto *r_ptr = &monraces_info[r_idx];
-
     term_erase(0, y);
     term_gotoxy(x, y);
-    if (!r_ptr) {
+    const auto monrace_id = m_ptr->ap_r_idx;
+    if (monrace_id == MonsterRaceId::PLAYER) {
         return;
     }
-    if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
-        buf = format(_("%3s(覚%2d)", "%3s(%2d)"), MonsterRace(r_idx).is_bounty(true) ? "  W" : "  U", n_awake);
+
+    std::string buf;
+    const auto &monrace = monraces_info[monrace_id];
+    if (monrace.kind_flags.has(MonsterKindType::UNIQUE)) {
+        buf = format(_("%3s(覚%2d)", "%3s(%2d)"), MonsterRace(monrace_id).is_bounty(true) ? "  W" : "  U", n_awake);
     } else {
         buf = format(_("%3d(覚%2d)", "%3d(%2d)"), n_same, n_awake);
     }
-    term_addstr(-1, TERM_WHITE, buf);
 
+    term_addstr(-1, TERM_WHITE, buf);
     term_addstr(-1, TERM_WHITE, " ");
-    term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
+    term_add_bigch({ monrace.x_attr, monrace.x_char });
 
-    if (r_ptr->r_tkills && m_ptr->mflag2.has_not(MonsterConstantFlagType::KAGE)) {
-        buf = format(" %2d", (int)r_ptr->level);
+    if (monrace.r_tkills && m_ptr->mflag2.has_not(MonsterConstantFlagType::KAGE)) {
+        buf = format(" %2d", monrace.level);
     } else {
         buf = " ??";
     }
 
     term_addstr(-1, TERM_WHITE, buf);
-
-    term_addstr(-1, TERM_WHITE, format(" %s ", r_ptr->name.data()));
+    term_addstr(-1, TERM_WHITE, format(" %s ", monrace.name.data()));
 }
 
 /*!
@@ -232,7 +232,7 @@ static void print_pet_list_oneline(PlayerType *player_ptr, const MonsterEntity &
     }
 
     term_gotoxy(x + 13, y);
-    term_add_bigch(monrace.x_attr, monrace.x_char);
+    term_add_bigch({ monrace.x_attr, monrace.x_char });
     term_addstr(-1, TERM_WHITE, " ");
     term_addstr(-1, TERM_WHITE, name);
 
index a5bf55b..9ce7ef0 100644 (file)
@@ -282,7 +282,7 @@ void display_map(PlayerType *player_ptr, int *cy, int *cx)
                 }
             }
 
-            term_add_bigch(ta, tc);
+            term_add_bigch({ ta, tc });
         }
     }