OSDN Git Service

[Refactor] #37353 player-personality.c/h を作成して関連構造体と変数を移動.
[hengband/hengband.git] / src / scores.c
index a411347..2cf49bd 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "player-race.h"
+#include "player-status.h"
+#include "player-class.h"
+#include "player-personality.h"
+#include "files.h"
+#include "scores.h"
+#include "floor.h"
+#include "world.h"
 
 /*!
  * @brief i番目のスコア情報にバッファ位置をシークする / Seek score 'i' in the highscore file
@@ -145,15 +155,15 @@ static int highscore_add(high_score *score)
  */
 void display_scores_aux(int from, int to, int note, high_score *score)
 {
-       int             i, j, k, n, place;
-       byte attr;
+       int i, j, k, n, place;
+       TERM_COLOR attr;
 
-       high_score      the_score;
+       high_score the_score;
 
-       char    out_val[256];
-       char    tmp_val[160];
+       GAME_TEXT out_val[256];
+       GAME_TEXT tmp_val[160];
 
-       int wid, hgt, per_screen;
+       TERM_LEN wid, hgt, per_screen;
 
        Term_get_size(&wid, &hgt);
        per_screen = (hgt - 4) / 4;
@@ -187,7 +197,6 @@ void display_scores_aux(int from, int to, int note, high_score *score)
        /* Show per_screen per page, until "done" */
        for (k = from, place = k+1; k < i; k += per_screen)
        {
-               /* Clear screen */
                Term_clear();
 
                /* Title */
@@ -205,7 +214,7 @@ void display_scores_aux(int from, int to, int note, high_score *score)
                {
                        int pr, pc, pa, clev, mlev, cdun, mdun;
 
-                       cptr user, gold, when, aged;
+                       concptr user, gold, when, aged;
 
 
                        /* Hack -- indicate death in yellow */
@@ -395,8 +404,6 @@ void display_scores(int from, int to)
 
        /* Paranoia -- No score file */
        if (highscore_fd < 0) quit(_("スコア・ファイルが使用できません。", "Score file unavailable."));
-
-       /* Clear screen */
        Term_clear();
 
        /* Display the scores */
@@ -477,15 +484,15 @@ errr top_twenty(void)
                FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
 
        /* Calculate and save the points */
-       sprintf(the_score.pts, "%9ld", (long)total_points());
+       sprintf(the_score.pts, "%9ld", (long)calc_score());
        the_score.pts[9] = '\0';
 
        /* Save the current gold */
        sprintf(the_score.gold, "%9lu", (long)p_ptr->au);
        the_score.gold[9] = '\0';
 
-       /* Save the current turn */
-       sprintf(the_score.turns, "%9lu", (long)turn_real(turn));
+       /* Save the current current_world_ptr->game_turn */
+       sprintf(the_score.turns, "%9lu", (long)turn_real(current_world_ptr->game_turn));
        the_score.turns[9] = '\0';
 
 #ifdef HIGHSCORE_DATE_HACK
@@ -499,20 +506,20 @@ errr top_twenty(void)
 #endif
 
        /* Save the player name (15 chars) */
-       sprintf(the_score.who, "%-.15s", player_name);
+       sprintf(the_score.who, "%-.15s", p_ptr->name);
 
-       /* Save the player info XXX XXX XXX */
+       /* Save the player info */
        sprintf(the_score.uid, "%7u", player_uid);
        sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
-       sprintf(the_score.p_r, "%2d", p_ptr->prace);
-       sprintf(the_score.p_c, "%2d", p_ptr->pclass);
-       sprintf(the_score.p_a, "%2d", p_ptr->pseikaku);
+       sprintf(the_score.p_r, "%2d", MIN(p_ptr->prace, MAX_RACES));
+       sprintf(the_score.p_c, "%2d", MIN(p_ptr->pclass, MAX_CLASS));
+       sprintf(the_score.p_a, "%2d", MIN(p_ptr->pseikaku, MAX_SEIKAKU));
 
        /* Save the level and such */
-       sprintf(the_score.cur_lev, "%3d", p_ptr->lev);
-       sprintf(the_score.cur_dun, "%3d", dun_level);
-       sprintf(the_score.max_lev, "%3d", p_ptr->max_plv);
-       sprintf(the_score.max_dun, "%3d", max_dlv[dungeon_type]);
+       sprintf(the_score.cur_lev, "%3d", MIN((u16b)p_ptr->lev, 999));
+       sprintf(the_score.cur_dun, "%3d", (int)current_floor_ptr->dun_level);
+       sprintf(the_score.max_lev, "%3d", MIN((u16b)p_ptr->max_plv, 999));
+       sprintf(the_score.max_dun, "%3d", (int)max_dlv[p_ptr->dungeon_idx]);
 
        /* Save the cause of death (31 chars) */
        if (strlen(p_ptr->died_from) >= sizeof(the_score.how))
@@ -574,9 +581,10 @@ errr top_twenty(void)
        return (0);
 }
 
-
-/*
+/*!
+ * @brief プレイヤーの現在のスコアをランキングに挟む /
  * Predict the players location, and display it.
+ * @return エラーコード
  */
 errr predict_score(void)
 {
@@ -599,32 +607,32 @@ errr predict_score(void)
                FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
 
        /* Calculate and save the points */
-       sprintf(the_score.pts, "%9ld", (long)total_points());
+       sprintf(the_score.pts, "%9ld", (long)calc_score());
 
        /* Save the current gold */
        sprintf(the_score.gold, "%9lu", (long)p_ptr->au);
 
-       /* Save the current turn */
-       sprintf(the_score.turns, "%9lu", (long)turn_real(turn));
+       /* Save the current current_world_ptr->game_turn */
+       sprintf(the_score.turns, "%9lu", (long)turn_real(current_world_ptr->game_turn));
 
        /* Hack -- no time needed */
        strcpy(the_score.day, _("今日", "TODAY"));
 
        /* Save the player name (15 chars) */
-       sprintf(the_score.who, "%-.15s", player_name);
+       sprintf(the_score.who, "%-.15s", p_ptr->name);
 
-       /* Save the player info XXX XXX XXX */
+       /* Save the player info */
        sprintf(the_score.uid, "%7u", player_uid);
        sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
-       sprintf(the_score.p_r, "%2d", p_ptr->prace);
-       sprintf(the_score.p_c, "%2d", p_ptr->pclass);
-       sprintf(the_score.p_a, "%2d", p_ptr->pseikaku);
+       sprintf(the_score.p_r, "%2d", MIN(p_ptr->prace, MAX_RACES));
+       sprintf(the_score.p_c, "%2d", MIN(p_ptr->pclass, MAX_CLASS));
+       sprintf(the_score.p_a, "%2d", MIN(p_ptr->pseikaku, MAX_SEIKAKU));
 
        /* Save the level and such */
-       sprintf(the_score.cur_lev, "%3d", p_ptr->lev);
-       sprintf(the_score.cur_dun, "%3d", dun_level);
-       sprintf(the_score.max_lev, "%3d", p_ptr->max_plv);
-       sprintf(the_score.max_dun, "%3d", max_dlv[dungeon_type]);
+       sprintf(the_score.cur_lev, "%3d", MIN((u16b)p_ptr->lev, 999));
+       sprintf(the_score.cur_dun, "%3d", (int)current_floor_ptr->dun_level);
+       sprintf(the_score.max_lev, "%3d", MIN((u16b)p_ptr->max_plv, 999));
+       sprintf(the_score.max_dun, "%3d", (int)max_dlv[p_ptr->dungeon_idx]);
 
        /* Hack -- no cause of death */
        /* まだ死んでいないときの識別文字 */
@@ -653,16 +661,17 @@ errr predict_score(void)
 }
 
 
-
-/*
- * show_highclass - selectively list highscores based on class
- * -KMW-
+/*!
+ * @brief スコアランキングの簡易表示 /
+ * show_highclass - selectively list highscores based on class -KMW-
+ * @return なし
  */
 void show_highclass(void)
 {
 
        register int i = 0, j, m = 0;
-       int pr, clev/*, al*/;
+       int pr;
+       PLAYER_LEVEL clev/*, al*/;
        high_score the_score;
        char buf[1024], out_val[256];
 
@@ -694,7 +703,7 @@ void show_highclass(void)
                if (highscore_seek(j)) break;
                if (highscore_read(&the_score)) break;
                pr = atoi(the_score.p_r);
-               clev = atoi(the_score.cur_lev);
+               clev = (PLAYER_LEVEL)atoi(the_score.cur_lev);
 
 #ifdef JP
                sprintf(out_val, "   %3d) %sの%s (レベル %2d)",
@@ -711,10 +720,10 @@ void show_highclass(void)
 
 #ifdef JP
        sprintf(out_val, "あなた) %sの%s (レベル %2d)",
-           race_info[p_ptr->prace].title,player_name, p_ptr->lev);
+           race_info[p_ptr->prace].title,p_ptr->name, p_ptr->lev);
 #else
        sprintf(out_val, "You) %s the %s (Level %2d)",
-           player_name, race_info[p_ptr->prace].title, p_ptr->lev);
+           p_ptr->name, race_info[p_ptr->prace].title, p_ptr->lev);
 #endif
 
        prt(out_val, (m + 8), 0);
@@ -729,10 +738,11 @@ void show_highclass(void)
        screen_load();
 }
 
-
-/*
- * Race Legends
- * -KMW-
+/*!
+ * @brief スコアランキングの簡易表示(種族毎)サブルーチン /
+ * Race Legends -KMW-
+ * @param race_num 種族ID
+ * @return なし
  */
 void race_score(int race_num)
 {
@@ -801,10 +811,10 @@ void race_score(int race_num)
        {
 #ifdef JP
        sprintf(out_val, "あなた) %sの%s (レベル %2d)",
-                    race_info[p_ptr->prace].title,player_name, p_ptr->lev);
+                    race_info[p_ptr->prace].title,p_ptr->name, p_ptr->lev);
 #else
                sprintf(out_val, "You) %s the %s (Level %3d)",
-                   player_name, race_info[p_ptr->prace].title, p_ptr->lev);
+                   p_ptr->name, race_info[p_ptr->prace].title, p_ptr->lev);
 #endif
 
                prt(out_val, (m + 8), 0);
@@ -815,9 +825,10 @@ void race_score(int race_num)
 }
 
 
-/*
- * Race Legends
- * -KMW-
+/*!
+ * @brief スコアランキングの簡易表示(種族毎)メインルーチン /
+ * Race Legends -KMW-
+ * @return なし
  */
 void race_legends(void)
 {
@@ -833,18 +844,19 @@ void race_legends(void)
        }
 }
 
-
-/*
- * Change the player into a King!                      -RAK-
+/*!
+ * @brief 勝利者用の引退演出処理 /
+ * Change the player into a King! -RAK-
+ * @return なし
  */
 void kingly(void)
 {
-       int wid, hgt;
-       int cx, cy;
+       TERM_LEN wid, hgt;
+       TERM_LEN cx, cy;
        bool seppuku = streq(p_ptr->died_from, "Seppuku");
 
        /* Hack -- retire in town */
-       dun_level = 0;
+       current_floor_ptr->dun_level = 0;
 
        /* Fake death */
        if (!seppuku)
@@ -863,8 +875,6 @@ void kingly(void)
 
        /* Hack -- Instant Gold */
        p_ptr->au += 10000000L;
-
-       /* Clear screen */
        Term_clear();
 
        /* Display a crown */