OSDN Git Service

[Refactor] #38997 calc_score() に player_type * 引数を追加.
[hengband/hengband.git] / src / scores.c
index 08627d9..5104cc2 100644 (file)
  */
 
 #include "angband.h"
+#include "term.h"
 #include "util.h"
+#include "core.h"
 
+#include "dungeon.h"
 #include "player-race.h"
 #include "player-status.h"
 #include "player-class.h"
 #include "scores.h"
 #include "floor.h"
 #include "world.h"
+#include "cmd-dump.h"
+#include "report.h"
+#include "japanese.h"
+
+ /*
+  * The "highscore" file descriptor, if available.
+  */
+int highscore_fd = -1;
 
 /*!
  * @brief i番目のスコア情報にバッファ位置をシークする / Seek score 'i' in the highscore file
@@ -396,8 +407,6 @@ void display_scores_aux(int from, int to, int note, high_score *score)
 void display_scores(int from, int to)
 {
        char buf[1024];
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        /* Open the binary high score file, for reading */
@@ -485,7 +494,7 @@ errr top_twenty(void)
                FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
 
        /* Calculate and save the points */
-       sprintf(the_score.pts, "%9ld", (long)calc_score());
+       sprintf(the_score.pts, "%9ld", (long)calc_score(p_ptr));
        the_score.pts[9] = '\0';
 
        /* Save the current gold */
@@ -510,7 +519,7 @@ errr top_twenty(void)
        sprintf(the_score.who, "%-.15s", p_ptr->name);
 
        /* Save the player info */
-       sprintf(the_score.uid, "%7u", player_uid);
+       sprintf(the_score.uid, "%7u", p_ptr->player_uid);
        sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
        sprintf(the_score.p_r, "%2d", MIN(p_ptr->prace, MAX_RACES));
        sprintf(the_score.p_c, "%2d", MIN(p_ptr->pclass, MAX_CLASS));
@@ -608,7 +617,7 @@ errr predict_score(void)
                FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
 
        /* Calculate and save the points */
-       sprintf(the_score.pts, "%9ld", (long)calc_score());
+       sprintf(the_score.pts, "%9ld", (long)calc_score(p_ptr));
 
        /* Save the current gold */
        sprintf(the_score.gold, "%9lu", (long)p_ptr->au);
@@ -623,7 +632,7 @@ errr predict_score(void)
        sprintf(the_score.who, "%-.15s", p_ptr->name);
 
        /* Save the player info */
-       sprintf(the_score.uid, "%7u", player_uid);
+       sprintf(the_score.uid, "%7u", p_ptr->player_uid);
        sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
        sprintf(the_score.p_r, "%2d", MIN(p_ptr->prace, MAX_RACES));
        sprintf(the_score.p_c, "%2d", MIN(p_ptr->pclass, MAX_CLASS));
@@ -677,8 +686,6 @@ void show_highclass(void)
        char buf[1024], out_val[256];
 
        screen_save();
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        highscore_fd = fd_open(buf, O_RDONLY);
@@ -758,8 +765,6 @@ void race_score(int race_num)
        sprintf(tmp_str,_("最高の%s", "The Greatest of all the %s"), race_info[race_num].title);
 
        prt(tmp_str, 5, 15);
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        highscore_fd = fd_open(buf, O_RDONLY);
@@ -917,3 +922,69 @@ void kingly(void)
        /* Wait for response */
        pause_line(hgt - 1);
 }
+
+/*!
+ * @brief スコアファイル出力
+ * Display some character info
+ * @return なし
+ */
+bool check_score(void)
+{
+       Term_clear();
+
+       /* No score file */
+       if (highscore_fd < 0)
+       {
+               msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
+               msg_print(NULL);
+               return FALSE;
+       }
+
+#ifndef SCORE_WIZARDS
+       /* Wizard-mode pre-empts scoring */
+       if (p_ptr->noscore & 0x000F)
+       {
+               msg_print(_("ウィザード・モードではスコアが記録されません。", "Score not registered for wizards."));
+               msg_print(NULL);
+               return FALSE;
+       }
+#endif
+
+#ifndef SCORE_BORGS
+       /* Borg-mode pre-empts scoring */
+       if (p_ptr->noscore & 0x00F0)
+       {
+               msg_print(_("ボーグ・モードではスコアが記録されません。", "Score not registered for borgs."));
+               msg_print(NULL);
+               return FALSE;
+       }
+#endif
+
+#ifndef SCORE_CHEATERS
+       /* Cheaters are not scored */
+       if (p_ptr->noscore & 0xFF00)
+       {
+               msg_print(_("詐欺をやった人はスコアが記録されません。", "Score not registered for cheaters."));
+               msg_print(NULL);
+               return FALSE;
+       }
+#endif
+
+       /* Interupted */
+       if (!p_ptr->total_winner && streq(p_ptr->died_from, _("強制終了", "Interrupting")))
+       {
+               msg_print(_("強制終了のためスコアが記録されません。", "Score not registered due to interruption."));
+               msg_print(NULL);
+               return FALSE;
+       }
+
+       /* Quitter */
+       if (!p_ptr->total_winner && streq(p_ptr->died_from, _("途中終了", "Quitting")))
+       {
+               msg_print(_("途中終了のためスコアが記録されません。", "Score not registered due to quitting."));
+               msg_print(NULL);
+               return FALSE;
+       }
+       return TRUE;
+}
+