18 #define _GNU_SOURCE // strcasestr() is a GNU extension in string.h 67 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);
93 fprintf(fp,
"%s\n", buf);
114 cp = strchr(bp,
'\n');
135 sscanf(tmp[5],
"%d", &sc->
maxhp);
137 sscanf(tmp[6],
"%d", &sc->
maxsp);
139 sscanf(tmp[7],
"%d", &sc->
maxgrace);
159 if (strcmp(sc->
killer,
"quit") == 0 || strcmp(sc->
killer,
"left") == 0) {
163 s1 =
"was killed by";
166 snprintf(buf, size,
"[fixed]%3d %10"FMT64"[print] %s%s%s %s %s on map %s <%d><%d><%d>.",
167 sc->
position, sc->
exp, sc->
name, sc->
title[0]==
',' ?
"" :
" ", sc->
title, s1, s2, sc->
maplevel, sc->
maxhp, sc->
maxsp, sc->
maxgrace);
186 memset(old_score, 0,
sizeof(*old_score));
192 table->
entry[i] = *new_score;
197 *old_score = table->
entry[i];
199 table->
entry[i] = *new_score;
206 if (i >= HIGHSCORE_LENGTH) {
216 table->
entry[i] = *new_score;
221 while (i > 0 && new_score->
exp >= table->
entry[i-1].
exp) {
224 tmp = table->
entry[i-1];
226 table->
entry[i] = tmp;
250 fp = fopen(table->
fname,
"r");
252 if (errno == ENOENT) {
255 LOG(
llevError,
"Cannot open highscore file %s: %s\n", table->
fname, strerror(errno));
262 if (fgets(buf,
MAX_BUF, fp) == NULL) {
276 memset(&table->
entry[i], 0,
sizeof(table->
entry[i]));
313 "Since you have been in wizard mode, " 314 "you can't enter the high-score list.");
320 "You don't deserve to save your character yet.");
328 if (new_score.
killer[0] ==
'\0')
329 strcpy(new_score.
killer,
"a dungeon collapse");
341 add_score(&hiscore_table, &new_score, &old_score);
352 message =
"You didn't enter the highscore list:";
354 message =
"You entered the highscore list:";
357 message =
"You left the highscore list:";
358 else if (new_score.
exp > old_score.
exp)
359 message =
"You beat your last score:";
361 message =
"You didn't beat your last score:";
387 "[fixed]Nr Score [print] Who <max hp><max sp><max grace>");
static score_table hiscore_table
void hiscore_display(object *op, int max, const char *match)
static void hiscore_save(const score_table *table)
void player_get_title(const struct pl *pl, char *buf, size_t bufsize)
static char * draw_one_high_score(const score *sc, char *buf, size_t size)
#define MSG_TYPE_ADMIN_HISCORE
static int get_score(char *bp, score *sc)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
static void hiscore_load(score_table *table)
#define MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_APPLY_ERROR
int of_close(OutputFile *of)
score entry[HIGHSCORE_LENGTH]
#define QUERY_FLAG(xyz, p)
static void put_score(const score *sc, char *buf, size_t size)
static void add_score(score_table *table, score *new_score, score *old_score)
FILE * of_open(OutputFile *of, const char *fname)
size_t split_string(char *str, char *array[], size_t array_size, char sep)
void LOG(LogLevel logLevel, const char *format,...)
void hiscore_check(object *op, int quiet)