Crossfire Server, Branch 1.12
R12190
|
Hiscore handling functions. More...
Go to the source code of this file.
Data Structures | |
struct | scr |
The score structure is used when treating new high-scores. More... | |
Typedefs | |
typedef struct scr | score |
The score structure is used when treating new high-scores. | |
Functions | |
static score * | add_score (score *new_score) |
Adds the given score-structure to the high-score list, but only if it was good enough to deserve a place. | |
void | check_score (object *op, int quiet) |
Checks if player should enter the hiscore, and if so writes her into the list. | |
static void | copy_score (const score *sc1, score *sc2) |
Does what it says, copies the contents of the first score structure to the second one. | |
void | display_high_score (object *op, int max, const char *match) |
Displays the high score file. | |
static char * | draw_one_high_score (const score *sc, char *buf, int size) |
Formats one score to display to a player. | |
static score * | get_score (char *bp) |
The opposite of put_score(), get_score reads from the given buffer into a static score structure, and returns a pointer to it. | |
static void | put_score (const score *sc, char *buf, int size) |
Writes the given score structure to specified buffer. | |
static char * | spool (char *bp, const char *error) |
Spool works mostly like strtok(char *, ":"), but it can also log a specified error message if something goes wrong. |
Hiscore handling functions.
Definition in file hiscore.c.
Adds the given score-structure to the high-score list, but only if it was good enough to deserve a place.
new_score | score to add. |
Definition at line 217 of file hiscore.c.
References close_and_delete(), copy_score(), scr::exp, get_score(), HIGHSCORE, HIGHSCORE_LENGTH, llevError, Settings::localdir, LOG(), MAX_BUF, scr::name, open_and_uncompress(), scr::position, put_score(), settings, snprintf(), and strerror_local().
Referenced by check_score().
void check_score | ( | object * | op, |
int | quiet | ||
) |
Checks if player should enter the hiscore, and if so writes her into the list.
op | player to check. |
quiet | If set, don't print anything out - used for periodic updates during game play or when player unexpected quits - don't need to print anything in those cases |
Definition at line 289 of file hiscore.c.
References add_score(), BIG_NAME, draw_ext_info(), draw_ext_info_format(), draw_one_high_score(), scr::exp, FLAG_WAS_WIZ, HIGHSCORE_LENGTH, scr::killer, scr::maplevel, MAX_BUF, scr::maxgrace, scr::maxhp, scr::maxsp, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_HISCORE, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, scr::name, NDI_UNIQUE, scr::position, QUERY_FLAG, and scr::title.
Referenced by apply_savebed(), command_kick(), command_shutdown(), emergency_save(), key_confirm_quit(), kill_player(), leave(), and process_players1().
static void copy_score | ( | const score * | sc1, |
score * | sc2 | ||
) | [static] |
Does what it says, copies the contents of the first score structure to the second one.
sc1 | what to copy. |
sc2 | where to copy to. |
Definition at line 97 of file hiscore.c.
References BIG_NAME, scr::exp, scr::killer, scr::maplevel, scr::maxgrace, scr::maxhp, scr::maxsp, scr::name, and scr::title.
Referenced by add_score().
void display_high_score | ( | object * | op, |
int | max, | ||
const char * | match | ||
) |
Displays the high score file.
op | player asking for the score file. |
max | maximum number of scores to display. |
match | if set, will only print players with name or title containing the string (non case-sensitive). |
Definition at line 402 of file hiscore.c.
References close_and_delete(), draw_ext_info(), draw_one_high_score(), get_score(), HIGHSCORE, HIGHSCORE_LENGTH, llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_HISCORE, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, scr::name, NDI_UNIQUE, open_and_uncompress(), scr::position, settings, snprintf(), strcasestr_local(), strerror_local(), and scr::title.
Referenced by command_hiscore(), showscores(), and showscoresparm().
static char* draw_one_high_score | ( | const score * | sc, |
char * | buf, | ||
int | size | ||
) | [static] |
Formats one score to display to a player.
sc | score to format. |
buf | buffer to write to. Will contain suitably formatted score. |
size | length of buf. |
Definition at line 194 of file hiscore.c.
References scr::exp, scr::killer, scr::maplevel, MAX_NAME, scr::maxgrace, scr::maxhp, scr::maxsp, scr::name, scr::position, snprintf(), and scr::title.
Referenced by check_score(), and display_high_score().
The opposite of put_score(), get_score reads from the given buffer into a static score structure, and returns a pointer to it.
bp | string to parse. |
Definition at line 136 of file hiscore.c.
References BIG_NAME, scr::exp, scr::killer, scr::maplevel, scr::maxgrace, scr::maxhp, scr::maxsp, scr::name, spool(), and scr::title.
Referenced by add_score(), and display_high_score().
Writes the given score structure to specified buffer.
sc | score to write. |
buf | buffer to write to. |
size | buf's size. |
Definition at line 121 of file hiscore.c.
References scr::exp, scr::killer, scr::maplevel, scr::maxgrace, scr::maxhp, scr::maxsp, scr::name, snprintf(), and scr::title.
Referenced by add_score().
static char* spool | ( | char * | bp, |
const char * | error | ||
) | [static] |
Spool works mostly like strtok(char *, ":"), but it can also log a specified error message if something goes wrong.
bp | string to search into. Should be non NULL for first call, NULL for subsequent calls. |
error | message to display in case there is an error. |
Definition at line 65 of file hiscore.c.
References llevError, and LOG().
Referenced by get_score().