Crossfire Server, Trunk
player.cpp File Reference
#include "global.h"
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for player.cpp:

Go to the source code of this file.

Functions

int atnr_is_dragon_enabled (int attacknr)
 
void clear_player (player *pl)
 
void commit_crime (object *op, const char *description)
 
void free_player (player *pl)
 
client_spellget_client_spell_state (player *pl, object *spell)
 
bool is_criminal (object *op)
 
int is_dragon_pl (const object *op)
 
int is_old_wraith_pl (object *op)
 
int is_wraith_pl (object *op)
 
void link_player_skills (object *op)
 
const char * player_get_own_title (const struct player *pl)
 
void player_get_title (const player *pl, char *buf, size_t bufsize)
 
int player_has_own_title (const struct player *pl)
 
void player_set_dragon_title (player *pl, int level, const char *attack, int skin_resist)
 
void player_set_own_title (struct player *pl, const char *title)
 

Detailed Description

Player-structure related functions.

Definition in file player.cpp.

Function Documentation

◆ atnr_is_dragon_enabled()

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 103 of file player.cpp.

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:

◆ clear_player()

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.cpp.

References FREE_AND_CLEAR, FREE_AND_CLEAR_STR, FREE_OBJ_NO_DESTROY_CALLBACK, give::next, client_spell::next, object_free(), and altar_valkyrie::pl.

Referenced by free_player(), and get_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commit_crime()

void commit_crime ( object op,
const char *  description 
)

Definition at line 307 of file player.cpp.

References add_force(), dragon_attune::force, object_set_msg(), and give::op.

Referenced by save_throw_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_player()

void free_player ( player pl)

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

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

Definition at line 68 of file player.cpp.

References clear_player(), first_player, FLAG_REMOVED, llevError, LOG(), player::next, object_free_drop_inventory(), object_remove(), altar_valkyrie::pl, and QUERY_FLAG.

Referenced by final_free_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_client_spell_state()

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 144 of file player.cpp.

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

Referenced by append_spell(), and esrv_update_spells().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_criminal()

bool is_criminal ( object op)

Definition at line 312 of file player.cpp.

References find_force(), and give::op.

Referenced by attack_ob_simple(), and get_nearest_criminal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_dragon_pl()

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 122 of file player.cpp.

References give::op, and PLAYER.

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:

◆ is_old_wraith_pl()

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 185 of file player.cpp.

References is_wraith_pl(), object_find_by_name(), give::op, and PLAYER.

Referenced by food_type_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_wraith_pl()

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 173 of file player.cpp.

References object_find_by_name(), give::op, and PLAYER.

Referenced by check_heal_and_mana(), 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:

◆ link_player_skills()

void link_player_skills ( object op)

This function goes through the player inventory and sets up the last_skills[] array in the player object. The last_skills[] is used to more quickly lookup skills - mostly used for sending exp. This function should be called anytime the player gains a skill.

Parameters
opplayer to link skills for. Must be a player.

Definition at line 287 of file player.cpp.

References FOR_INV_FINISH, FOR_INV_PREPARE, MAX_SKILLS, give::op, SKILL, and Ice::tmp.

Referenced by adjust_skill_tool(), apply_race_and_class(), become_follower(), check_login(), food_type_apply(), give_initial_items(), give_skill_by_name(), key_change_class(), and learn_skill().

+ Here is the caller graph for this function:

◆ player_get_own_title()

const char* player_get_own_title ( const struct player 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 260 of file player.cpp.

References altar_valkyrie::pl.

Referenced by save_player().

+ Here is the caller graph for this function:

◆ player_get_title()

void player_get_title ( const player 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 232 of file player.cpp.

References buf, altar_valkyrie::pl, and strlcpy().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ player_has_own_title()

int player_has_own_title ( const struct player 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 247 of file player.cpp.

References altar_valkyrie::pl.

Referenced by command_title(), and save_player().

+ Here is the caller graph for this function:

◆ player_set_dragon_title()

void player_set_dragon_title ( player 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 202 of file player.cpp.

References altar_valkyrie::pl.

Referenced by set_dragon_name().

+ Here is the caller graph for this function:

◆ player_set_own_title()

void player_set_own_title ( struct player 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 272 of file player.cpp.

References altar_valkyrie::pl, replace_unprintable_chars(), and strlcpy().

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: