65 static char *
spool(
char *bp,
const char *error) {
66 static char *prev_pos = NULL;
70 if (prev_pos == NULL) {
71 LOG(
llevError,
"Called spool (%s) with NULL without previous call.\n", error);
80 if ((next_pos = strchr(bp,
':')) != NULL) {
82 prev_pos = next_pos+1;
122 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);
140 if ((cp = strchr(bp,
'\n')) != NULL)
143 if ((cp =
spool(bp,
"name")) == NULL)
148 if ((cp =
spool(NULL,
"title")) == NULL)
153 if ((cp =
spool(NULL,
"score")) == NULL)
156 sscanf(cp,
"%"FMT64, &sc.
exp);
158 if ((cp =
spool(NULL,
"killer")) == NULL)
163 if ((cp =
spool(NULL,
"map")) == NULL)
168 if ((cp =
spool(NULL,
"maxhp")) == NULL)
170 sscanf(cp,
"%d", &sc.
maxhp);
172 if ((cp =
spool(NULL,
"maxsp")) == NULL)
174 sscanf(cp,
"%d", &sc.
maxsp);
176 if ((cp =
spool(NULL,
"maxgrace")) == NULL)
196 snprintf(buf, size,
"[Fixed]%3d %10"FMT64
"[Print] %s the %s quit the game on map %s <%d><%d><%d>.",
199 snprintf(buf, size,
"[Fixed]%3d %10"FMT64
"[Print] %s the %s left the game on map %s <%d><%d><%d>.",
202 snprintf(buf, size,
"[Fixed]%3d %10"FMT64
"[Print] %s the %s was killed by %s on map %s <%d><%d><%d>.",
219 static score old_score;
222 int nrofscores = 0, flag = 0, i, comp;
229 if ((tmp_score =
get_score(buf)) == NULL)
231 if (!flag && new_score->
exp >= tmp_score->
exp) {
238 if (!strcmp(new_score->
name, tmp_score->
name)) {
252 if ((fp = fopen(filename,
"w")) == NULL) {
256 for (i = 0; i < nrofscores; i++) {
258 fprintf(fp,
"%s\n", bp);
272 copy_score(&pscore[nrofscores-1], &old_score);
301 "As you haven't changed your name, you won't "
302 "get into the high-score list.", NULL);
309 "Since you have been in wizard mode, "
310 "you can't enter the high-score list.", NULL);
316 "Since you were in explore mode, "
317 "you can't enter the high-score list.", NULL);
323 "You don't deserve to save your character yet.", NULL);
330 if (new_score.
title[0] ==
'\0')
334 if (new_score.
killer[0] ==
'\0')
335 strcpy(new_score.
killer,
"a dungeon collapse");
347 if ((old_score =
add_score(&new_score)) == NULL) {
350 "Error in the highscore list.", NULL);
363 if (!strcmp(old_score->
name, new_score.
name))
365 "You didn't beat your last highscore:", NULL);
368 "You didn't enter the highscore list:", NULL);
377 if (old_score->
exp >= new_score.
exp)
379 "You didn't beat your last score:", NULL);
382 "You beat your last score:", NULL);
405 int i = 0, j = 0, comp;
415 "There is no highscore file.", NULL);
420 "[Fixed]Nr Score Who <max hp><max sp><max grace>",
421 "Nr Score Who <max hp><max sp><max grace>");
423 while (fgets(buf,
MAX_BUF, fp) != NULL) {
void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage)
static score * add_score(score *new_score)
static void put_score(const score *sc, char *buf, int size)
void close_and_delete(FILE *fp, int compressed)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format,...)
void display_high_score(object *op, int max, const char *match)
static char * spool(char *bp, const char *error)
#define MSG_TYPE_ADMIN_HISCORE
static char * draw_one_high_score(const score *sc, char *buf, int size)
static void copy_score(const score *sc1, score *sc2)
#define QUERY_FLAG(xyz, p)
int snprintf(char *dest, int max, const char *format,...)
#define MSG_TYPE_APPLY_ERROR
void LOG(LogLevel logLevel, const char *format,...)
const char * strcasestr_local(const char *s, const char *find)
char * strerror_local(int errnum, char *buf, size_t size)
void check_score(object *op, int quiet)
#define MSG_TYPE_COMMAND_ERROR
FILE * open_and_uncompress(const char *name, int flag, int *compressed)
static score * get_score(char *bp)