Crossfire Server, Trunk
|
#include "global.h"
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "sproto.h"
#include "output_file.h"
Go to the source code of this file.
Data Structures | |
struct | score |
struct | score_table |
Macros | |
#define | _GNU_SOURCE |
Functions | |
static void | add_score (score_table *table, score *new_score, score *old_score) |
static char * | draw_one_high_score (const score *sc, char *buf, size_t size) |
static int | get_score (char *bp, score *sc) |
void | hiscore_check (object *op, int quiet) |
void | hiscore_display (object *op, int max, const char *match) |
void | hiscore_init (void) |
static void | hiscore_load (score_table *table) |
static void | hiscore_save (const score_table *table) |
static void | put_score (const score *sc, char *buf, size_t size) |
Variables | |
static score_table | hiscore_tables [MAX_SKILLS+1] |
Hiscore handling functions.
Definition in file hiscore.cpp.
#define _GNU_SOURCE |
Definition at line 19 of file hiscore.cpp.
|
static |
Adds the given score-structure to the high-score list, but only if it was good enough to deserve a place.
table | the highscore table to add to. |
new_score | score to add. |
old_score | returns the old player score. |
Definition at line 188 of file hiscore.cpp.
References score_table::entry, score::exp, HIGHSCORE_LENGTH, hiscore_save(), score::name, score::position, and Ice::tmp.
Referenced by hiscore_check().
|
static |
Formats one score to display to a player.
sc | score to format. |
buf | buffer to write to. Will contain suitably formatted score. |
size | length of buf. |
Definition at line 158 of file hiscore.cpp.
References buf, score::exp, FMT64, score::killer, score::maplevel, score::maxgrace, score::maxhp, score::maxsp, score::name, score::position, and score::title.
Referenced by hiscore_check(), and hiscore_display().
|
static |
The opposite of put_score(), get_score reads from the given buffer into a static score structure, and returns a pointer to it.
bp | string to parse. |
sc | returns the parsed score. |
Definition at line 113 of file hiscore.cpp.
References BIG_NAME, score::exp, FMT64, score::killer, score::maplevel, score::maxgrace, score::maxhp, score::maxsp, score::name, split_string(), score::title, and Ice::tmp.
Referenced by hiscore_load().
void hiscore_check | ( | object * | op, |
int | quiet | ||
) |
Checks if player should enter the hiscore, and if so writes her into the list.
op | player to check. |
quiet | If 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 348 of file hiscore.cpp.
References add_score(), BIG_NAME, draw_ext_info(), draw_ext_info_format(), draw_one_high_score(), score::exp, FLAG_WAS_WIZ, FMT64, FOR_INV_FINISH, FOR_INV_PREPARE, get_skill_client_code(), HIGHSCORE_LENGTH, hiscore_tables, make_face_from_files::int, score::killer, llevDebug, LOG(), score::maplevel, MAX_BUF, score::maxgrace, score::maxhp, score::maxsp, diamondslots::message, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_HISCORE, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, score::name, NDI_UNIQUE, give::op, player_get_title(), score::position, PROFILE_BEGIN, PROFILE_END, QUERY_FLAG, SKILL, score::title, and Ice::tmp.
Referenced by apply_savebed(), emergency_save(), key_confirm_quit(), kill_player_permadeath(), leave(), and process_players1().
void hiscore_display | ( | object * | op, |
int | max, | ||
const char * | match | ||
) |
Displays the high score file.
op | player asking for the score file. |
max | maximum number of scores to display. |
match | if non-empty, will only print players with name or title containing the string (non case-sensitive). Other options: -s:[name] – show the table for the skill 'name' instead of overall -s – show a short list for each skill |
Definition at line 451 of file hiscore.cpp.
References draw_ext_info(), draw_ext_info_format(), draw_one_high_score(), score_table::entry, HIGHSCORE_LENGTH, hiscore_tables, llevDebug, LOG(), push::match, say::max, MAX_BUF, MAX_SKILLS, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_HISCORE, give::name, score::name, NDI_UNIQUE, give::op, and strcasestr_local.
Referenced by command_hiscore().
void hiscore_init | ( | void | ) |
Initializes the module.
Definition at line 296 of file hiscore.cpp.
References c, get_skill_client_code(), HIGHSCORE_DIR, hiscore_load(), hiscore_tables, Settings::localdir, MAX_BUF, MAX_SKILLS, give::name, OLD_HIGHSCORE, settings, and skill_names.
Referenced by init().
|
static |
Loads the hiscore_table from the highscore file.
table | the highscore table to load. |
Definition at line 250 of file hiscore.cpp.
References buf, score_table::entry, score_table::fname, get_score(), HIGHSCORE_LENGTH, llevDebug, llevError, LOG(), MAX_BUF, and score::position.
Referenced by hiscore_init().
|
static |
Saves the highscore_table into the highscore file.
table | the highscore table to save. |
Definition at line 81 of file hiscore.cpp.
References buf, score_table::entry, score_table::fname, HIGHSCORE_LENGTH, MAX_BUF, score::name, of_close(), of_open(), and put_score().
Referenced by add_score().
|
static |
Writes the given score structure to specified buffer.
sc | score to write. |
buf | buffer to write to. |
size | buf's size. |
Definition at line 71 of file hiscore.cpp.
References buf, score::exp, FMT64, score::killer, score::maplevel, score::maxgrace, score::maxhp, score::maxsp, score::name, and score::title.
Referenced by hiscore_save().
|
static |
The highscore table. Unused entries are set to zero (except for position).
Definition at line 59 of file hiscore.cpp.
Referenced by hiscore_check(), hiscore_display(), and hiscore_init().