OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。 / Ongoing type replacement.
[hengband/hengband.git] / src / scores.c
index 972e141..4a92db2 100644 (file)
@@ -1,20 +1,21 @@
-/* File: scores.c */
-
-/*
+/*!
+ * @file scores.c
+ * @brief ハイスコア処理 / Highscores handling
+ * @date 2014/07/14
+ * @author
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
  * This software may be copied and distributed for educational, research,
  * and not for profit purposes provided that this copyright and statement
  * are included in all such copies.  Other copyrights may also apply.
+ * 2014 Deskull rearranged comment for Doxygen.
  */
 
-/* Purpose: Highscores handling */
-
 #include "angband.h"
 
-
-/*
- * Seek score 'i' in the highscore file
+/*!
+ * @brief i番目のスコア情報にバッファ位置をシークする / Seek score 'i' in the highscore file
+ * @param i スコア情報ID
+ * @return 問題がなければ0を返す
  */
 static int highscore_seek(int i)
 {
@@ -23,8 +24,10 @@ static int highscore_seek(int i)
 }
 
 
-/*
- * Read one score from the highscore file
+/*!
+ * @brief 所定ポインタからスコア情報を読み取る / Read one score from the highscore file
+ * @param score スコア情報参照ポインタ
+ * @return エラーコード
  */
 static errr highscore_read(high_score *score)
 {
@@ -33,8 +36,10 @@ static errr highscore_read(high_score *score)
 }
 
 
-/*
- * Write one score to the highscore file
+/*!
+ * @brief 所定ポインタへスコア情報を書き込む / Write one score to the highscore file
+ * @param score スコア情報参照ポインタ
+ * @return エラーコード(問題がなければ0を返す)
  */
 static int highscore_write(high_score *score)
 {
@@ -42,10 +47,10 @@ static int highscore_write(high_score *score)
        return (fd_write(highscore_fd, (char*)(score), sizeof(high_score)));
 }
 
-
-/*
- * Just determine where a new score *would* be placed
- * Return the location (0 is best) or -1 on failure
+/*!
+ * @brief スコア情報を全て得るまで繰り返し取得する / Just determine where a new score *would* be placed
+ * @param score スコア情報参照ポインタ
+ * @return 正常ならば(MAX_HISCORES - 1)、問題があれば-1を返す
  */
 static int highscore_where(high_score *score)
 {
@@ -77,9 +82,10 @@ static int highscore_where(high_score *score)
 }
 
 
