 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
19 #define _GNU_SOURCE // strcasestr() is a GNU extension in string.h
27 #include <sys/types.h>
72 snprintf(
buf, size,
"%s:%s:%" FMT64 ":%s:%s:%d:%d:%d",
sc->name,
sc->
title,
sc->exp,
sc->
killer,
sc->
maplevel,
sc->maxhp,
sc->maxsp,
sc->maxgrace);
96 fprintf(fp,
"%s\n",
buf);
117 cp = strchr(bp,
'\n');
130 sscanf(tmp[2],
"%" FMT64, &
sc->exp);
138 sscanf(tmp[5],
"%d", &
sc->maxhp);
140 sscanf(tmp[6],
"%d", &
sc->maxsp);
142 sscanf(tmp[7],
"%d", &
sc->maxgrace);
165 }
else if (strcmp(
sc->
killer,
"a dungeon collapse") == 0) {
169 s1 =
"was killed by";
172 snprintf(
buf, size,
"[fixed]%3d %10" FMT64 "[print] %s%s%s %s %s on map %s <%d><%d><%d>.",
173 sc->position,
sc->exp,
sc->name,
sc->
title[0]==
',' ?
"" :
" ",
sc->
title, s1, s2,
sc->
maplevel,
sc->maxhp,
sc->maxsp,
sc->maxgrace);
192 memset(old_score, 0,
sizeof(*old_score));
198 table->
entry[i] = *new_score;
203 *old_score = table->
entry[i];
205 table->
entry[i] = *new_score;
222 table->
entry[i] = *new_score;
227 while (i > 0 && new_score->
exp >= table->
entry[i-1].
exp) {
230 tmp = table->
entry[i-1];
232 table->
entry[i] = tmp;
256 fp = fopen(table->
fname,
"r");
258 if (errno == ENOENT) {
261 LOG(
llevError,
"Cannot open highscore file %s: %s\n", table->
fname, strerror(errno));
282 memset(&table->
entry[i], 0,
sizeof(table->
entry[i]));
360 "Since you have been in wizard mode, "
361 "you can't enter the high-score list.");
367 "You don't deserve to save your character yet.");
376 if (new_score.
killer[0] ==
'\0') {
377 strcpy(new_score.
killer,
"a dungeon collapse");
380 if (op->
map == NULL) {
390 if (tmp->type !=
SKILL)
continue;
391 if (!tmp->stats.exp)
continue;
392 new_score.
exp = tmp->stats.exp;
395 if (!quiet && new_score.
exp > old_score.
exp) {
397 "You improved your rating in %s: %" FMT64, tmp->name, new_score.
exp);
419 message =
"You didn't enter the highscore list:";
421 message =
"You entered the highscore list:";
424 message =
"You left the highscore list:";
425 else if (new_score.
exp > old_score.
exp)
426 message =
"You beat your last score:";
428 message =
"You didn't beat your last score:";
455 int skill_min,skill_max;
459 if (strncmp(match,
"-s", 2) == 0 ) {
463 if (strchr(match,
' ')) {
464 len = strchr(match,
' ') - match;
476 "Could not match '%.*s' to a skill", len, match);
483 if ( max < 100 && max > 10 ) max = 10;
486 while (*match ==
' ') ++match;
488 skill_min = skill_max = skill_match;
489 if (skill_match == -1) {
500 if (skill < skill_min || skill > skill_max)
continue;
510 "Overall high scores:");
516 "[fixed]Rank Score [print]Who <max hp><max sp><max grace>");
static void hiscore_load(score_table *table)
Loads the hiscore_table from the highscore file.
static char * draw_one_high_score(const score *sc, char *buf, size_t size)
Formats one score to display to a player.
struct Settings settings
Server settings.
int16_t maxhp
Max hit points.
@ llevError
Error, serious thing.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int of_close(OutputFile *of)
Closes an output file.
FILE * of_open(OutputFile *of, const char *fname)
Opens an output file.
#define HIGHSCORE_LENGTH
How many entries there are room for.
#define QUERY_FLAG(xyz, p)
char title[BIG_NAME]
Title.
int get_skill_client_code(const char *skill_name)
Return the code of the skill for a client, the index in the skill_names array.
static event_registration c
struct mapstruct * map
Pointer to the map in which this object is present.
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 pl...
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
@ SKILL
Also see SKILL_TOOL (74) below.
#define PROFILE_BEGIN(expr)
#define MSG_TYPE_COMMAND_ERROR
Bad syntax/can't use command.
char path[HUGE_BUF]
Filename of the map.
static score_table hiscore_tables[MAX_SKILLS+1]
The highscore table.
#define MSG_TYPE_ADMIN_HISCORE
Hiscore list.
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Plugin animator file specs[Config] name
int maxsp
Max sp when killed.
#define PROFILE_END(var, expr)
score entry[HIGHSCORE_LENGTH]
The entries in decreasing exp order.
struct player * contr
Pointer to the player which control this object.
char killer[BIG_NAME]
Who killed this player.
#define FLAG_WAS_WIZ
Player was once a wiz.
int maxgrace
Max grace when killed.
Player Stats effect how well a character can survie and interact inside the crossfire world This section discusses the various what they and how they effect the player s actions Also in this section are the stat modifiers that specific classes professions bring Player and sps the current and maximum the Current and Maximum The Current Sp can go somewhat negative When Sp is negative not all spells can be and a more negative Sp makes spell casting less likey to succeed can affect Damage and how the characters as well as how often the character can attack this affects the prices when buying and selling items if this drops the player will start losing hit points wd Cleric or Dwarf sm Elf wd Fireborn sc
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings.
int maxhp
Max hp when killed.
static void hiscore_save(const score_table *table)
Saves the highscore_table into the highscore file.
static int get_score(char *bp, score *sc)
The opposite of put_score(), get_score reads from the given buffer into a static score structure,...
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
const char * skill_names[MAX_SKILLS]
Will contain a number-name mapping for skills, initialized by init_skills().
Information on one title.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
char skill_name[MAX_BUF]
The name of the skill or "Overall".
#define MAX_SKILLS
This is the maximum number of skills the game may handle.
char maplevel[MAX_BUF]
On which level is the player?
#define MAX_BUF
Used for all kinds of things.
void hiscore_display(object *op, int max, const char *match)
Displays the high score file.
char maplevel[BIG_NAME]
Killed on what level.
The score structure is used when treating new high-scores.
int16_t maxgrace
Maximum grace.
static void put_score(const score *sc, char *buf, size_t size)
Writes the given score structure to specified buffer.
#define NDI_UNIQUE
Print immediately, don't buffer.
sstring name
The name of the object, obviously...
int16_t maxsp
Max spell points.
char * name
Name of map as given by its creator.
int position
Position in the highscore list.
void hiscore_init(void)
Initializes the module.
char killer[BIG_NAME]
Name (+ title) or "left".
void hiscore_check(object *op, int quiet)
Checks if player should enter the hiscore, and if so writes her into the list.
living stats
Str, Con, Dex, etc.
char title[BIG_NAME]
Default title, like fighter, wizard, etc.
char fname[MAX_BUF]
Filename of the backing file.
#define MSG_TYPE_APPLY
Applying objects.
uint32_t name_changed
If true, the player has set a name.
#define MSG_TYPE_APPLY_ERROR
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
@ llevDebug
Only for debugging purposes.
void player_get_title(const player *pl, char *buf, size_t bufsize)
Returns the player's title.
const char * localdir
Read/write data files.