Crossfire Server, Trunk  R20513
Functions
player.c File Reference

Player-structure related functions. More...

#include "global.h"
#include <stdlib.h>
#include <string.h>
Include dependency graph for player.c:

Go to the source code of this file.

Functions

int atnr_is_dragon_enabled (int attacknr)
 Determine if the attacktype represented by the specified attack-number is enabled for dragon players. More...
 
void clear_player (player *pl)
 Clears data in player structure. More...
 
void free_player (player *pl)
 Clears player structure, including pointed object (through object_free_drop_inventory()). More...
 
client_spellget_client_spell_state (player *pl, object *spell)
 Gets the (client-side) spell state for specified spell. More...
 
int is_dragon_pl (const object *op)
 Checks if player is a dragon. More...
 
int is_old_wraith_pl (object *op)
 Checks if player is a wraith without the 'wraith feed' skill. More...
 
int is_wraith_pl (object *op)
 Tests if a player is a wraith. More...
 
const char * player_get_own_title (const struct pl *pl)
 Returns the player's own title. More...
 
void player_get_title (const struct pl *pl, char *buf, size_t bufsize)
 Returns the player's title. More...
 
int player_has_own_title (const struct pl *pl)
 Returns whether the player has a custom title. More...
 
void player_set_dragon_title (struct pl *pl, int level, const char *attack, int skin_resist)
 Updates the title of a dragon player to reflect the current level, attack type, and resistances. More...
 
void player_set_own_title (struct pl *pl, const char *title)
 Sets the custom title. More...
 

Detailed Description

Player-structure related functions.

Definition in file player.c.

Function Documentation

int atnr_is_dragon_enabled ( int  attacknr)

Determine if the attacktype represented by the specified attack-number is enabled for dragon players.

A dragon player (quetzal) can gain resistances for all enabled attacktypes.

Parameters
attacknrattacktype to check
Returns
TRUE if player can gain resistances in that, FALSE else.

Definition at line 95 of file player.c.

References ATNR_ACID, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_MAGIC, and ATNR_POISON.

Referenced by command_resistances(), describe_item(), describe_resistance(), dragon_eat_flesh(), dragon_level_gain(), perceive_self(), and set_dragon_name().

Here is the caller graph for this function:

void clear_player ( player pl)

Clears data in player structure.

Socket isn't touched. Nor is anything that doesn't need to be freed. So you may need to do a memset() to clear out values.

Parameters
plplayer to clear. Pointer is still valid, and can be reused for "play again".

Definition at line 33 of file player.c.

References FREE_AND_CLEAR_STR, client_spell::next, pl::spell_state, pl::stack_items, pl::stack_position, and pl::unarmed_skill.

Referenced by free_player(), and get_player().

Here is the caller graph for this function:

void free_player ( player pl)

Clears player structure, including pointed object (through object_free_drop_inventory()).

Parameters
plplayer to clear. Pointer is invalid after this call.

Definition at line 57 of file player.c.

References clear_player(), socket_struct::faces_sent, first_player, FLAG_REMOVED, llevError, LOG(), pl::next, pl::ob, object_free_drop_inventory(), object_remove(), QUERY_FLAG, and pl::socket.

Referenced by final_free_player().

Here is the call graph for this function:

Here is the caller graph for this function:

client_spell* get_client_spell_state ( player pl,
object spell 
)

Gets the (client-side) spell state for specified spell.

Will be created to empty state if not found.

Note
will fatal() in case of memory allocation failure.
Parameters
plplayer we're handling.
spellspell for which to search data.
Returns
state information for that spell.

Definition at line 136 of file player.c.

References fatal(), client_spell::next, OUT_OF_MEMORY, client_spell::spell, and pl::spell_state.

Referenced by append_spell(), and esrv_update_spells().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_dragon_pl ( const object op)

Checks if player is a dragon.

Parameters
opplayer to check. Can be NULL.
Returns
TRUE if the adressed object 'ob' is a player of the dragon race.

Definition at line 114 of file player.c.

References obj::arch, archt::clone, PLAYER, obj::race, and obj::type.

Referenced by check_login(), command_resistances(), command_title(), describe_item(), describe_monster(), dragon_eat_flesh(), dragon_focus_type_apply(), find_best_player_hth_skill(), food_type_apply(), old_describe_monster(), perceive_self(), and player_lvl_adj().

Here is the caller graph for this function:

int is_old_wraith_pl ( object op)

Checks if player is a wraith without the 'wraith feed' skill.

Parameters
opplayer to check.
Returns
true if the adressed object 'ob' is an old wraith player, false else.

Definition at line 177 of file player.c.

References obj::arch, is_wraith_pl(), object_find_by_name(), PLAYER, and obj::type.

Referenced by food_type_apply().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_wraith_pl ( object op)

Tests if a player is a wraith.

Parameters
opplayer to check.
Returns
true if the adressed object 'ob' is a wraith player, false else.

Definition at line 165 of file player.c.

References obj::arch, object_find_by_name(), PLAYER, and obj::type.

Referenced by eat_special_food(), food_type_apply(), hit_with_one_attacktype(), and is_old_wraith_pl().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* player_get_own_title ( const struct pl pl)

Returns the player's own title.

The returned value must not be modified and points into the player structure.

Parameters
plthe player
Returns
the own title

Definition at line 252 of file player.c.

References pl::own_title.

Referenced by save_player().

Here is the caller graph for this function:

void player_get_title ( const struct pl pl,
char *  buf,
size_t  bufsize 
)

Returns the player's title.

The returned title is never empty and includes a "the" prefix if necessary.

Parameters
plthe player to return the title of
bufreturns the title
bufsizethe size of buf in byte

Definition at line 224 of file player.c.

References pl::own_title, snprintf, and pl::title.

Referenced by cfapi_object_get_property(), command_title(), get_who_escape_code_value(), hiscore_check(), and set_title().

Here is the caller graph for this function:

int player_has_own_title ( const struct pl pl)

Returns whether the player has a custom title.

Parameters
plthe player to check
Returns
whether the player has a custom title

Definition at line 239 of file player.c.

References pl::own_title.

Referenced by command_title(), and save_player().

Here is the caller graph for this function:

void player_set_dragon_title ( struct pl pl,
int  level,
const char *  attack,
int  skin_resist 
)

Updates the title of a dragon player to reflect the current level, attack type, and resistances.

Parameters
plthe player to update
levelthe dragon's current level
attackthe dragon's current attack focus
skin_resistthe dragon's skin resistance for attack

Definition at line 194 of file player.c.

References pl::own_title, snprintf, and pl::title.

Referenced by set_dragon_name().

Here is the caller graph for this function:

void player_set_own_title ( struct pl pl,
const char *  title 
)

Sets the custom title.

Parameters
plthe player to modify
titlethe new title to set; empty string to unset

Definition at line 264 of file player.c.

References pl::own_title, replace_unprintable_chars(), and snprintf.

Referenced by cfapi_object_set_property(), check_login(), command_title(), key_confirm_quit(), and kill_player_permadeath().

Here is the call graph for this function:

Here is the caller graph for this function: