Go to the documentation of this file.
18 #define _GNU_SOURCE // strcasestr() is a GNU extension in string.h
25 #include <sys/types.h>
70 snprintf(
buf, size,
"%s:%s:%"FMT64":%s:%s:%d:%d:%d", sc->
name, sc->
title, sc->
exp, sc->
killer, sc->
maplevel, sc->
maxhp, sc->
maxsp, sc->
maxgrace);
94 fprintf(fp,
"%s\n",
buf);
115 cp = strchr(bp,
'\n');
160 if (strcmp(sc->
killer,
"quit") == 0 || strcmp(sc->
killer,
"left") == 0) {
163 }
else if (strcmp(sc->
killer,
"a dungeon collapse") == 0) {
167 s1 =
"was killed by";
170 snprintf(
buf, size,
"[fixed]%3d %10"FMT64"[print] %s%s%s %s %s on map %s <%d><%d><%d>.",
171 sc->
position, sc->
exp, sc->
name, sc->
title[0]==
',' ?
"" :
" ", sc->
title, s1, s2, sc->
maplevel, sc->
maxhp, sc->
maxsp, sc->
maxgrace);
190 memset(old_score, 0,
sizeof(*old_score));
196 table->
entry[i] = *new_score;
201 *old_score = table->
entry[i];
203 table->
entry[i] = *new_score;
220 table->
entry[i] = *new_score;
225 while (i > 0 && new_score->
exp >= table->
entry[i-1].
exp) {
254 fp = fopen(table->
fname,
"r");
256 if (errno == ENOENT) {
259 LOG(
llevError,
"Cannot open highscore file %s: %s\n", table->
fname, strerror(errno));
280 memset(&table->
entry[i], 0,
sizeof(table->
entry[i]));
352 if (
op->stats.exp == 0 || !
op->contr->name_changed)
358 "Since you have been in wizard mode, "
359 "you can't enter the high-score list.");
362 if (!
op->stats.exp) {
365 "You don't deserve to save your character yet.");
374 if (new_score.
killer[0] ==
'\0') {
375 strcpy(new_score.
killer,
"a dungeon collapse");
378 if (
op->map == NULL) {
385 new_score.
maxsp = (
int)
op->stats.maxsp;
389 if (!
tmp->stats.exp)
continue;
390 new_score.
exp =
tmp->stats.exp;
393 if (!quiet && new_score.
exp > old_score.
exp) {
395 "You improved your rating in %s: %" FMT64,
tmp->name, new_score.
exp);
404 new_score.
exp =
op->stats.exp;
417 message =
"You didn't enter the highscore list:";
419 message =
"You entered the highscore list:";
422 message =
"You left the highscore list:";
423 else if (new_score.
exp > old_score.
exp)
424 message =
"You beat your last score:";
426 message =
"You didn't beat your last score:";
453 int skill_min,skill_max;
457 if (strncmp(
match,
"-s", 2) == 0 ) {
461 if (strchr(
match,
' ')) {
474 "Could not match '%.*s' to a skill", len,
match);
481 if ( max < 100 && max > 10 )
max = 10;
486 skill_min = skill_max = skill_match;
487 if (skill_match == -1) {
498 if (skill < skill_min || skill > skill_max)
continue;
508 "Overall high scores:");
511 "High scores for the skill [color=red]%s[/color]:",
hiscore_tables[skill].skill_name);
514 "[fixed]Rank Score [print]Who <max hp><max sp><max grace>");
void hiscore_check(object *op, int quiet)
static char * draw_one_high_score(const score *sc, char *buf, size_t size)
void hiscore_display(object *op, int max, const char *match)
#define QUERY_FLAG(xyz, p)
int get_skill_client_code(const char *skill_name)
static event_registration c
#define PROFILE_BEGIN(expr)
static void hiscore_save(const score_table *table)
#define MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_ADMIN_HISCORE
#define PROFILE_END(var, expr)
score entry[HIGHSCORE_LENGTH]
static void hiscore_load(score_table *table)
static int get_score(char *bp, score *sc)
int of_close(OutputFile *of)
const char * skill_names[MAX_SKILLS]
static void put_score(const score *sc, char *buf, size_t size)
size_t split_string(char *str, char *array[], size_t array_size, char sep)
void LOG(LogLevel logLevel, const char *format,...)
FILE * of_open(OutputFile *of, const char *fname)
static score_table hiscore_tables[MAX_SKILLS+1]
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
static void add_score(score_table *table, score *new_score, score *old_score)
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
#define MSG_TYPE_APPLY_ERROR
#define FOR_INV_PREPARE(op_, it_)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)