Atrinik Server  4.0
Data Structures | Typedefs | Functions | Variables
hiscore.c File Reference
#include <global.h>
#include <toolkit/string.h>
#include <player.h>
#include <object.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)
 
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 211 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 180 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 136 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 332 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 412 of file hiscore.c.

void hiscore_init ( void  )

Initializes the module.

Definition at line 315 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 275 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 96 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 86 of file hiscore.c.

Variable Documentation

score_table hiscore_table
static

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

Definition at line 75 of file hiscore.c.