OSDN Git Service

[Refactor] #4165 bolt_pict() の返り値をDisplaySymbol に変えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 27 May 2024 11:56:44 +0000 (20:56 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Mon, 27 May 2024 13:17:01 +0000 (22:17 +0900)
src/grid/grid.cpp
src/term/gameterm.cpp
src/term/gameterm.h

index b79eac9..9035a30 100644 (file)
@@ -277,8 +277,8 @@ void print_rel(PlayerType *player_ptr, const DisplaySymbol &symbol, POSITION y,
 
 void print_bolt_pict(PlayerType *player_ptr, POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ)
 {
-    const auto &[a, c] = bolt_pict(y, x, ny, nx, typ);
-    print_rel(player_ptr, { a, c }, ny, nx);
+    const auto symbol = bolt_pict(y, x, ny, nx, typ);
+    print_rel(player_ptr, symbol, ny, nx);
 }
 
 /*!
index fbecfaa..353784f 100644 (file)
@@ -3,6 +3,7 @@
 #include "system/system-variables.h"
 #include "term/term-color-types.h"
 #include "util/string-processor.h"
+#include "view/colored-char.h"
 #include <span>
 #include <unordered_map>
 
@@ -561,15 +562,10 @@ static TERM_COLOR spell_color(AttributeType type)
  * If the distance is not "one", we (may) return "*".
  * </pre>
  */
-std::pair<TERM_COLOR, char> bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ)
+DisplaySymbol bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ)
 {
-    int base;
-
-    byte k;
-
-    TERM_COLOR a;
-
     /* No motion (*) */
+    int base;
     if ((ny == y) && (nx == x)) {
         base = 0x30;
     }
@@ -600,11 +596,11 @@ std::pair<TERM_COLOR, char> bolt_pict(POSITION y, POSITION x, POSITION ny, POSIT
     }
 
     /* Basic spell color */
-    k = spell_color(typ);
+    const auto k = spell_color(typ);
 
     /* Obtain attr/char */
-    a = misc_to_attr[base + k];
-    auto c = misc_to_char[base + k];
+    const auto a = misc_to_attr[base + k];
+    const auto c = misc_to_char[base + k];
 
     /* Create pict */
     return { a, c };
index 0668b2f..a9c452e 100644 (file)
@@ -30,4 +30,6 @@ extern std::map<AttributeType, std::string> gf_colors;
 extern TERM_COLOR color_char_to_attr(char c);
 
 extern const std::unordered_map<std::string_view, TERM_COLOR> color_list;
-std::pair<TERM_COLOR, char> bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ);
+
+class DisplayDymbol;
+DisplaySymbol bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ);