Crossfire Server, Branches 1.12  R18729
hiscore.c File Reference
#include <global.h>
#include <sproto.h>
+ Include dependency graph for hiscore.c:

Go to the source code of this file.

Data Structures

struct  scr
 

Typedefs

typedef struct scr score
 

Functions

static scoreadd_score (score *new_score)
 
void check_score (object *op, int quiet)
 
static void copy_score (const score *sc1, score *sc2)
 
void display_high_score (object *op, int max, const char *match)
 
static char * draw_one_high_score (const score *sc, char *buf, int size)
 
static scoreget_score (char *bp)
 
static void put_score (const score *sc, char *buf, int size)
 
static char * spool (char *bp, const char *error)
 

Detailed Description

Hiscore handling functions.

Definition in file hiscore.c.

Typedef Documentation

typedef struct scr score

The score structure is used when treating new high-scores.

Function Documentation

static score* add_score ( score new_score)
static

Adds the given score-structure to the high-score list, but only if it was good enough to deserve a place.

Parameters
new_scorescore to add.
Returns
old player score.
Todo:
remove static buffer.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void check_score ( object op,
int  quiet 
)

Checks if player should enter the hiscore, and if so writes her into the list.

Parameters
opplayer to check.
quietIf 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, obj::contr, draw_ext_info(), draw_ext_info_format(), draw_one_high_score(), scr::exp, liv::exp, pl::explore, FLAG_WAS_WIZ, HIGHSCORE_LENGTH, scr::killer, pl::killer, obj::map, scr::maplevel, MAX_BUF, scr::maxgrace, liv::maxgrace, scr::maxhp, liv::maxhp, scr::maxsp, liv::maxsp, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_HISCORE, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, scr::name, obj::name, mapdef::name, pl::name_changed, NDI_UNIQUE, pl::own_title, mapdef::path, scr::position, QUERY_FLAG, obj::stats, scr::title, and pl::title.

Referenced by apply_savebed(), command_kick(), command_shutdown(), emergency_save(), key_confirm_quit(), kill_player(), leave(), and process_players1().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
sc1what to copy.
sc2where 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().

+ Here is the caller graph for this function:

void display_high_score ( object op,
int  max,
const char *  match 
)

Displays the high score file.

Parameters
opplayer asking for the score file.
maxmaximum number of scores to display.
matchif 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* draw_one_high_score ( const score sc,
char *  buf,
int  size 
)
static

Formats one score to display to a player.

Parameters
scscore to format.
bufbuffer to write to. Will contain suitably formatted score.
sizelength of buf.
Returns
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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static score* get_score ( char *  bp)
static

The opposite of put_score(), get_score reads from the given buffer into a static score structure, and returns a pointer to it.

Parameters
bpstring to parse.
Returns
parsed score.
Todo:
make thread-safe, remove static stuff.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void put_score ( const score sc,
char *  buf,
int  size 
)
static

Writes the given score structure to specified buffer.

Parameters
scscore to write.
bufbuffer to write to.
sizebuf'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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
bpstring to search into. Should be non NULL for first call, NULL for subsequent calls.
errormessage to display in case there is an error.
Returns
next token, NULL if no more found.
Todo:
make thread-safe. is this function really useful?

Definition at line 65 of file hiscore.c.

References llevError, and LOG().

Referenced by get_score().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: