OSDN Git Service

#37287 (2.2.0.40) cmd1.c内のC4457警告に対応。 / Deal C4457 warning in cmd1.c.
[hengband/hengband.git] / src / scores.c
1 /*!
2  * @file scores.c
3  * @brief ハイスコア処理 / Highscores handling
4  * @date 2014/07/14
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  * This software may be copied and distributed for educational, research,
8  * and not for profit purposes provided that this copyright and statement
9  * are included in all such copies.  Other copyrights may also apply.
10  * 2014 Deskull rearranged comment for Doxygen.
11  */
12
13 #include "angband.h"
14
15 /*!
16  * @brief i番目のスコア情報にバッファ位置をシークする / Seek score 'i' in the highscore file
17  * @param i スコア情報ID
18  * @return 問題がなければ0を返す
19  */
20 static int highscore_seek(int i)
21 {
22         /* Seek for the requested record */
23         return (fd_seek(highscore_fd, (huge)(i) * sizeof(high_score)));
24 }
25
26
27 /*!
28  * @brief 所定ポインタからスコア情報を読み取る / Read one score from the highscore file
29  * @param score スコア情報参照ポインタ
30  * @return エラーコード
31  */
32 static errr highscore_read(high_score *score)
33 {
34         /* Read the record, note failure */
35         return (fd_read(highscore_fd, (char*)(score), sizeof(high_score)));
36 }
37
38
39 /*!
40  * @brief 所定ポインタへスコア情報を書き込む / Write one score to the highscore file
41  * @param score スコア情報参照ポインタ
42  * @return エラーコード(問題がなければ0を返す)
43  */
44 static int highscore_write(high_score *score)
45 {
46         /* Write the record, note failure */
47         return (fd_write(highscore_fd, (char*)(score), sizeof(high_score)));
48 }
49
50 /*!
51  * @brief スコア情報を全て得るまで繰り返し取得する / Just determine where a new score *would* be placed
52  * @param score スコア情報参照ポインタ
53  * @return 正常ならば(MAX_HISCORES - 1)、問題があれば-1を返す
54  */
55 static int highscore_where(high_score *score)
56 {
57         int                     i;
58
59         high_score              the_score;
60         int my_score;
61
62         my_score = atoi(score->pts);
63
64         /* Paranoia -- it may not have opened */
65         if (highscore_fd < 0) return (-1);
66
67         /* Go to the start of the highscore file */
68         if (highscore_seek(0)) return (-1);
69
70         /* Read until we get to a higher score */
71         for (i = 0; i < MAX_HISCORES; i++)
72         {
73                 int old_score;
74                 if (highscore_read(&the_score)) return (i);
75                 old_score = atoi(the_score.pts);
76 /*              if (strcmp(the_score.pts, score->pts) < 0) return (i); */
77                 if (my_score > old_score) return (i);
78         }
79
80         /* The "last" entry is always usable */
81         return (MAX_HISCORES - 1);
82 }
83
84
85 /*!
86  * @brief スコア情報をバッファの末尾に追加する / Actually place an entry into the high score file
87  * @param score スコア情報参照ポインタ
88  * @return 正常ならば書き込んだスロット位置、問題があれば-1を返す / Return the location (0 is best) or -1 on "failure"
89  */
90 static int highscore_add(high_score *score)
91 {
92         int                     i, slot;
93         bool            done = FALSE;
94
95         high_score              the_score, tmpscore;
96
97
98         /* Paranoia -- it may not have opened */
99         if (highscore_fd < 0) return (-1);
100
101         /* Determine where the score should go */
102         slot = highscore_where(score);
103
104         /* Hack -- Not on the list */
105         if (slot < 0) return (-1);
106
107         /* Hack -- prepare to dump the new score */
108         the_score = (*score);
109
110         /* Slide all the scores down one */
111         for (i = slot; !done && (i < MAX_HISCORES); i++)
112         {
113                 /* Read the old guy, note errors */
114                 if (highscore_seek(i)) return (-1);
115                 if (highscore_read(&tmpscore)) done = TRUE;
116
117                 /* Back up and dump the score we were holding */
118                 if (highscore_seek(i)) return (-1);
119                 if (highscore_write(&the_score)) return (-1);
120
121                 /* Hack -- Save the old score, for the next pass */
122                 the_score = tmpscore;
123         }
124
125         /* Return location used */
126         return (slot);
127 }
128
129
130
131 /*!
132  * @brief 指定された順位範囲でスコアを並べて表示する / Display the scores in a given range.
133  * @param from 順位先頭
134  * @param to 順位末尾
135  * @param note 黄色表示でハイライトする順位
136  * @param score スコア配列参照ポインタ
137  * @return なし
138  * @details
139  * <pre>
140  * Assumes the high score list is already open.
141  * Only five entries per line, too much info.
142  *
143  * Mega-Hack -- allow "fake" entry at the given position.
144  * </pre>
145  */
146 void display_scores_aux(int from, int to, int note, high_score *score)
147 {
148         int             i, j, k, n, place;
149         byte attr;
150
151         high_score      the_score;
152
153         char    out_val[256];
154         char    tmp_val[160];
155
156         int wid, hgt, per_screen;
157
158         Term_get_size(&wid, &hgt);
159         per_screen = (hgt - 4) / 4;
160
161         /* Paranoia -- it may not have opened */
162         if (highscore_fd < 0) return;
163
164
165         /* Assume we will show the first 10 */
166         if (from < 0) from = 0;
167         if (to < 0) to = 10;
168         if (to > MAX_HISCORES) to = MAX_HISCORES;
169
170
171         /* Seek to the beginning */
172         if (highscore_seek(0)) return;
173
174         /* Hack -- Count the high scores */
175         for (i = 0; i < MAX_HISCORES; i++)
176         {
177                 if (highscore_read(&the_score)) break;
178         }
179
180         /* Hack -- allow "fake" entry to be last */
181         if ((note == i) && score) i++;
182
183         /* Forget about the last entries */
184         if (i > to) i = to;
185
186
187         /* Show per_screen per page, until "done" */
188         for (k = from, place = k+1; k < i; k += per_screen)
189         {
190                 /* Clear screen */
191                 Term_clear();
192
193                 /* Title */
194                 put_str(_("                変愚蛮怒: 勇者の殿堂", "                Hengband Hall of Fame"), 0, 0);
195
196                 /* Indicate non-top scores */
197                 if (k > 0)
198                 {
199                         sprintf(tmp_val, _("( %d 位以下 )", "(from position %d)"), k + 1);
200                         put_str(tmp_val, 0, 40);
201                 }
202
203                 /* Dump per_screen entries */
204                 for (j = k, n = 0; j < i && n < per_screen; place++, j++, n++)
205                 {
206                         int pr, pc, pa, clev, mlev, cdun, mdun;
207
208                         cptr user, gold, when, aged;
209
210
211                         /* Hack -- indicate death in yellow */
212                         attr = (j == note) ? TERM_YELLOW : TERM_WHITE;
213
214
215                         /* Mega-Hack -- insert a "fake" record */
216                         if ((note == j) && score)
217                         {
218                                 the_score = (*score);
219                                 attr = TERM_L_GREEN;
220                                 score = NULL;
221                                 note = -1;
222                                 j--;
223                         }
224
225                         /* Read a normal record */
226                         else
227                         {
228                                 /* Read the proper record */
229                                 if (highscore_seek(j)) break;
230                                 if (highscore_read(&the_score)) break;
231                         }
232
233                         /* Extract the race/class */
234                         pr = atoi(the_score.p_r);
235                         pc = atoi(the_score.p_c);
236                         pa = atoi(the_score.p_a);
237
238                         /* Extract the level info */
239                         clev = atoi(the_score.cur_lev);
240                         mlev = atoi(the_score.max_lev);
241                         cdun = atoi(the_score.cur_dun);
242                         mdun = atoi(the_score.max_dun);
243
244                         /* Hack -- extract the gold and such */
245                         for (user = the_score.uid; iswspace(*user); user++) /* loop */;
246                         for (when = the_score.day; iswspace(*when); when++) /* loop */;
247                         for (gold = the_score.gold; iswspace(*gold); gold++) /* loop */;
248                         for (aged = the_score.turns; iswspace(*aged); aged++) /* loop */;
249
250                         /* Clean up standard encoded form of "when" */
251                         if ((*when == '@') && strlen(when) == 9)
252                         {
253                                 sprintf(tmp_val, "%.4s-%.2s-%.2s",
254                                         when + 1, when + 5, when + 7);
255                                 when = tmp_val;
256                         }
257
258                         /* Dump some info */
259 #ifdef JP
260 /*sprintf(out_val, "%3d.%9s  %s%s%sという名の%sの%s (レベル %d)", */
261                         sprintf(out_val, "%3d.%9s  %s%s%s - %s%s (レベル %d)",
262                                 place, the_score.pts,
263                                 seikaku_info[pa].title, (seikaku_info[pa].no ? "の" : ""),
264                                 the_score.who,
265                                 race_info[pr].title, class_info[pc].title,
266                                 clev);
267
268 #else
269                         sprintf(out_val, "%3d.%9s  %s %s the %s %s, Level %d",
270                                 place, the_score.pts,
271                                 seikaku_info[pa].title,
272                                 the_score.who, race_info[pr].title, class_info[pc].title,
273                                 clev);
274 #endif
275
276
277                         /* Append a "maximum level" */
278                         if (mlev > clev) strcat(out_val, format(_(" (最高%d)", " (Max %d)"), mlev));
279
280                         /* Dump the first line */
281                         c_put_str(attr, out_val, n*4 + 2, 0);
282
283                         /* Another line of info */
284 #ifdef JP
285                         if (mdun != 0)
286                                 sprintf(out_val, "    最高%3d階", mdun);
287                         else
288                                 sprintf(out_val, "             ");
289
290
291                         /* 死亡原因をオリジナルより細かく表示 */
292                         if (streq(the_score.how, "yet"))
293                         {
294                                 sprintf(out_val+13, "  まだ生きている (%d%s)",
295                                        cdun, "階");
296                         }
297                         else
298                         if (streq(the_score.how, "ripe"))
299                         {
300                                 sprintf(out_val+13, "  勝利の後に引退 (%d%s)",
301                                         cdun, "階");
302                         }
303                         else if (streq(the_score.how, "Seppuku"))
304                         {
305                                 sprintf(out_val+13, "  勝利の後に切腹 (%d%s)",
306                                         cdun, "階");
307                         }
308                         else
309                         {
310                                 codeconv(the_score.how);
311
312                                 /* Some people die outside of the dungeon */
313                                 if (!cdun)
314                                         sprintf(out_val+13, "  地上で%sに殺された", the_score.how);
315                                 else
316                                         sprintf(out_val+13, "  %d階で%sに殺された",
317                                                 cdun, the_score.how);
318                         }
319
320 #else
321                         /* Some people die outside of the dungeon */
322                         if (!cdun)
323                                 sprintf(out_val, 
324                                         "               Killed by %s on the surface",
325                                         the_score.how);
326                         else
327                                 sprintf(out_val, 
328                                         "               Killed by %s on %s %d",
329                                         the_score.how, "Dungeon Level", cdun);
330
331                         /* Append a "maximum level" */
332                         if (mdun > cdun) strcat(out_val, format(" (Max %d)", mdun));
333 #endif
334
335                         /* Dump the info */
336                         c_put_str(attr, out_val, n*4 + 3, 0);
337
338                         /* And still another line of info */
339 #ifdef JP
340                         {
341                                 char buf[11];
342
343                                 /* 日付を 19yy/mm/dd の形式に変更する */
344                                 if (strlen(when) == 8 && when[2] == '/' && when[5] == '/') {
345                                         sprintf(buf, "%d%s/%.5s", 19 + (when[6] < '8'), when + 6, when);
346                                         when = buf;
347                                 }
348                                 sprintf(out_val,
349                                                 "        (ユーザー:%s, 日付:%s, 所持金:%s, ターン:%s)",
350                                                 user, when, gold, aged);
351                         }
352
353 #else
354                         sprintf(out_val,
355                                 "               (User %s, Date %s, Gold %s, Turn %s).",
356                                 user, when, gold, aged);
357 #endif
358
359                         c_put_str(attr, out_val, n*4 + 4, 0);
360                 }
361
362
363                 /* Wait for response */
364                 prt(_("[ ESCで中断, その他のキーで続けます ]", "[Press ESC to quit, any other key to continue.]"), hgt - 1, _(21, 17));
365
366                 j = inkey();
367                 prt("", hgt - 1, 0);
368
369                 /* Hack -- notice Escape */
370                 if (j == ESCAPE) break;
371         }
372 }
373
374
375 /*!
376  * @brief スコア表示処理メインルーチン / Hack -- Display the scores in a given range and quit.
377  * @param from 順位先頭
378  * @param to 順位末尾
379  * @return なし
380  * @details
381  * <pre>
382  * This function is only called from "main.c" when the user asks
383  * to see the "high scores".
384  * </pre>
385  */
386 void display_scores(int from, int to)
387 {
388         char buf[1024];
389
390         /* Build the filename */
391         path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
392
393         /* Open the binary high score file, for reading */
394         highscore_fd = fd_open(buf, O_RDONLY);
395
396         /* Paranoia -- No score file */
397         if (highscore_fd < 0) quit(_("スコア・ファイルが使用できません。", "Score file unavailable."));
398
399         /* Clear screen */
400         Term_clear();
401
402         /* Display the scores */
403         display_scores_aux(from, to, -1, NULL);
404
405         /* Shut the high score file */
406         (void)fd_close(highscore_fd);
407
408         /* Forget the high score fd */
409         highscore_fd = -1;
410
411         /* Quit */
412         quit(NULL);
413 }
414
415
416 /*!
417  * @brief スコアサーバへの転送処理
418  * @param do_send 実際に転送ア処置を行うか否か
419  * @return 転送が成功したらTRUEを返す
420  */
421 bool send_world_score(bool do_send)
422 {
423 #ifdef WORLD_SCORE
424         if(send_score && do_send)
425         {
426                 if(easy_band)
427                 {
428                         msg_print(_("初心者モードではワールドスコアに登録できません。",
429                         "Since you are in the Easy Mode, you cannot send score to world score server."));
430                 }
431                 else if(get_check_strict(_("スコアをスコア・サーバに登録しますか? ", "Do you send score to the world score sever? "), 
432                                 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
433                 {
434                         errr err;
435                         prt("",0,0);
436                         prt(_("送信中..", "Sending..."),0,0);
437                         Term_fresh();
438                         screen_save();
439                         err = report_score();
440                         screen_load();
441                         if (err)
442                         {
443                                 return FALSE;
444                         }
445                         prt(_("完了。何かキーを押してください。", "Completed.  Hit any key."), 0, 0);
446                         (void)inkey();
447                 }
448                 else return FALSE;
449         }
450 #endif
451         return TRUE;
452 }
453
454 /*!
455  * @brief スコアの過去二十位内ランキングを表示する
456  * Enters a players name on a hi-score table, if "legal", and in any
457  * case, displays some relevant portion of the high score list.
458  * @return エラーコード
459  * @details
460  * Assumes "signals_ignore_tstp()" has been called.
461  */
462 errr top_twenty(void)
463 {
464         int          j;
465
466         high_score   the_score;
467
468         time_t ct = time((time_t*)0);
469
470         errr err;
471
472         /* Clear the record */
473         (void)WIPE(&the_score, high_score);
474
475         /* Save the version */
476         sprintf(the_score.what, "%u.%u.%u",
477                 FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
478
479         /* Calculate and save the points */
480         sprintf(the_score.pts, "%9ld", (long)total_points());
481         the_score.pts[9] = '\0';
482
483         /* Save the current gold */
484         sprintf(the_score.gold, "%9lu", (long)p_ptr->au);
485         the_score.gold[9] = '\0';
486
487         /* Save the current turn */
488         sprintf(the_score.turns, "%9lu", (long)turn_real(turn));
489         the_score.turns[9] = '\0';
490
491 #ifdef HIGHSCORE_DATE_HACK
492         /* Save the date in a hacked up form (9 chars) */
493         (void)sprintf(the_score.day, "%-.6s %-.2s", ctime(&ct) + 4, ctime(&ct) + 22);
494 #else
495         /* Save the date in standard form (8 chars) */
496 /*      (void)strftime(the_score.day, 9, "%m/%d/%y", localtime(&ct)); */
497         /* Save the date in standard encoded form (9 chars) */
498         strftime(the_score.day, 10, "@%Y%m%d", localtime(&ct));
499 #endif
500
501         /* Save the player name (15 chars) */
502         sprintf(the_score.who, "%-.15s", p_ptr->name);
503
504         /* Save the player info XXX XXX XXX */
505         sprintf(the_score.uid, "%7u", player_uid);
506         sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
507         sprintf(the_score.p_r, "%2d", p_ptr->prace);
508         sprintf(the_score.p_c, "%2d", p_ptr->pclass);
509         sprintf(the_score.p_a, "%2d", p_ptr->pseikaku);
510
511         /* Save the level and such */
512         sprintf(the_score.cur_lev, "%3d", p_ptr->lev);
513         sprintf(the_score.cur_dun, "%3d", dun_level);
514         sprintf(the_score.max_lev, "%3d", p_ptr->max_plv);
515         sprintf(the_score.max_dun, "%3d", max_dlv[dungeon_type]);
516
517         /* Save the cause of death (31 chars) */
518         if (strlen(p_ptr->died_from) >= sizeof(the_score.how))
519         {
520 #ifdef JP
521                 my_strcpy(the_score.how, p_ptr->died_from, sizeof(the_score.how) - 2);
522                 strcat(the_score.how, "…");
523 #else
524                 my_strcpy(the_score.how, p_ptr->died_from, sizeof(the_score.how) - 3);
525                 strcat(the_score.how, "...");
526 #endif
527         }
528         else
529         {
530                 strcpy(the_score.how, p_ptr->died_from);
531         }
532
533         /* Grab permissions */
534         safe_setuid_grab();
535
536         /* Lock (for writing) the highscore file, or fail */
537         err = fd_lock(highscore_fd, F_WRLCK);
538
539         /* Drop permissions */
540         safe_setuid_drop();
541
542         if (err) return (1);
543
544         /* Add a new entry to the score list, see where it went */
545         j = highscore_add(&the_score);
546
547         /* Grab permissions */
548         safe_setuid_grab();
549
550         /* Unlock the highscore file, or fail */
551         err = fd_lock(highscore_fd, F_UNLCK);
552
553         /* Drop permissions */
554         safe_setuid_drop();
555
556         if (err) return (1);
557
558
559         /* Hack -- Display the top fifteen scores */
560         if (j < 10)
561         {
562                 display_scores_aux(0, 15, j, NULL);
563         }
564
565         /* Display the scores surrounding the player */
566         else
567         {
568                 display_scores_aux(0, 5, j, NULL);
569                 display_scores_aux(j - 2, j + 7, j, NULL);
570         }
571
572
573         /* Success */
574         return (0);
575 }
576
577 /*!
578  * @brief プレイヤーの現在のスコアをランキングに挟む /
579  * Predict the players location, and display it.
580  * @return エラーコード
581  */
582 errr predict_score(void)
583 {
584         int          j;
585
586         high_score   the_score;
587
588
589         /* No score file */
590         if (highscore_fd < 0)
591         {
592                 msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
593                 msg_print(NULL);
594                 return (0);
595         }
596
597
598         /* Save the version */
599         sprintf(the_score.what, "%u.%u.%u",
600                 FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
601
602         /* Calculate and save the points */
603         sprintf(the_score.pts, "%9ld", (long)total_points());
604
605         /* Save the current gold */
606         sprintf(the_score.gold, "%9lu", (long)p_ptr->au);
607
608         /* Save the current turn */
609         sprintf(the_score.turns, "%9lu", (long)turn_real(turn));
610
611         /* Hack -- no time needed */
612         strcpy(the_score.day, _("今日", "TODAY"));
613
614         /* Save the player name (15 chars) */
615         sprintf(the_score.who, "%-.15s", p_ptr->name);
616
617         /* Save the player info XXX XXX XXX */
618         sprintf(the_score.uid, "%7u", player_uid);
619         sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f'));
620         sprintf(the_score.p_r, "%2d", p_ptr->prace);
621         sprintf(the_score.p_c, "%2d", p_ptr->pclass);
622         sprintf(the_score.p_a, "%2d", p_ptr->pseikaku);
623
624         /* Save the level and such */
625         sprintf(the_score.cur_lev, "%3d", p_ptr->lev);
626         sprintf(the_score.cur_dun, "%3d", dun_level);
627         sprintf(the_score.max_lev, "%3d", p_ptr->max_plv);
628         sprintf(the_score.max_dun, "%3d", max_dlv[dungeon_type]);
629
630         /* Hack -- no cause of death */
631         /* まだ死んでいないときの識別文字 */
632         strcpy(the_score.how, _("yet", "nobody (yet!)"));
633
634         /* See where the entry would be placed */
635         j = highscore_where(&the_score);
636
637
638         /* Hack -- Display the top fifteen scores */
639         if (j < 10)
640         {
641                 display_scores_aux(0, 15, j, &the_score);
642         }
643
644         /* Display some "useful" scores */
645         else
646         {
647                 display_scores_aux(0, 5, -1, NULL);
648                 display_scores_aux(j - 2, j + 7, j, &the_score);
649         }
650
651
652         /* Success */
653         return (0);
654 }
655
656
657 /*!
658  * @brief スコアランキングの簡易表示 /
659  * show_highclass - selectively list highscores based on class -KMW-
660  * @return なし
661  */
662 void show_highclass(void)
663 {
664
665         register int i = 0, j, m = 0;
666         int pr, clev/*, al*/;
667         high_score the_score;
668         char buf[1024], out_val[256];
669
670         screen_save();
671
672         /* Build the filename */
673         path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
674
675         highscore_fd = fd_open(buf, O_RDONLY);
676
677         if (highscore_fd < 0)
678         {
679                 msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
680                 msg_print(NULL);
681                 return;
682         }
683
684         if (highscore_seek(0)) return;
685
686         for (i = 0; i < MAX_HISCORES; i++)
687                 if (highscore_read(&the_score)) break;
688
689         m = 0;
690         j = 0;
691         clev = 0;
692
693         while ((m < 9) && (j < MAX_HISCORES))
694         {
695                 if (highscore_seek(j)) break;
696                 if (highscore_read(&the_score)) break;
697                 pr = atoi(the_score.p_r);
698                 clev = atoi(the_score.cur_lev);
699
700 #ifdef JP
701                 sprintf(out_val, "   %3d) %sの%s (レベル %2d)",
702                     (m + 1), race_info[pr].title,the_score.who, clev);
703 #else
704                 sprintf(out_val, "%3d) %s the %s (Level %2d)",
705                     (m + 1), the_score.who, race_info[pr].title, clev);
706 #endif
707
708                 prt(out_val, (m + 7), 0);
709                 m++;
710                 j++;
711         }
712
713 #ifdef JP
714         sprintf(out_val, "あなた) %sの%s (レベル %2d)",
715             race_info[p_ptr->prace].title,p_ptr->name, p_ptr->lev);
716 #else
717         sprintf(out_val, "You) %s the %s (Level %2d)",
718             p_ptr->name, race_info[p_ptr->prace].title, p_ptr->lev);
719 #endif
720
721         prt(out_val, (m + 8), 0);
722
723         (void)fd_close(highscore_fd);
724         highscore_fd = -1;
725         prt(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"),0,0);
726
727         (void)inkey();
728
729         for (j = 5; j < 18; j++) prt("", j, 0);
730         screen_load();
731 }
732
733 /*!
734  * @brief スコアランキングの簡易表示(種族毎)サブルーチン /
735  * Race Legends -KMW-
736  * @param race_num 種族ID
737  * @return なし
738  */
739 void race_score(int race_num)
740 {
741         register int i = 0, j, m = 0;
742         int pr, clev, lastlev;
743         high_score the_score;
744         char buf[1024], out_val[256], tmp_str[80];
745
746         lastlev = 0;
747
748         /* rr9: TODO - pluralize the race */
749         sprintf(tmp_str,_("最高の%s", "The Greatest of all the %s"), race_info[race_num].title);
750
751         prt(tmp_str, 5, 15);
752
753         /* Build the filename */
754         path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
755
756         highscore_fd = fd_open(buf, O_RDONLY);
757
758         if (highscore_fd < 0)
759         {
760                 msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
761                 msg_print(NULL);
762                 return;
763         }
764
765         if (highscore_seek(0)) return;
766
767         for (i = 0; i < MAX_HISCORES; i++)
768         {
769                 if (highscore_read(&the_score)) break;
770         }
771
772         m = 0;
773         j = 0;
774
775         while ((m < 10) || (j < MAX_HISCORES))
776         {
777                 if (highscore_seek(j)) break;
778                 if (highscore_read(&the_score)) break;
779                 pr = atoi(the_score.p_r);
780                 clev = atoi(the_score.cur_lev);
781
782                 if (pr == race_num)
783                 {
784 #ifdef JP
785                 sprintf(out_val, "   %3d) %sの%s (レベル %2d)",
786                             (m + 1), race_info[pr].title, 
787                                 the_score.who,clev);
788 #else
789                         sprintf(out_val, "%3d) %s the %s (Level %3d)",
790                             (m + 1), the_score.who,
791                         race_info[pr].title, clev);
792 #endif
793
794                         prt(out_val, (m + 7), 0);
795                         m++;
796                         lastlev = clev;
797                 }
798                 j++;
799         }
800
801         /* add player if qualified */
802         if ((p_ptr->prace == race_num) && (p_ptr->lev >= lastlev))
803         {
804 #ifdef JP
805         sprintf(out_val, "あなた) %sの%s (レベル %2d)",
806                      race_info[p_ptr->prace].title,p_ptr->name, p_ptr->lev);
807 #else
808                 sprintf(out_val, "You) %s the %s (Level %3d)",
809                     p_ptr->name, race_info[p_ptr->prace].title, p_ptr->lev);
810 #endif
811
812                 prt(out_val, (m + 8), 0);
813         }
814
815         (void)fd_close(highscore_fd);
816         highscore_fd = -1;
817 }
818
819
820 /*!
821  * @brief スコアランキングの簡易表示(種族毎)メインルーチン /
822  * Race Legends -KMW-
823  * @return なし
824  */
825 void race_legends(void)
826 {
827         int i, j;
828
829         for (i = 0; i < MAX_RACES; i++)
830         {
831                 race_score(i);
832                 msg_print(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"));
833                 msg_print(NULL);
834                 for (j = 5; j < 19; j++)
835                         prt("", j, 0);
836         }
837 }
838
839 /*!
840  * @brief 勝利者用の引退演出処理 /
841  * Change the player into a King! -RAK-
842  * @return なし
843  */
844 void kingly(void)
845 {
846         int wid, hgt;
847         int cx, cy;
848         bool seppuku = streq(p_ptr->died_from, "Seppuku");
849
850         /* Hack -- retire in town */
851         dun_level = 0;
852
853         /* Fake death */
854         if (!seppuku)
855                 /* 引退したときの識別文字 */
856                 (void)strcpy(p_ptr->died_from, _("ripe", "Ripe Old Age"));
857
858         /* Restore the experience */
859         p_ptr->exp = p_ptr->max_exp;
860
861         /* Restore the level */
862         p_ptr->lev = p_ptr->max_plv;
863
864         Term_get_size(&wid, &hgt);
865         cy = hgt / 2;
866         cx = wid / 2;
867
868         /* Hack -- Instant Gold */
869         p_ptr->au += 10000000L;
870
871         /* Clear screen */
872         Term_clear();
873
874         /* Display a crown */
875         put_str("#", cy - 11, cx - 1);
876         put_str("#####", cy - 10, cx - 3);
877         put_str("#", cy - 9, cx - 1);
878         put_str(",,,  $$$  ,,,", cy - 8, cx - 7);
879         put_str(",,=$   \"$$$$$\"   $=,,", cy - 7, cx - 11);
880         put_str(",$$        $$$        $$,", cy - 6, cx - 13);
881         put_str("*>         <*>         <*", cy - 5, cx - 13);
882         put_str("$$         $$$         $$", cy - 4, cx - 13);
883         put_str("\"$$        $$$        $$\"", cy - 3, cx - 13);
884         put_str("\"$$       $$$       $$\"", cy - 2, cx - 12);
885         put_str("*#########*#########*", cy - 1, cx - 11);
886         put_str("*#########*#########*", cy, cx - 11);
887
888         /* Display a message */
889 #ifdef JP
890         put_str("Veni, Vidi, Vici!", cy + 3, cx - 9);
891         put_str("来た、見た、勝った!", cy + 4, cx - 10);
892         put_str(format("偉大なる%s万歳!", sp_ptr->winner), cy + 5, cx - 11);
893 #else
894         put_str("Veni, Vidi, Vici!", cy + 3, cx - 9);
895         put_str("I came, I saw, I conquered!", cy + 4, cx - 14);
896         put_str(format("All Hail the Mighty %s!", sp_ptr->winner), cy + 5, cx - 13);
897 #endif
898
899         /* If player did Seppuku, that is already written in playrecord */
900         if (!seppuku)
901         {
902                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索から引退した。", "retired exploring dungeons."));
903                 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
904                 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
905         }
906
907         /* Flush input */
908         flush();
909
910         /* Wait for response */
911         pause_line(hgt - 1);
912 }