Atrinik Server 2.5
Data Structures | Typedefs | Functions | Variables
server/hiscore.c File Reference
#include <global.h>

Go to the source code of this file.

Data Structures

struct  scr
struct  score_table

Typedefs

typedef struct scr score

Functions

static void put_score (const score *sc, char *buf, int size)
static void hiscore_save (const score_table *table)
static int get_score (char *bp, score *sc)
static char * draw_one_high_score (const score *sc, char *buf, size_t size)
static void add_score (score_table *table, score *new_score, score *old_score)
static void hiscore_load (score_table *table)
void hiscore_init ()
void hiscore_check (object *op, int quiet)
void hiscore_display (object *op, int max, const char *match)

Variables

static score_table hiscore_table

Detailed Description

Includes high score related 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 void add_score ( score_table table,
score new_score,
score old_score 
) [static]

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

Parameters:
tableThe highscore table to add to.
new_scoreScore to add.
old_scoreReturns the old player score.

Definition at line 204 of file hiscore.c.

static char* draw_one_high_score ( const score sc,
char *  buf,
size_t  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 171 of file hiscore.c.

static int get_score ( char *  bp,
score sc 
) [static]

The opposite of put_score(), get_score reads from the given buffer into a given score structure.

Parameters:
bpString to parse.
scIncludes the parsed score.
Returns:
Whether parsing was successful.

Definition at line 129 of file hiscore.c.

void hiscore_check ( object op,
int  quiet 
)

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

Parameters:
opPlayer to check.
quietIf set, don't print anything out - used for periodic updates during game play or when player unexpectedly quits - don't need to print anything in those cases.

Definition at line 338 of file hiscore.c.

void hiscore_display ( 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 non-empty, will only print players with name or title containing the string (non case-sensitive).

Definition at line 447 of file hiscore.c.

void hiscore_init ( )

Initializes the module.

Definition at line 326 of file hiscore.c.

static void hiscore_load ( score_table table) [static]

Loads the hiscore_table from the highscore file.

Parameters:
tableThe highscore table to load.

Definition at line 273 of file hiscore.c.

static void hiscore_save ( const score_table table) [static]

Saves the highscore_table into the highscore file.

Parameters:
tableThe highscore table to save.

Definition at line 86 of file hiscore.c.

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

Writes the given score structure to the given buffer.

Parameters:
scScore.
bufThe buffer.
sizeSize of the buffer.

Definition at line 78 of file hiscore.c.


Variable Documentation

The highscore table. Unused entries are set to zero (except for position).

Definition at line 71 of file hiscore.c.