OSDN Git Service

[Refactor] #4165 change_display_by_mutation() の引数と戻り値の型を調整してポインタ引数をなくした
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 27 May 2024 12:01:58 +0000 (21:01 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Mon, 27 May 2024 13:17:02 +0000 (22:17 +0900)
src/view/display-player-stat-info.cpp

index 3f5a484..9304e51 100644 (file)
@@ -320,27 +320,29 @@ static int compensation_stat_by_mutation(PlayerType *player_ptr, int stat)
  * @param c 補正後の表示記号
  * @param a 表示色
  */
-static void change_display_by_mutation(PlayerType *player_ptr, int stat, char *c, TERM_COLOR *a)
+static DisplaySymbol change_display_by_mutation(PlayerType *player_ptr, int stat, const DisplaySymbol &symbol_initial)
 {
     int compensation = compensation_stat_by_mutation(player_ptr, stat);
     if (compensation == 0) {
-        return;
+        return symbol_initial;
     }
 
-    *c = '*';
+    DisplaySymbol symbol = { symbol_initial.color, '*' };
     if (compensation > 0) {
-        *a = TERM_L_GREEN;
+        symbol.color = TERM_L_GREEN;
         if (compensation < 10) {
-            *c = '0' + compensation;
+            symbol.character = '0' + compensation;
         }
     }
 
     if (compensation < 0) {
-        *a = TERM_RED;
+        symbol.color = TERM_RED;
         if (compensation > -10) {
-            *c = '0' - compensation;
+            symbol.character = '0' - compensation;
         }
     }
+
+    return symbol;
 }
 
 /*!
@@ -355,9 +357,7 @@ static void display_mutation_compensation(PlayerType *player_ptr, int row, int c
     player_flags(player_ptr, flags);
 
     for (int stat = 0; stat < A_MAX; stat++) {
-        DisplaySymbol symbol(TERM_SLATE, '.');
-        change_display_by_mutation(player_ptr, stat, &symbol.character, &symbol.color);
-
+        auto symbol = change_display_by_mutation(player_ptr, stat, { TERM_SLATE, '.' });
         if (flags.has(TR_SUST_STATUS_LIST[stat])) {
             symbol = { TERM_GREEN, 's' };
         }