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


typedef struct scr score


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)


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 

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

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 

Formats one score to display to a player.

scScore to format.
bufBuffer to write to. Will contain suitably formatted score.
sizeLength of buf.

Definition at line 180 of file hiscore.c.

static int get_score ( char *  bp,
score sc 

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

bpString to parse.
scIncludes the parsed score.
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.

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.

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)

Loads the hiscore_table from the highscore file.

tableThe highscore table to load.

Definition at line 275 of file hiscore.c.

static void hiscore_save ( const score_table table)

Saves the highscore_table into the highscore file.

tableThe highscore table to save.

Definition at line 96 of file hiscore.c.

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

Writes the given score structure to the given buffer.

bufThe buffer.
sizeSize of the buffer.

Definition at line 86 of file hiscore.c.

Variable Documentation

score_table hiscore_table

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

Definition at line 75 of file hiscore.c.