Crossfire Server, Branch 1.12  R12190
Data Structures | Typedefs | Functions
hiscore.c File Reference

Hiscore handling functions. More...

#include <global.h>
#include <sproto.h>
Include dependency graph for hiscore.c:

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 scoreadd_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 scoreget_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.

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

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: