OSDN Git Service

[Refactor] #39962 Separated dump_player_status_with_screen_num() from dump_aux_player...
authorHourier <hourier@users.sourceforge.jp>
Sat, 7 Mar 2020 13:02:58 +0000 (22:02 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 7 Mar 2020 13:02:58 +0000 (22:02 +0900)
src/io/player-status-dump.c

index 73e6c0d..8e3fc0a 100644 (file)
@@ -2,81 +2,39 @@
 #include "files.h"
 #include "io/player-status-dump.h"
 
+
 /*!
- * @brief プレイヤーのステータス表示をファイルにダンプする
+ * @brief 画面番号を指定してダンプする
  * @param creature_ptr プレーヤーへの参照ポインタ
  * @param fff ファイルポインタ
+ * @param display_player 画面表示へのコールバック
+ * @param map_name マップ名へのコールバック
+ * @param screen_num 画面番号
+ * @param start_y
+ * @param end_y
+ * @param change_color バッファへ詰める文字の変更有無
  * @return なし
  */
-void dump_aux_player_status(player_type *creature_ptr, FILE *fff, display_player_pf display_player, map_name_pf map_name)
+static void dump_player_status_with_screen_num(
+       player_type *creature_ptr, FILE *fff, display_player_pf display_player, map_name_pf map_name,
+       int screen_num, TERM_LEN start_y, TERM_LEN end_y, bool change_color)
 {
        TERM_COLOR a;
        char c;
        char buf[1024];
-       display_player(creature_ptr, 0, map_name);
-
-       for (TERM_LEN y = 1; y < 22; y++)
+       display_player(creature_ptr, screen_num, map_name);
+       for (TERM_LEN y = start_y; y < end_y; y++)
        {
                TERM_LEN x;
                for (x = 0; x < 79; x++)
                {
                        (void)(Term_what(x, y, &a, &c));
-                       buf[x] = c;
-               }
-
-               buf[x] = '\0';
-               while ((x > 0) && (buf[x - 1] == ' '))
-                       buf[--x] = '\0';
-
-               fprintf(fff, _("%s\n", "%s\n"), buf);
-       }
-
-       display_player(creature_ptr, 1, map_name);
-       for (TERM_LEN y = 10; y < 19; y++)
-       {
-               TERM_LEN x;
-               for (x = 0; x < 79; x++)
-               {
-                       (void)(Term_what(x, y, &a, &c));
-                       buf[x] = c;
-               }
-
-               buf[x] = '\0';
-               while ((x > 0) && (buf[x - 1] == ' '))
-                       buf[--x] = '\0';
-
-               fprintf(fff, "%s\n", buf);
-       }
-
-       fprintf(fff, "\n");
-       display_player(creature_ptr, 2, map_name);
-       for (TERM_LEN y = 2; y < 22; y++)
-       {
-               TERM_LEN x;
-               for (x = 0; x < 79; x++)
-               {
-                       (void)(Term_what(x, y, &a, &c));
-                       if (a < 128)
+                       if (!change_color)
+                       {
                                buf[x] = c;
-                       else
-                               buf[x] = ' ';
-               }
+                               continue;
+                       }
 
-               buf[x] = '\0';
-               while ((x > 0) && (buf[x - 1] == ' '))
-                       buf[--x] = '\0';
-
-               fprintf(fff, "%s\n", buf);
-       }
-
-       fprintf(fff, "\n");
-       display_player(creature_ptr, 3, map_name);
-       for (TERM_LEN y = 1; y < 22; y++)
-       {
-               TERM_LEN x;
-               for (x = 0; x < 79; x++)
-               {
-                       (void)(Term_what(x, y, &a, &c));
                        if (a < 128)
                                buf[x] = c;
                        else
@@ -89,6 +47,24 @@ void dump_aux_player_status(player_type *creature_ptr, FILE *fff, display_player
 
                fprintf(fff, "%s\n", buf);
        }
+}
 
+
+/*!
+ * @brief プレイヤーのステータス表示をファイルにダンプする
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param fff ファイルポインタ
+ * @param display_player 画面表示へのコールバック
+ * @param map_name マップ名へのコールバック
+ * @return なし
+ */
+void dump_aux_player_status(player_type *creature_ptr, FILE *fff, display_player_pf display_player, map_name_pf map_name)
+{
+       dump_player_status_with_screen_num(creature_ptr, fff, display_player, map_name, 0, 1, 22, FALSE);
+       dump_player_status_with_screen_num(creature_ptr, fff, display_player, map_name, 1, 10, 19, FALSE);
+       fprintf(fff, "\n");
+       dump_player_status_with_screen_num(creature_ptr, fff, display_player, map_name, 2, 2, 22, TRUE);
+       fprintf(fff, "\n");
+       dump_player_status_with_screen_num(creature_ptr, fff, display_player, map_name, 3, 1, 22, TRUE);
        fprintf(fff, "\n");
 }