git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@664 c06c8d41-db1a-0410-9941-cceddc491573
GR6ZABTGAAQTKZBVA7PTOYQG6G3ACF62ITT5COLHTRN2HGIPRG2AC
}
static void hiscores_print_entry(const scorefile_entry &se,
int index,
int format,
int (*pf)(const char *, ...))
{
char buf[INFO_SIZE];
// print position (tracked implicitly by order score file)
snprintf( buf, sizeof buf, "%3d.", index + 1 );
pf("%s", buf);
std::string entry;
// format the entry
if (format == SCORE_TERSE)
{
entry = hiscores_format_single( se );
// truncate if we want short format
if (entry.length() > 75)
entry = entry.substr(0, 75);
}
else
{
entry = hiscores_format_single_long( se, (format == SCORE_VERBOSE) );
}
entry += EOL;
pf("%s", entry.c_str());
}
// Writes all entries in the scorefile to stdout in human-readable form.
void hiscores_print_all(int display_count, int format)
{
FILE *scores = hs_open("r", score_file_name());
if (scores == NULL)
{
// will only happen from command line
puts( "No scores." );
return;
}
for (int entry = 0; display_count <= 0 || entry < display_count; ++entry)
{
scorefile_entry se;
if (!hs_read(scores, se))
break;
hiscores_print_entry(se, entry, format, printf);
}
hs_close( scores, "r", score_file_name() );
// print position (tracked implicitly by order score file)
snprintf( info, INFO_SIZE, "%3d.", i + 1 );
if (use_printf)
printf("%s", info);
else
cprintf("%s", info);
std::string entry;
// format the entry
if (format == SCORE_TERSE)
{
entry = hiscores_format_single( hs_list[i] );
// truncate if we want short format
if (entry.length() > 75)
entry = entry.substr(0, 75);
}
else
{
entry = hiscores_format_single_long( hs_list[i],
(format == SCORE_VERBOSE) );
}
entry += EOL;
if(use_printf)
printf("%s", entry.c_str());
else
cprintf("%s", entry.c_str());
hiscores_print_entry(hs_list[i], i, format, cprintf);