-/*
- * Actually place an entry into the high score file
- * Return the location (0 is best) or -1 on "failure"
+/*!
+ * @brief スコア情報をバッファの末尾に追加する / Actually place an entry into the high score file
+ * @param score スコア情報参照ポインタ
+ * @return 正常ならば書き込んだスロット位置、問題があれば-1を返す / Return the location (0 is best) or -1 on "failure"
  */
 static int highscore_add(high_score *score)
 {
@@ -122,12 +128,20 @@ static int highscore_add(high_score *score)
 
 
 
-/*
- * Display the scores in a given range.
+/*!
+ * @brief 指定された順位範囲でスコアを並べて表示する / Display the scores in a given range.
+ * @param from 順位先頭
+ * @param to 順位末尾
+ * @param note 黄色表示でハイライトする順位
+ * @param score スコア配列参照ポインタ
+ * @return なし
+ * @details
+ * <pre>
  * Assumes the high score list is already open.
  * Only five entries per line, too much info.
  *
  * Mega-Hack -- allow "fake" entry at the given position.
+ * </pre>
  */
 void display_scores_aux(int from, int to, int note, high_score *score)
 {
@@ -177,22 +191,12 @@ void display_scores_aux(int from, int to, int note, high_score *score)
                Term_clear();
 
                /* Title */
-#ifdef JP
-put_str("                変愚蛮怒: 勇者の殿堂", 0, 0);
-#else
-               put_str("                Hengband Hall of Fame", 0, 0);
-#endif
-
+               put_str(_("                変愚蛮怒: 勇者の殿堂", "                Hengband Hall of Fame"), 0, 0);
 
                /* Indicate non-top scores */
                if (k > 0)
                {
-#ifdef JP
-sprintf(tmp_val, "( %d 位以下 )", k + 1);
-#else
-                       sprintf(tmp_val, "(from position %d)", k + 1);
-#endif
-
+                       sprintf(tmp_val, _("( %d 位以下 )", "(from position %d)"), k + 1);
                        put_str(tmp_val, 0, 40);
                }
 
@@ -271,12 +275,7 @@ sprintf(tmp_val, "( %d 位以下 )", k + 1);
 
 
                        /* Append a "maximum level" */
-#ifdef JP
-if (mlev > clev) strcat(out_val, format(" (最高%d)", mlev));
-#else
-                       if (mlev > clev) strcat(out_val, format(" (Max %d)", mlev));
-#endif
-
+                       if (mlev > clev) strcat(out_val, format(_(" (最高%d)", " (Max %d)"), mlev));
 
                        /* Dump the first line */
                        c_put_str(attr, out_val, n*4 + 2, 0);
@@ -362,11 +361,7 @@ if (mlev > clev) strcat(out_val, format(" (最高%d)", mlev));
 
 
                /* Wait for response */
-#ifdef JP
-prt("[ ESCで中断, その他のキーで続けます ]", hgt - 1, 21);
-#else
-               prt("[Press ESC to quit, any other key to continue.]", hgt - 1, 17);
-#endif
+               prt(_("[ ESCで中断, その他のキーで続けます ]", "[Press ESC to quit, any other key to continue.]"), hgt - 1, _(21, 17));
 
                j = inkey();
                prt("", hgt - 1, 0);
@@ -377,11 +372,16 @@ prt("[ ESCで中断, その他のキーで続けます ]", hgt - 1, 21);
 }
 
 
-/*
- * Hack -- Display the scores in a given range and quit.
- *
+/*!
+ * @brief スコア表示処理メインルーチン / Hack -- Display the scores in a given range and quit.
+ * @param from 順位先頭
+ * @param to 順位末尾
+ * @return なし
+ * @details
+ * <pre>
  * This function is only called from "main.c" when the user asks
  * to see the "high scores".
+ * </pre>
  */
 void display_scores(int from, int to)
 {
@@ -394,12 +394,7 @@ void display_scores(int from, int to)
        highscore_fd = fd_open(buf, O_RDONLY);
 
        /* Paranoia -- No score file */
-#ifdef JP
-if (highscore_fd < 0) quit("スコア・ファイルが使用できません。");
-#else
-       if (highscore_fd < 0) quit("Score file unavailable.");
-#endif
-
+       if (highscore_fd < 0) quit(_("スコア・ファイルが使用できません。", "Score file unavailable."));
 
        /* Clear screen */
        Term_clear();
@@ -418,7 +413,11 @@ if (highscore_fd < 0) quit("スコア・ファイルが使用できません。"
 }
 
 
-
+/*!
+ * @brief スコアサーバへの転送処理
+ * @param do_send 実際に転送ア処置を行うか否か
+ * @return 転送が成功したらTRUEを返す
+ */
 bool send_world_score(bool do_send)
 {
 #ifdef WORLD_SCORE
@@ -426,25 +425,15 @@ bool send_world_score(bool do_send)
        {
                if(easy_band)
                {
-#ifdef JP
-                       msg_print("初心者モードではワールドスコアに登録できません。");
-#else
-                       msg_print("Since you are in the Easy Mode, you cannot send score to world score server.");
-#endif
+                       msg_print(_("初心者モードではワールドスコアに登録できません。",
+                       "Since you are in the Easy Mode, you cannot send score to world score server."));
                }
-#ifdef JP
-               else if(get_check_strict("スコアをスコア・サーバに登録しますか? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
-#else
-               else if(get_check_strict("Do you send score to the world score sever? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
-#endif
+               else if(get_check_strict(_("スコアをスコア・サーバに登録しますか? ", "Do you send score to the world score sever? "), 
+                               (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
                {
                        errr err;
                        prt("",0,0);
-#ifdef JP
-                       prt("送信中..",0,0);
-#else
-                       prt("Sending...",0,0);
-#endif
+                       prt(_("送信中..", "Sending..."),0,0);
                        Term_fresh();
                        screen_save();
                        err = report_score();
@@ -453,11 +442,7 @@ bool send_world_score(bool do_send)
                        {
                                return FALSE;
                        }
-#ifdef JP
-                       prt("完了。何かキーを押してください。", 0, 0);
-#else
-                       prt("Completed.  Hit any key.", 0, 0);
-#endif
+                       prt(_("完了。何かキーを押してください。", "Completed.  Hit any key."), 0, 0);
                        (void)inkey();
                }
                else return FALSE;
@@ -466,10 +451,12 @@ bool send_world_score(bool do_send)
        return TRUE;
 }
 
-/*
+/*!
+ * @brief スコアの過去二十位内ランキングを表示する
  * Enters a players name on a hi-score table, if "legal", and in any
  * case, displays some relevant portion of the high score list.
- *
+ * @return エラーコード
+ * @details
  * Assumes "signals_ignore_tstp()" has been called.
  */
 errr top_twenty(void)
@@ -512,7 +499,7 @@ 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 */
        sprintf(the_score.uid, "%7u", player_uid);
@@ -523,9 +510,9 @@ errr top_twenty(void)
 
        /* 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.cur_dun, "%3d", (int)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.max_dun, "%3d", (int)max_dlv[dungeon_type]);
 
        /* Save the cause of death (31 chars) */
        if (strlen(p_ptr->died_from) >= sizeof(the_score.how))
@@ -587,9 +574,10 @@ errr top_twenty(void)
        return (0);
 }
 
-
-/*
+/*!
+ * @brief プレイヤーの現在のスコアをランキングに挟む /
  * Predict the players location, and display it.
+ * @return エラーコード
  */
 errr predict_score(void)
 {
@@ -601,12 +589,7 @@ errr predict_score(void)
        /* No score file */
        if (highscore_fd < 0)
        {
-#ifdef JP
-msg_print("スコア・ファイルが使用できません。");
-#else
-               msg_print("Score file unavailable.");
-#endif
-
+               msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
                msg_print(NULL);
                return (0);
        }
@@ -626,15 +609,10 @@ msg_print("スコア・ファイルが使用できません。");
        sprintf(the_score.turns, "%9lu", (long)turn_real(turn));
 
        /* Hack -- no time needed */
-#ifdef JP
-strcpy(the_score.day, "今日");
-#else
-       strcpy(the_score.day, "TODAY");
-#endif
-
+       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 */
        sprintf(the_score.uid, "%7u", player_uid);
@@ -644,20 +622,14 @@ strcpy(the_score.day, "今日");
        sprintf(the_score.p_a, "%2d", p_ptr->pseikaku);
 
        /* 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", (int)p_ptr->lev);
+       sprintf(the_score.cur_dun, "%3d", (int)dun_level);
+       sprintf(the_score.max_lev, "%3d", (int)p_ptr->max_plv);
+       sprintf(the_score.max_dun, "%3d", (int)max_dlv[dungeon_type]);
 
        /* Hack -- no cause of death */
-#ifdef JP
        /* まだ死んでいないときの識別文字 */
-       strcpy(the_score.how, "yet");
-#else
-       strcpy(the_score.how, "nobody (yet!)");
-#endif
-
-
+       strcpy(the_score.how, _("yet", "nobody (yet!)"));
 
        /* See where the entry would be placed */
        j = highscore_where(&the_score);
@@ -682,16 +654,17 @@ strcpy(the_score.day, "今日");
 }
 
 
-
-/*
- * 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];
 
@@ -704,12 +677,7 @@ void show_highclass(void)
 
        if (highscore_fd < 0)
        {
-#ifdef JP
-msg_print("スコア・ファイルが使用できません。");
-#else
-               msg_print("Score file unavailable.");
-#endif
-
+               msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
                msg_print(NULL);
                return;
        }
@@ -728,7 +696,7 @@ msg_print("スコア・ファイルが使用できません。");
                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)",
@@ -745,21 +713,17 @@ msg_print("スコア・ファイルが使用できません。");
 
 #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);
 
        (void)fd_close(highscore_fd);
        highscore_fd = -1;
-#ifdef JP
-       prt("何かキーを押すとゲームに戻ります",0,0);
-#else
-       prt("Hit any key to continue",0,0);
-#endif
+       prt(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"),0,0);
 
        (void)inkey();
 
@@ -767,10 +731,11 @@ msg_print("スコア・ファイルが使用できません。");
        screen_load();
 }
 
-
-/*
- * Race Legends
- * -KMW-
+/*!
+ * @brief スコアランキングの簡易表示(種族毎)サブルーチン /
+ * Race Legends -KMW-
+ * @param race_num 種族ID
+ * @return なし
  */
 void race_score(int race_num)
 {
@@ -782,11 +747,7 @@ void race_score(int race_num)
        lastlev = 0;
 
        /* rr9: TODO - pluralize the race */
-#ifdef JP
-sprintf(tmp_str,"最高の%s", race_info[race_num].title);
-#else
-       sprintf(tmp_str,"The Greatest of all the %s", race_info[race_num].title);
-#endif
+       sprintf(tmp_str,_("最高の%s", "The Greatest of all the %s"), race_info[race_num].title);
 
        prt(tmp_str, 5, 15);
 
@@ -797,12 +758,7 @@ sprintf(tmp_str,"最高の%s", race_info[race_num].title);
 
        if (highscore_fd < 0)
        {
-#ifdef JP
-msg_print("スコア・ファイルが使用できません。");
-#else
-               msg_print("Score file unavailable.");
-#endif
-
+               msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
                msg_print(NULL);
                return;
        }
@@ -848,10 +804,10 @@ msg_print("スコア・ファイルが使用できません。");
        {
 #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);
@@ -862,9 +818,10 @@ msg_print("スコア・ファイルが使用できません。");
 }
 
 
-/*
- * Race Legends
- * -KMW-
+/*!
+ * @brief スコアランキングの簡易表示(種族毎)メインルーチン /
+ * Race Legends -KMW-
+ * @return なし
  */
 void race_legends(void)
 {
@@ -873,21 +830,17 @@ void race_legends(void)
        for (i = 0; i < MAX_RACES; i++)
        {
                race_score(i);
-#ifdef JP
-msg_print("何かキーを押すとゲームに戻ります");
-#else
-               msg_print("Hit any key to continue");
-#endif
-
+               msg_print(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"));
                msg_print(NULL);
                for (j = 5; j < 19; j++)
                        prt("", j, 0);
        }
 }
 
-
-/*
- * Change the player into a King!                      -RAK-
+/*!
+ * @brief 勝利者用の引退演出処理 /
+ * Change the player into a King! -RAK-
+ * @return なし
  */
 void kingly(void)
 {
@@ -900,13 +853,8 @@ void kingly(void)
 
        /* Fake death */
        if (!seppuku)
-#ifdef JP
                /* 引退したときの識別文字 */
-               (void)strcpy(p_ptr->died_from, "ripe");
-#else
-               (void)strcpy(p_ptr->died_from, "Ripe Old Age");
-#endif
-
+               (void)strcpy(p_ptr->died_from, _("ripe", "Ripe Old Age"));
 
        /* Restore the experience */
        p_ptr->exp = p_ptr->max_exp;
@@ -952,13 +900,8 @@ void kingly(void)
        /* If player did Seppuku, that is already written in playrecord */
        if (!seppuku)
        {
-#ifdef JP
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "ダンジョンの探索から引退した。");
-               do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ゲームオーバー --------");
-#else
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "retired exploring dungeons.");
-               do_cmd_write_nikki(NIKKI_GAMESTART, 1, "--------   Game  Over   --------");
-#endif
+               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索から引退した。", "retired exploring dungeons."));
+               do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
                do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
        }