OSDN Git Service

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