Crossfire Server, Trunk
player.cpp File Reference
#include "global.h"
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include "server.h"
#include "living.h"
#include "object.h"
#include "shared/newclient.h"
#include "shop.h"
#include "skills.h"
#include "sounds.h"
#include "spells.h"
#include "sproto.h"
#include "assets.h"
#include "AssetsManager.h"
+ Include dependency graph for player.cpp:

Go to the source code of this file.

Macros

#define DETOUR_AMOUNT   2
 
#define MAX_SPACES   50
 

Functions

static int action_makes_visible (object *op)
 
playeradd_player (socket_struct *ns, int flags)
 
int apply_race_and_class (object *op, archetype *race, archetype *opclass, living *stats)
 
void cast_dust (object *op, object *throw_ob, int dir)
 
int check_pick (object *op)
 
int check_race_and_class (living *stats, archetype *race, archetype *opclass)
 
void confirm_password (object *op)
 
void display_motd (const object *op)
 
void do_hidden_move (object *op)
 
void do_some_living (object *op)
 
void dragon_ability_gain (object *who, int atnr, int level)
 
int face_player (object *op, int dir)
 
static objectfind_arrow (object *op, const char *type)
 
static objectfind_better_arrow (object *op, object *target, const char *type, int *better)
 
objectfind_key (object *pl, object *container, object *door)
 
playerfind_player (const char *plname)
 
playerfind_player_options (const char *plname, int options, const mapstruct *map)
 
playerfind_player_partial_name (const char *plname)
 
playerfind_player_socket (const socket_struct *ns)
 
void fire (object *op, int dir)
 
int fire_bow (object *op, object *arrow, int dir, int wc_mod, int16_t sx, int16_t sy)
 
static void fire_misc_object (object *op, int dir)
 
void fix_luck (void)
 
void fix_weight (void)
 
static void flee_player (object *op)
 
void get_name (object *op)
 
objectget_nearest_criminal (object *mon)
 
objectget_nearest_player (object *mon)
 
int get_party_password (object *op, partylist *party)
 
void get_password (object *op)
 
playerget_player (player *p)
 
static archetypeget_player_archetype (archetype *at)
 
void give_initial_items (object *pl, treasurelist *items)
 
static const char * gravestone_text (object *op, char *buf2, int len)
 
int handle_newcs_player (object *op)
 
int hideability (object *ob)
 
int is_true_undead (object *op)
 
void key_change_class (object *op, char key)
 
void key_confirm_quit (object *op, char key)
 
void key_roll_stat (object *op, char key)
 
void kill_player (object *op, const object *killer)
 
static void kill_player_not_permadeath (object *op)
 
static void kill_player_permadeath (object *op)
 
static void loot_object (object *op)
 
void make_visible (object *op)
 
int move_player (object *op, int dir)
 
void move_player_attack (object *op, int dir)
 
int op_on_battleground (object *op, int *x, int *y, archetype **trophy)
 
int path_to_player (object *mon, object *pl, unsigned mindiff)
 
static objectpick_arrow_target (object *op, const char *type, int dir)
 
void play_again (object *op)
 
static int player_attack_door (object *op, object *door)
 
int player_can_view (object *pl, object *op)
 
static int player_fire_bow (object *op, int dir)
 
SockListplayer_get_delayed_buffer (player *pl)
 
void player_set_state (player *pl, uint8_t state)
 
void player_unready_range_ob (player *pl, object *ob)
 
int playername_ok (const char *cp)
 
void receive_play_again (object *op, char key)
 
void remove_unpaid_objects (object *op, object *env, int free_items)
 
static void restore_player (object *op)
 
void roll_again (object *op)
 
int roll_stat (void)
 
void roll_stats (object *op)
 
static int save_life (object *op)
 
void send_news (const object *op)
 
void send_rules (const object *op)
 
void set_first_map (object *op)
 
void set_player_socket (player *p, socket_struct *ns)
 
static int similar_direction (int a, int b)
 
int stand_near_hostile (object *who)
 
static bool starving (object *op)
 
static void swap_stat (object *op, int swap_second)
 
static int turn_one_transport (object *transport, object *captain, int dir)
 
static int turn_transport (object *transport, object *captain, int dir)
 
static void update_transport_block (object *transport, int dir)
 

Variables

std::vector< archetype * > players
 

Detailed Description

Player-related functions, including those used during the login and creation phases.

Todo:
describe login/creation functions/cycles.

Definition in file player.cpp.

Macro Definition Documentation

◆ DETOUR_AMOUNT

#define DETOUR_AMOUNT   2

This value basically determines how large a detour a monster will take from the direction path when looking for a path to the player.

The values are in the amount of direction the deviation is.

I believe this can safely go to 2, 3 is questionable, 4 will likely result in a monster paths backtracking.

Definition at line 603 of file player.cpp.

◆ MAX_SPACES

#define MAX_SPACES   50

This is used to prevent infinite loops. Consider a case where the player is in a chamber (with gate closed), and monsters are outside. with DETOUR_AMOUNT==2, the function will turn each corner, trying to find a path into the chamber. This is a good thing, but since there is no real path, it will just keep circling the chamber for ever (this could be a nice effect for monsters, but not for the function to get stuck in. I think for the monsters, if max is reached and we return the first direction the creature could move would result in the circling behaviour. Unfortunately, this function is also used to determined if the creature should cast a spell, so returning a direction in that case is probably not a good thing.

Definition at line 618 of file player.cpp.

Function Documentation

◆ action_makes_visible()

static int action_makes_visible ( object op)
static

We call this when there is a possibility for our action disturbing our hiding place or invisibility spell. Artefact invisibility is not effected by this. If we aren't invisible to begin with, we return 0.

This routine works for both players and monsters.

Parameters
opobject to check.
Returns
1 if op isn't invisible anymore, 0 else.

Definition at line 4198 of file player.cpp.

References draw_ext_info_format(), FLAG_ALIVE, FLAG_MAKE_INVIS, MSG_SUBTYPE_NONE, MSG_TYPE_MISC, NDI_UNIQUE, give::op, and QUERY_FLAG.

Referenced by fire(), move_player_attack(), and player_attack_door().

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

◆ add_player()

player* add_player ( socket_struct ns,
int  flags 
)

Tries to add player on the connection passwd in ns.

Player object is created and put on the first map, rules/news/motd are sent.

Parameters
nsconnection.
flagsflag values are define in player.h: ADD_PLAYER_NEW - If set, go right to new character creation - used in case of new account code. We don't display motd and other bits in this case either. ADD_PLAYER_NO_MAP - Do not set up map information - used in character login method >2 where we do not use the same starting map.
Returns
player returns pointer to newly created player structure.

Definition at line 460 of file player.cpp.

References add_friendly_object(), ADD_PLAYER_NEW, ADD_PLAYER_NO_MAP, ADD_PLAYER_NO_STATS_ROLL, CLEAR_FLAG, display_motd(), FLAG_FRIENDLY, flags, get_name(), get_player(), Ns_Avail, player::ob, player_set_state(), roll_again(), send_news(), send_rules(), set_first_map(), set_player_socket(), ST_ROLL_STAT, and socket_struct::status.

Referenced by add_me_cmd(), create_player_cmd(), and START_TEST().

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

◆ apply_race_and_class()

int apply_race_and_class ( object op,
archetype race,
archetype opclass,
living stats 
)

This is somewhat like key_change_class() above, except we know the race to change to, but we still basically need to do the same work (apply bonuses, update archetype, etc.)

Parameters
opPlayer object
racerace to use - caller should do sanity checking that this is a valid race.
opclassclass to use - like race, caller should do sanity checking.
statsIf set, use these stats for the character, do not apply new ones. Note: It is required that the caller only use valid stat values (generated by check_race_and_class() for example), as this function will not do checking on the stats.
Returns
0 on success, non zero on failure (may be extended with unique error codes). It is the responsibility of the caller to notify the client of this failure.

Definition at line 1479 of file player.cpp.

References AC_PLAYER_STAT_NO_CHANGE, add_statbonus(), add_string(), allowed_class(), apply_changes_to_player(), buf, CLEAR_FLAG, archetype::clone, create_treasure(), esrv_add_spells(), esrv_new_player(), esrv_send_inventory(), esrv_update_item(), EVENT_BORN, EVENT_LOGIN, events_execute_global_event(), find_treasurelist(), fix_object(), FLAG_WIZ, free_string(), get_attr_value(), give_initial_items(), commongive::inv, link_player_skills(), Settings::localdir, make_path_to_file(), MAX_BUF, give::name, NUM_STATS, object_copy(), object_free(), object_remove(), object_set_msg(), object_update(), give::op, Settings::playerdir, pticks, SET_ANIMATION, set_attr_value(), settings, strlcpy(), UP_OBJ_FACE, and UPD_FACE.

Referenced by create_player_cmd(), and START_TEST().

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

◆ cast_dust()

void cast_dust ( object op,
object throw_ob,
int  dir 
)

Handles op throwing objects of type 'DUST'. This is much simpler in the new spell code - we basically just treat this as any other spell casting object.

Parameters
opobject throwing.
throw_obwhat to throw.
dirdirection to throw into.

Definition at line 3931 of file player.cpp.

References cast_spell(), draw_ext_info_format(), find_skill_by_name(), FLAG_REMOVED, object::inv, llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, object::name, NDI_UNIQUE, object_free_drop_inventory(), object_remove(), give::op, PLAYER, POTION, QUERY_FLAG, object::skill, and object::type.

Referenced by do_throw().

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

◆ check_pick()

◆ check_race_and_class()

int check_race_and_class ( living stats,
archetype race,
archetype opclass 
)

This checks to see if the race and class are legal. Legal in this contexts means that after apply the race/class stat modifiers, the race is still in legal range.

Parameters
statsThe statistics to modify - this data is modified, so the caller can use it on the next update.
raceThe race to try and apply. It can be NULL, in which case no race will be applied.
opclassThe class to apply. It can be NULL, in which case no class will be applied.
Returns
0 on success, 1 on failure. Note that no distinction is made on whether the failure is from race or class, as it is the final statistics which are important. For example, if race is -2 Str, and class is +2 Str, if the starting strength is 1, that is still legal (as final result is 1)

Definition at line 1429 of file player.cpp.

References archetype::clone, get_attr_value(), Settings::max_stat, MIN_STAT, NUM_STATS, set_attr_value(), settings, and object::stats.

Referenced by create_player_cmd().

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

◆ confirm_password()

void confirm_password ( object op)

Ask the player to confirm her password during creation.

Parameters
opplayer.

Definition at line 1006 of file player.cpp.

References CS_QUERY_HIDEINPUT, i18n(), give::op, player_set_state(), send_query(), and ST_CONFIRM_PASSWORD.

Referenced by check_login().

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

◆ display_motd()

void display_motd ( const object op)

Sends the message of the day to the player.

Parameters
opplayer to send to.

Definition at line 139 of file player.cpp.

References buf, Settings::confdir, draw_ext_info(), HUGE_BUF, MAX_BUF, Settings::motd, MSG_SUBTYPE_NONE, MSG_TYPE_MOTD, NDI_GREEN, NDI_UNIQUE, give::op, safe_strcat(), and settings.

Referenced by add_player(), command_motd(), and receive_player_password().

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

◆ do_hidden_move()

void do_hidden_move ( object op)

For hidden creatures - a chance of becoming 'unhidden' every time they move - as we subtract off 'invisibility' AND, for players, if they move into a ridiculously unhideable spot (surrounded by clear terrain in broad daylight). -b.t.

Parameters
opobject moving.

Definition at line 4037 of file player.cpp.

References calc_skill_exp(), change_exp(), draw_ext_info(), hide(), hideability(), object::level, make_visible(), MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, object_find_by_type_subtype(), give::op, PLAYER, PREFER_LOW, random_roll(), SK_HIDING, SKILL, and object::skill.

Referenced by face_player(), monster_move(), and move_player().

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

◆ do_some_living()

void do_some_living ( object op)

Regenerate hp/sp/gr, decreases food. This only works for players. Will grab food if needed, or kill player.

Parameters
opplayer to regenerate for.

Definition at line 3276 of file player.cpp.

References give::op, and ST_PLAYING.

Referenced by command_possess(), monsterFight(), and process_players1().

+ Here is the caller graph for this function:

◆ dragon_ability_gain()

◆ face_player()

int face_player ( object op,
int  dir 
)

Face player in the given direction.

Parameters
opplayer.
dirdirection to face
Returns
0.

Definition at line 3027 of file player.cpp.

References animate_object(), object::contr, do_hidden_move(), FLAG_CONFUSED, get_randomized_dir(), llevError, LOG(), MAP_IN_MEMORY, give::op, QUERY_FLAG, and turn_transport().

Referenced by command_face().

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

◆ find_arrow()

static object* find_arrow ( object op,
const char *  type 
)
static

Find an arrow in the inventory and after that in the right type container (quiver). Pointer to the found object is returned.

Parameters
opobject to find arrow for.
typewhat arrow race to search for.
Returns
suitable arrow, NULL if none found.

Definition at line 1922 of file player.cpp.

References ARROW, CONTAINER, FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, commongive::inv, give::op, QUERY_FLAG, Ice::tmp, and is_valid_types_gen::type.

Referenced by find_better_arrow(), fire_bow(), and pick_arrow_target().

+ Here is the caller graph for this function:

◆ find_better_arrow()

static object* find_better_arrow ( object op,
object target,
const char *  type,
int *  better 
)
static

Similar to find_arrow(), but looks for (roughly) the best arrow to use against the target. A full test is not performed, simply a basic test of resistances. The archer is making a quick guess at what he sees down the hall. Failing that it does it's best to pick the highest plus arrow.

Parameters
opwho to search arrows for.
targetwhat op is aiming at.
typearrow race to search for.
[out]betterwill contain the arrow's value if not NULL.
Returns
suitable arrow, NULL if none found.

Definition at line 1954 of file player.cpp.

References object::arch, ARROW, AT_DEATH, archetype::clone, CONTAINER, find_arrow(), FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, NROFATTACKS, give::op, QUERY_FLAG, object::race, object::resist, Ice::tmp, and is_valid_types_gen::type.

Referenced by pick_arrow_target().

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

◆ find_key()

object* find_key ( object pl,
object container,
object door 
)

We try to find a key for the door as passed. If we find a key and player can use it (based on the usekeys settings), we return the key, otherwise NULL.

This function merges both normal and locked door, since the logic for both is the same - just the specific key is different.

This function can be called recursively to search containers.

Parameters
plplayer.
containerinventory to searched for keys.
doordoor we are trying to match against.
Returns
key to use, NULL if none found or usekeys mode doesn't let reach the key.
Todo:
document use key modes.

Definition at line 2468 of file player.cpp.

References CONTAINER, DOOR, draw_ext_info_format(), FLAG_APPLIED, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, object::inv, castle_read::key, KEY, key_inventory, keyrings, MAX_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, NDI_BROWN, NDI_UNIQUE, object_find_by_type_and_slaying(), object_find_by_type_without_flags(), altar_valkyrie::pl, QUERY_FLAG, query_name(), object::race, object::slaying, SPECIAL_KEY, Ice::tmp, and object::type.

Referenced by apply_container(), and player_attack_door().

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

◆ find_player()

player* find_player ( const char *  plname)

Find a player by her full name.

Parameters
plnamename to find.
Returns
matching player, or NULL if no match.

Definition at line 59 of file player.cpp.

References find_player_options().

Referenced by command_reply(), and list_players().

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

◆ find_player_options()

player* find_player_options ( const char *  plname,
int  options,
const mapstruct map 
)

Find a player.

Parameters
plnamename of the player to search for. Can be partial.
optionscombination of FIND_PLAYER_xxx flags.
mapoptional map the player must be on (adjacent maps are ok too).
Returns
matching player, NULL if none or more than one.

Definition at line 70 of file player.cpp.

References FIND_PLAYER_NO_HIDDEN_DM, FIND_PLAYER_PARTIAL_NAME, first_player, FLAG_WIZ, is_valid_types_gen::found, disinfect::map, MAX_BUF, give::name, options, altar_valkyrie::pl, QUERY_FLAG, and query_name().

Referenced by basic_emote(), find_player(), and find_player_partial_name().

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

◆ find_player_partial_name()

player* find_player_partial_name ( const char *  plname)

Find a player by a partial name.

Parameters
plnamename to match.
Returns
matching player if only one matching, or one perfectly matching, NULL if no match or more than one.

Definition at line 114 of file player.cpp.

References find_player_options(), and FIND_PLAYER_PARTIAL_NAME.

+ Here is the call graph for this function:

◆ find_player_socket()

player* find_player_socket ( const socket_struct ns)

Return a player for a socket structure.

Parameters
nssocket to search for.
Returns
NULL if no player, player else.

Definition at line 123 of file player.cpp.

References first_player, and altar_valkyrie::pl.

Referenced by add_me_cmd(), and set_up_cmd().

+ Here is the caller graph for this function:

◆ fire()

void fire ( object op,
int  dir 
)

Received a fire command for the player - go and do it.

Parameters
opplayer.
dirdirection to fire into.

Definition at line 2396 of file player.cpp.

References action_makes_visible(), apply_map_builder(), cast_spell(), do_skill(), draw_ext_info(), fire_misc_object(), make_visible(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, give::op, pets_control_golem(), PLAYER, player_fire_bow(), range_bow, range_builder, range_golem, range_magic, range_misc, range_none, range_skill, and nlohmann::detail::void().

Referenced by command_stay(), and move_player().

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

◆ fire_bow()

int fire_bow ( object op,
object arrow,
int  dir,
int  wc_mod,
int16_t  sx,
int16_t  sy 
)

Creature (monster or player) fires a bow.

Parameters
opobject firing the bow.
arrowobject to fire.
dirdirection of fire.
wc_modany special modifier to give (used in special player fire modes)
sx
sycoordinates to fire arrow from - also used in some of the special player fire modes.
Returns
1 if bow was actually fired, 0 otherwise.
Todo:
describe player firing modes.

Definition at line 2093 of file player.cpp.

References add_refcount(), add_string(), object::anim_suffix, apply_anim_suffix(), AT_PHYSICAL, object::attacktype, BOW, bow_bestarrow, change_skill(), CLEAR_FLAG, object::count, living::dam, object::direction, draw_ext_info(), draw_ext_info_format(), FABS, find_arrow(), find_skill_by_name(), fix_object(), FLAG_NO_STRENGTH, FLAG_READY_BOW, free_string(), get_dam_bonus(), get_dex_bonus(), get_map_flags(), GET_MAP_MOVE_BLOCK, get_thaco_bonus(), living::grace, living::hp, if(), object::level, llevError, LOG(), m, object::magic, MOVE_FLY_LOW, object::move_on, object::move_type, MOVE_WALK, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, object::name, NDI_UNIQUE, object::nrof, ob_process(), object_find_by_type(), object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_set_owner(), object_split(), object_update_speed(), object_update_turn_face(), object_was_destroyed, give::op, P_OUT_OF_MAP, play_sound_map(), PLAYER, QUERY_FLAG, object::race, range_bow, object::skill, object::slaying, SOUND_TYPE_ITEM, living::sp, object::speed, object::speed_left, object::spellarg, object::stats, strdup_local, CFweardisguise::tag, and living::wc.

Referenced by monster_use_bow(), and player_fire_bow().

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

◆ fire_misc_object()

static void fire_misc_object ( object op,
int  dir 
)
static

Fires a misc (wand/rod/horn) object in 'dir'. Broken apart from 'fire' to keep it more readable.

Parameters
opplayer firing.
dirfiring direction.
Warning
op must be a player (contr != NULL).

Definition at line 2344 of file player.cpp.

References cast_spell(), drain_rod_charge(), drain_wand_charge(), draw_ext_info(), draw_ext_info_format(), FLAG_BEEN_APPLIED, say::item, llevError, LOG(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, give::name, NDI_UNIQUE, give::op, play_sound_player_only(), query_base_name(), range_misc, ROD, SET_FLAG, SOUND_TYPE_ITEM, SP_level_spellpoint_cost(), SPELL_HIGHEST, and WAND.

Referenced by fire().

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

◆ fix_luck()

void fix_luck ( void  )

Fixes luck of players, slowly move it towards 0.

Definition at line 3910 of file player.cpp.

References change_luck(), first_player, and altar_valkyrie::pl.

Referenced by do_specials().

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

◆ fix_weight()

void fix_weight ( void  )

Check recursively the weight of all players, and fix what needs to be fixed. Refresh windows and fix speed if anything was changed.

Todo:
is this still useful?

Definition at line 3894 of file player.cpp.

References first_player, fix_object(), llevDebug, LOG(), object_sum_weight(), and altar_valkyrie::pl.

Referenced by do_specials().

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

◆ flee_player()

static void flee_player ( object op)
static

The player is scared, and should flee. If she can't, then she isn't scared anymore.

Parameters
opplayer.

Definition at line 1658 of file player.cpp.

References absdir(), CLEAR_FLAG, did_make_save(), rv_vector::direction, FLAG_SCARED, get_rangevector(), llevDebug, LOG(), m, move_ob(), object_set_enemy(), give::op, PREFER_LOW, RANDOM, and random_roll().

Referenced by handle_newcs_player().

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

◆ get_name()

void get_name ( object op)

Waiting for the player's name.

Parameters
opplayer.

Definition at line 881 of file player.cpp.

References i18n(), give::op, player_set_state(), send_query(), and ST_GET_NAME.

Referenced by add_player(), receive_play_again(), receive_player_name(), receive_player_password(), and wrong_password().

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

◆ get_nearest_criminal()

object* get_nearest_criminal ( object mon)

Definition at line 583 of file player.cpp.

References first_player, is_criminal(), mon, monster_can_detect_enemy(), give::op, and altar_valkyrie::pl.

Referenced by monster_find_enemy().

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

◆ get_nearest_player()

object* get_nearest_player ( object mon)

Finds the nearest visible player or player-friendly for some object.

Parameters
monwhat object is searching a player.
Returns
player, or NULL if nothing suitable.

Definition at line 540 of file player.cpp.

References rv_vector::distance, first_player, FLAG_FREED, FLAG_FRIENDLY, free_objectlink(), get_friends_of(), guildoracle::list, mon, monster_can_detect_enemy(), objectlink::next, objectlink::ob, give::op, altar_valkyrie::pl, and QUERY_FLAG.

Referenced by monster_find_enemy(), monster_move(), and START_TEST().

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

◆ get_party_password()

int get_party_password ( object op,
partylist party 
)

Ask the player for the password of the party she wants to join.

Parameters
opplayer.
partyparty op wishes to join.
Returns
whether a party password has been requested from the client

Definition at line 1021 of file player.cpp.

References CS_QUERY_HIDEINPUT, i18n(), give::op, party_get_password(), player_set_state(), send_query(), and ST_GET_PARTY_PASSWORD.

Referenced by command_party().

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

◆ get_password()

void get_password ( object op)

Waiting for the player's password.

Parameters
opplayer.

Definition at line 892 of file player.cpp.

References CS_QUERY_HIDEINPUT, i18n(), give::op, player_set_state(), send_query(), and ST_GET_PASSWORD.

Referenced by receive_player_name().

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

◆ get_player()

player* get_player ( player p)

Create a player's object, initialize a player's structure.

This no longer sets the player map. Also, it now updates all the pointers so the caller doesn't need to do that. Caller is responsible for setting the correct map.

Redo this to do both get_player_ob and get_player. Hopefully this will be bugfree and simpler.

Parameters
pif NULL, a new player structure is created, else p is recycled.
Returns
initialized player structure.

Definition at line 285 of file player.cpp.

References add_string(), arch_to_object(), bow_normal, player::bowtype, living::Cha, CLEAR_FLAG, clear_los(), clear_player(), living::Con, living::Dex, player::do_los, living::exp, fatal(), first_map_path, first_player, FLAG_READY_SKILL, player::gen_sp_armour, get_player_archetype(), i18n_get_language_by_code(), living::Int, player::language, player::last_applied_stats, player::last_character_flags, player::last_resist, player::last_skill_exp, player::last_skill_ob, player::last_speed, player::last_stats, player::last_weapon_sp, player::last_weight, player::listening, MAX_SKILLS, player::no_shout, NROFATTACKS, player::ob, offsetof, give::op, OUT_OF_MEMORY, player::party, party_rejoin_if_exists, player::peaceful, pet_normal, player::petmode, player_set_state(), living::Pow, range_none, player::rejoin_party, roll_stats(), player::savebed_map, player::shoottype, ST_ROLL_STAT, living::Str, player::swap_first, player::ticks_played, player::title, Ice::tmp, player::unapply, unapply_nochoice, player::unarmed_skill, and living::Wis.

Referenced by account_play_cmd(), add_player(), make_perma_dead(), and receive_play_again().

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

◆ get_player_archetype()

static archetype * get_player_archetype ( archetype at)
static

Get next player archetype from archetype list. Not very efficient routine, but used only creating new players.

Note
there MUST be at least one player archetype! Will exit() if none.
Parameters
atarchetype to search from.
Returns
next player archetype available.

Definition at line 505 of file player.cpp.

References AssetsManager::archetypes(), archetype::clone, AssetsCollection< T, Key >::each(), fatal(), getManager(), llevError, LOG(), PLAYER, players, SEE_LAST_ERROR, and object::type.

Referenced by get_player(), and key_change_class().

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

◆ give_initial_items()

void give_initial_items ( object pl,
treasurelist items 
)

Gives a new player her initial items.

They will be god-given, and suitable for the player's race/restrictions.

Parameters
plplayer.
itemstreasure list containing the items.

Now we do a second loop, to apply weapons/armors/... This is because weapons require the skill, which can be given after the first loop.

Definition at line 784 of file player.cpp.

References AP_NOPRINT, apply_manual(), CLEAR_FLAG, create_treasure(), FLAG_APPLIED, FLAG_CAN_USE_SKILL, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_INV_LOCKED, FLAG_NEUTRAL, FLAG_STARTEQUIP, FLAG_USE_ARMOUR, FLAG_USE_SHIELD, FLAG_USE_WEAPON, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, is_valid_types_gen::found, GT_ONLY_GOOD, GT_STARTEQUIP, IS_ARMOR, is_identifiable_type(), IS_SHIELD, IS_WEAPON, link_player_skills(), llevError, LOG(), object_can_merge(), object_free_drop_inventory(), object_remove(), give::op, altar_valkyrie::pl, PLAYER, QUERY_FLAG, SET_FLAG, SKILL, SPELLBOOK, and Ice::tmp.

Referenced by apply_changes_to_player(), apply_race_and_class(), and key_change_class().

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

◆ gravestone_text()

static const char* gravestone_text ( object op,
char *  buf2,
int  len 
)
static

Create a text for a player's gravestone.

Moved from apply.c to player.c - player.c is what actually uses this function. player.c may not be quite the best, a misc file for object actions is probably better, but there isn't one in the server directory.

Parameters
opplayer.
buf2buffer to write the text to. Mustn't be NULL.
lenlength of buf2.
Returns
buf2, containing gravestone text.

Definition at line 3237 of file player.cpp.

References buf, MAX_BUF, give::op, and PLAYER.

Referenced by kill_player_permadeath().

+ Here is the caller graph for this function:

◆ handle_newcs_player()

int handle_newcs_player ( object op)

Handles commands the player can send us, and various checks on invisibility, golem and such.

This is sort of special, in that the new client/server actually uses the new speed values for commands.

Parameters
opplayer to handle.
Returns
true if there are more actions we can do.

Definition at line 3086 of file player.cpp.

References CLEAR_FLAG, draw_ext_info(), FLAG_MAKE_INVIS, FLAG_PARALYZED, FLAG_REMOVED, FLAG_SCARED, flee_player(), make_visible(), move_player(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, MSG_TYPE_SPELL, MSG_TYPE_SPELL_END, NDI_UNIQUE, give::op, PLAYER, pticks, QUERY_FLAG, and range_golem.

Referenced by process_players1().

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

◆ hideability()

int hideability ( object ob)

Look at the surrounding terrain to determine the hideability of this object. Positive levels indicate greater hideability.

Parameters
obobject that may want to hide.
Returns
the higher the value, the easier to hide here.

Definition at line 3996 of file player.cpp.

References freearr_x, freearr_y, get_map_flags(), has_carried_lights(), level, guildjoin::ob, P_BLOCKSVIEW, P_OUT_OF_MAP, diamondslots::x, and diamondslots::y.

Referenced by attempt_hide(), and do_hidden_move().

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

◆ is_true_undead()

int is_true_undead ( object op)

Is the object a true undead?

Parameters
opobject to test.
Returns
1 if undead, 0 else.

Definition at line 3979 of file player.cpp.

References FLAG_UNDEAD, give::op, and QUERY_FLAG.

Referenced by makes_invisible_to(), monster_can_detect_enemy(), and monster_can_see_enemy().

+ Here is the caller graph for this function:

◆ key_change_class()

void key_change_class ( object op,
char  key 
)

This function takes the key that is passed, and does the appropriate action with it (change race, or other things). The function name is for historical reasons - now we have separate race and class; this actually changes the RACE, not the class.

Parameters
opplayer.
keykey to handle.

Definition at line 1289 of file player.cpp.

References add_statbonus(), add_string(), allowed_class(), buf, CLEAR_FLAG, create_treasure(), CS_QUERY_SINGLECHAR, draw_ext_info(), draw_ext_info_format(), enter_exit(), esrv_new_player(), esrv_send_inventory(), esrv_update_item(), EVENT_BORN, EVENT_LOGIN, events_execute_global_event(), EXIT_PATH, EXIT_X, EXIT_Y, find_treasurelist(), first_map_ext_path, fix_object(), FLAG_WIZ, free_string(), get_player_archetype(), give_initial_items(), i18n(), castle_read::key, link_player_skills(), llevDebug, Settings::localdir, LOG(), make_path_to_file(), guild_questpoints_apply::mapname, MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, MSG_TYPE_ADMIN_PLAYER, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, give::name, NDI_ALL, NDI_BLUE, NDI_DK_ORANGE, NDI_UNIQUE, object_copy(), object_free_drop_inventory(), object_insert_in_map_at(), object_new(), object_remove(), object_set_msg(), object_update(), give::op, play_again(), player_set_state(), Settings::playerdir, pticks, remove_statbonus(), send_query(), SET_ANIMATION, settings, ST_PLAYING, strlcpy(), Ice::tmp, UP_OBJ_FACE, UPD_FACE, diamondslots::x, and diamondslots::y.

Referenced by reply_cmd().

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

◆ key_confirm_quit()

◆ key_roll_stat()

void key_roll_stat ( object op,
char  key 
)

Player is currently swapping stats.

This code has been greatly reduced, because with set_attr_value and get_attr_value, the stats can be accessed just numeric ids. stat_trans is a table that translate the number entered into the actual stat. It is needed because the order the stats are displayed in the stat window is not the same as how the number's access that stat. The table does that translation.

Parameters
opplayer.
keyreceived key.

Definition at line 1213 of file player.cpp.

References add_statbonus(), CHARISMA, CONSTITUTION, CS_QUERY_SINGLECHAR, DEXTERITY, draw_ext_info(), draw_ext_info_format(), FLAG_WIZ, i18n(), INTELLIGENCE, castle_read::key, llevError, LOG(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_BLUE, NDI_UNIQUE, give::op, play_again(), player_set_state(), POWER, roll_stats(), send_query(), SET_ANIMATION, SET_FLAG, short_stat_name, ST_CHANGE_CLASS, STRENGTH, swap_stat(), and WISDOM.

Referenced by reply_cmd().

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

◆ kill_player()

void kill_player ( object op,
const object killer 
)

Handle a player's death.

Also deals with lifesaving objects, arena deaths, cleaning disease/poison, death penalties, and removing the player file in case of permadeath.

Parameters
opPlayer to be killed.
killerThe object that's trying to kill op, which can be NULL.

Definition at line 3492 of file player.cpp.

References add_string(), arch_to_object(), buf, draw_ext_info(), EVENT_DEATH, EVENT_PLAYER_DEATH, events_execute_global_event(), events_execute_object_event(), FLESH, kill_player_not_permadeath(), kill_player_permadeath(), sword_of_souls::killer, MAX_BUF, MAX_FOOD, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_DIED, NDI_NAVY, NDI_UNIQUE, Settings::not_permadeth, object_insert_in_map_at(), object_set_msg(), give::op, op_on_battleground(), play_sound_player_only(), restore_player(), save_life(), SCRIPT_FIX_ALL, settings, SOUND_TYPE_LIVING, starving(), Ice::tmp, transfer_ob(), TRUE, diamondslots::x, and diamondslots::y.

Referenced by check_login(), deep_swamp_type_process(), kill_object(), and save_throw_object().

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

◆ kill_player_not_permadeath()

static void kill_player_not_permadeath ( object op)
static

◆ kill_player_permadeath()

◆ loot_object()

static void loot_object ( object op)
static

Grab and destroy some treasure.

Parameters
opobject to loot.

Definition at line 3415 of file player.cpp.

References AP_NULL, apply_container(), CONTAINER, FLAG_NO_DROP, FLAG_STARTEQUIP, FLAG_UNIQUE, FOR_INV_FINISH, FOR_INV_PREPARE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_split(), give::op, QUERY_FLAG, RANDOM, and Ice::tmp.

Referenced by kill_player_permadeath().

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

◆ make_visible()

void make_visible ( object op)

Makes an object visible again.

Parameters
opwhat to make visible.

Definition at line 3960 of file player.cpp.

References FREE_AND_CLEAR_STR, object_update(), give::op, PLAYER, and UP_OBJ_FACE.

Referenced by attack_ob_simple(), attempt_steal(), do_hidden_move(), fire(), handle_newcs_player(), hide(), monster_can_detect_enemy(), monster_can_see_enemy(), move_player_attack(), and player_attack_door().

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

◆ move_player()

int move_player ( object op,
int  dir 
)

Move player in the given direction. Can be called by a client through a movement command, or by the server for some other reasons.

Parameters
opplayer.
dirdirection to move/fire.
Returns
0.

Definition at line 2948 of file player.cpp.

References animate_object(), check_pick(), object::contr, do_hidden_move(), fire(), FLAG_CONFUSED, get_randomized_dir(), llevError, LOG(), MAP_IN_MEMORY, move_player_attack(), give::op, QUERY_FLAG, object::speed_left, and turn_transport().

Referenced by cfapi_object_move(), command_fire(), command_run(), handle_newcs_player(), monsterFight(), move_internal(), move_player_mover(), move_towards(), and pray_at_altar().

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

◆ move_player_attack()

void move_player_attack ( object op,
int  dir 
)

The player is also actually going to try and move (not fire weapons).

This function is just part of a breakup from move_player(). It should keep the code cleaner. When this is called, the players direction has been updated (taking into account confusion).

Parameters
opplayer moving.
dirmoving direction.

Definition at line 2623 of file player.cpp.

References action_makes_visible(), object::contr, DOOR, draw_ext_info(), object::enemy, FLAG_ALIVE, FLAG_CAN_ROLL, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_from_coord(), GET_MAP_OB, player::has_hit, HEAD, living::hp, LOCKED_DOOR, living::luck, m, make_visible(), object::map, mon, move_ob(), MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_NOATTACK, object_get_owner(), give::op, op_on_battleground(), out_of_map(), OUT_OF_REAL_MAP, player::party, play_sound_map(), PLAYER, player_attack_door(), player_map_change_common(), push_ob(), QUERY_FLAG, recursive_roll(), skill_attack(), SOUND_TYPE_LIVING, object::stats, Ice::tmp, object::type, nlohmann::detail::void(), object::x, and object::y.

Referenced by move_player().

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

◆ op_on_battleground()

int op_on_battleground ( object op,
int *  x,
int *  y,
archetype **  trophy 
)

Check if the given object (usually a player) is standing on a battleground tile. This is used to handle deaths and special attacks in arenas.

A battleground tile must have the following attributes set:

  • name "battleground"
  • type 58 (BATTLEGROUND)
  • is_floor 1 (must be the first tile beneath the player's feet)
  • no_pick 1
  • sp / hp > 0 (non-zero exit coordinates)

If the tile has 'slaying', 'maxhp', and 'maxsp' set, and the player has a matching marker, send the player to those coordinates instead.

If the tile has 'other_arch' set, then create that archetype as the trophy instead of the default ("finger").

Parameters
opObject to check (usually a player).
[out]x
[out]yIf not NULL and standing on a battleground tile, store exit coordinates.
[out]trophyIf not NULL and standing on a battleground tile, store a pointer to the archetype that can be collected by the winner.
Returns
TRUE if op is on a battleground, FALSE if not.

Definition at line 4245 of file player.cpp.

References BATTLEGROUND, EXIT_ALT_X, EXIT_ALT_Y, EXIT_PATH, EXIT_X, EXIT_Y, find_archetype(), FLAG_IS_FLOOR, FLAG_NO_PICK, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, FORCE, object_find_by_type_and_slaying(), give::op, QUERY_FLAG, Ice::tmp, diamondslots::x, and diamondslots::y.

Referenced by hit_player(), hit_with_drain(), hit_with_one_attacktype(), infect_object(), kill_object(), kill_player(), move_player_attack(), pets_should_arena_attack(), and spell_find_dir().

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

◆ path_to_player()

int path_to_player ( object mon,
object pl,
unsigned  mindiff 
)

Returns the direction to the player, if valid. Returns 0 otherwise.

Modified to verify there is a path to the player. Does this by stepping towards player and if path is blocked then see if blockage is close enough to player that direction to player is changed (ie zig or zag). Continue zig zag until either reach player or path is blocked. Thus, will only return true if there is a free path to player. Though path may not be a straight line. Note that it will find player hiding along a corridor at right angles to the corridor with the monster.

Modified by MSW 2001-08-06 to handle tiled maps. Various notes:

  • With DETOUR_AMOUNT being 2, it should still go and find players hiding down corridors.
  • I think the old code was broken if the first direction the monster should move was blocked - the code would store the first direction without verifying that the player can actually move in that direction. The new code does not store anything in firstdir until we have verified that the monster can in fact move one space in that direction.
  • I'm not sure how good this code will be for moving multipart monsters, since only simple checks to blocked are being called, which could mean the monster is blocking itself.
Parameters
monsource object.
pltarget.
mindiffminimal distance mon and pl should have.
Returns
direction from mon to pl, 0 if can't get there.

Definition at line 651 of file player.cpp.

References absdir(), blocked_link(), DETOUR_AMOUNT, rv_vector::direction, rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, FABS, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, get_rangevector(), get_rangevector_from_mapcoord(), m, object::map, MAX, say::max, MAX_SPACES, mon, MOVE_ALL, OB_TYPE_MOVE_BLOCK, P_IS_ALIVE, P_OUT_OF_MAP, altar_valkyrie::pl, diamondslots::x, object::x, diamondslots::y, and object::y.

Referenced by monster_cast_spell(), monster_use_range(), monster_use_scroll(), and monster_use_skill().

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

◆ pick_arrow_target()

static object* pick_arrow_target ( object op,
const char *  type,
int  dir 
)
static

Looks in a given direction, finds the first valid target, and calls find_better_arrow() to find a decent arrow to use.

Parameters
opshooter.
typearrow's race to search for (the bow's usually).
dirfire direction.
Returns
suitable arrow, or NULL if none found.

Definition at line 2024 of file player.cpp.

References die_roll(), find_arrow(), find_better_arrow(), FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, is_valid_types_gen::found, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, HEAD, m, MOVE_FLY_LOW, give::op, P_BLOCKSVIEW, P_IS_ALIVE, P_OUT_OF_MAP, PREFER_LOW, QUERY_FLAG, Ice::tmp, is_valid_types_gen::type, diamondslots::x, and diamondslots::y.

Referenced by player_fire_bow().

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

◆ play_again()

void play_again ( object op)

Ask the player whether to play again or disconnect.

Parameters
opplayer.

Definition at line 903 of file player.cpp.

References CS_QUERY_SINGLECHAR, FLAG_REMOVED, i18n(), Ns_Add, object_remove(), give::op, player_set_state(), QUERY_FLAG, receive_play_again(), send_query(), Send_With_Handling(), SockList_AddChar(), SockList_AddInt(), SockList_AddString(), SockList_Init(), SockList_Term(), and ST_PLAY_AGAIN.

Referenced by apply_savebed(), key_change_class(), key_confirm_quit(), key_roll_stat(), kill_player_permadeath(), and receive_play_again().

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

◆ player_attack_door()

static int player_attack_door ( object op,
object door 
)
static

Player is "attacking" a door. Will try to open it with a key, or warn if can't open it.

Moved out of move_player_attack().

Return values
1player has opened the door with a key such that the caller should not do anything more.
0nothing happened.

Definition at line 2550 of file player.cpp.

References action_makes_visible(), do_skill(), DOOR, draw_ext_info(), draw_ext_info_format(), find_key(), find_skill_by_name(), HUGE_BUF, object::inv, castle_read::key, LOCKED_DOOR, make_visible(), object::msg, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, MSG_TYPE_ITEM_REMOVE, give::name, NDI_BROWN, NDI_NAVY, NDI_UNIQUE, object_decrease_nrof_by_one, give::op, play_sound_map(), query_short_name(), remove_door(), remove_locked_door(), RUNE, SOUND_TYPE_GROUND, spring_trap(), TRAP, and object::type.

Referenced by move_player_attack().

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

◆ player_can_view()

int player_can_view ( object pl,
object op 
)

Check the player los field for viewability of the object op. This function works fine for monsters, but we dont worry if the object isnt the top one in a pile (say a coin under a table would return "viewable" by this routine). Another question, should we be concerned with the direction the player is looking in? Realistically, most of use cant see stuff behind our backs...on the other hand, does the "facing" direction imply the way your head, or body is facing? Its possible for them to differ. Sigh, this fctn could get a bit more complex. -b.t.

This function is now map tiling safe.

Parameters
plplayer that may see op.
opwhat may be seen by pl.
Return values
-1pl isn't a player
0pl can't see op.
1pl can see op.

Definition at line 4146 of file player.cpp.

References rv_vector::distance_x, rv_vector::distance_y, FABS, get_rangevector(), HEAD, llevError, LOG(), give::op, altar_valkyrie::pl, and PLAYER.

Referenced by adj_attackroll(), monster_can_detect_enemy(), and monster_can_see_enemy().

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

◆ player_fire_bow()

static int player_fire_bow ( object op,
int  dir 
)
static

Special fire code for players - this takes into account the special fire modes players can have but monsters can't. Putting that code here makes the fire_bow() code much cleaner.

This function should only be called if 'op' is a player, hence the function name.

Parameters
opplayer.
dirfiring direction.
Returns
1 if arrow was fired, 0 else.

Definition at line 2308 of file player.cpp.

References absdir(), bow_bestarrow, bow_n, bow_nw, bow_spreadshot, bow_threewide, fire_bow(), freearr_x, freearr_y, give::op, pick_arrow_target(), range_bow, and similar_direction().

Referenced by fire().

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

◆ player_get_delayed_buffer()

SockList* player_get_delayed_buffer ( player pl)

Get a delayed socket buffer, that will be sent after the player's tick is complete. Will fatal() if memory error.

Parameters
plplayer to get a buffer for.
Returns
buffer, never NULL.

Definition at line 4484 of file player.cpp.

References fatal(), llevError, LOG(), OUT_OF_MEMORY, altar_valkyrie::pl, and SockList_Init().

+ Here is the call graph for this function:

◆ player_set_state()

void player_set_state ( player pl,
uint8_t  state 
)

Set the player's state to the specified one.

Parameters
plwho to set state for.
statenew state.

Definition at line 4471 of file player.cpp.

References altar_valkyrie::pl, ST_CHANGE_PASSWORD_CONFIRM, and dragon::state.

Referenced by add_player(), check_login(), command_delete(), command_passwd(), confirm_password(), create_player_cmd(), get_name(), get_party_password(), get_password(), get_player(), key_change_class(), key_confirm_quit(), key_roll_stat(), play_again(), receive_party_password(), receive_play_again(), and receive_player_password().

+ Here is the caller graph for this function:

◆ player_unready_range_ob()

void player_unready_range_ob ( player pl,
object ob 
)

Unready an object for a player. This function does nothing if the object was not readied.

Parameters
plplayer.
obobject to unready.

Definition at line 4453 of file player.cpp.

References guildjoin::ob, altar_valkyrie::pl, range_none, and range_size.

Referenced by become_follower(), do_forget_spell(), and remove_special_prayers().

+ Here is the caller graph for this function:

◆ playername_ok()

int playername_ok ( const char *  cp)

Is the player name valid.

Parameters
cpname to test.
Returns
0 if invalid, 1 if valid.

Definition at line 257 of file player.cpp.

Referenced by check_name(), and create_player_cmd().

+ Here is the caller graph for this function:

◆ receive_play_again()

void receive_play_again ( object op,
char  key 
)

Player replied to play again / disconnect.

Parameters
opplayer.
keyreceived choice.

Definition at line 956 of file player.cpp.

References add_friendly_object(), add_refcount(), add_string(), draw_ext_info(), FREE_AND_CLEAR_STR, get_name(), get_player(), castle_read::key, leave(), MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, give::name, NDI_UNIQUE, object_free_drop_inventory(), give::op, altar_valkyrie::pl, play_again(), player_set_state(), remove_friendly_object(), send_account_players(), set_first_map(), and ST_GET_NAME.

Referenced by play_again(), and reply_cmd().

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

◆ remove_unpaid_objects()

void remove_unpaid_objects ( object op,
object env,
int  free_items 
)

This goes throws the inventory and removes unpaid objects, and puts them back in the map (location and map determined by values of env) or frees them. This function will descend into containers.

Parameters
opobject to start the search from.
envtop-level container, should be in a map if free_items is 0, unused if free_items is 1.
free_itemsif set, unpaid items are freed, else they are inserted in the same map as env.

Definition at line 3207 of file player.cpp.

References env, FLAG_UNPAID, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), give::op, and QUERY_FLAG.

Referenced by check_login(), execute_word_of_recall(), and kill_player_not_permadeath().

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

◆ restore_player()

static void restore_player ( object op)
static

Remove confusion, disease, and poison on death. Used in battleground not-death and non-perma-death

Abstracted out to its own function to de-spaghettify the death code a little

Parameters
opThe player object being killed. Assumes that the object is a player, but does not check

Definition at line 3454 of file player.cpp.

References arch_present_in_ob(), cure_disease(), draw_ext_info(), find_archetype(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, NDI_UNIQUE, object_free_drop_inventory(), object_remove(), give::op, and Ice::tmp.

Referenced by kill_player(), and kill_player_not_permadeath().

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

◆ roll_again()

void roll_again ( object op)

Ask the player what to do with the statistics.

Parameters
opplayer.

Definition at line 1141 of file player.cpp.

References CS_QUERY_SINGLECHAR, esrv_new_player(), i18n(), give::op, and send_query().

Referenced by add_player(), and receive_player_password().

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

◆ roll_stat()

int roll_stat ( void  )

This rolls four 1-6 rolls and sums the best 3 of the 4.

Returns
sum of rolls.

Definition at line 1038 of file player.cpp.

References RANDOM.

Referenced by roll_stats().

+ Here is the caller graph for this function:

◆ roll_stats()

void roll_stats ( object op)

Roll the initial player's statistics.

Parameters
opplayer to roll for.

Definition at line 1062 of file player.cpp.

References fix_object(), give::op, roll_stat(), Settings::roll_stat_points, and settings.

Referenced by get_player(), and key_roll_stat().

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

◆ save_life()

static int save_life ( object op)
static

Can the player be saved by an item?

Parameters
opplayer to try to save.
Return values
1player had his life saved by an item, first item saving life is removed.
0player had no life-saving item.

Definition at line 3164 of file player.cpp.

References CLEAR_FLAG, draw_ext_info_format(), enter_player_savebed(), fix_object(), FLAG_LIFESAVE, llevError, LOG(), MAX_BUF, MAX_FOOD, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, give::name, NDI_UNIQUE, object_find_by_flag_applied(), object_free_drop_inventory(), object_remove(), give::op, play_sound_map(), QUERY_FLAG, query_name(), SOUND_TYPE_ITEM, and Ice::tmp.

Referenced by kill_player().

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

◆ send_news()

void send_news ( const object op)

Send the news to a player.

Parameters
opplayer to send to.

Definition at line 206 of file player.cpp.

References buf, Settings::confdir, draw_ext_info_format(), HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, NDI_GREEN, NDI_UNIQUE, Settings::news, give::op, safe_strcat(), safe_strncpy, settings, and strip_endline().

Referenced by add_player(), and command_news().

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

◆ send_rules()

void send_rules ( const object op)

Send the rules to a player.

Parameters
opplayer to send rules to.

Definition at line 170 of file player.cpp.

References buf, Settings::confdir, draw_ext_info(), HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, NDI_GREEN, NDI_UNIQUE, give::op, Settings::rules, safe_strcat(), and settings.

Referenced by add_player(), and command_rules().

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

◆ set_first_map()

void set_first_map ( object op)

This loads the first map an puts the player on it.

Parameters
opplayer to put on map.

Definition at line 394 of file player.cpp.

References enter_player_maplevel(), first_map_path, and give::op.

Referenced by add_player(), and receive_play_again().

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

◆ set_player_socket()

void set_player_socket ( player p,
socket_struct ns 
)

This copies the data from the socket into the player structure. Originally written to separate this logic from add_player() so new character method could use it, but that did not work out, but still a good thing to have this separate.

Parameters
pThe target player object to copy the data into
nsthe socket structure to copy.

Definition at line 413 of file player.cpp.

References account_char_free(), socket_struct::account_chars, socket_struct::account_name, socket_struct::faces_sent, fatal(), socket_struct::host, socket_struct::inbuf, OUT_OF_MEMORY, player::socket, SockList_ResetRead(), and strdup_local.

Referenced by account_play_cmd(), and add_player().

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

◆ similar_direction()

static int similar_direction ( int  a,
int  b 
)
static

Is direction a similar to direction b? Find out in this exciting function below.

Parameters
a
bdirections to compare.
Returns
1 if similar, 0 if not.

Definition at line 2274 of file player.cpp.

References disinfect::a, and Ice::b.

Referenced by player_fire_bow().

+ Here is the caller graph for this function:

◆ stand_near_hostile()

int stand_near_hostile ( object who)

Determine if who is standing near a hostile creature.

Parameters
whoobject to check.
Returns
1 if near a monster, 0 else.

Definition at line 4078 of file player.cpp.

References FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, m, OB_TYPE_MOVE_BLOCK, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, Ice::tmp, autojail::who, diamondslots::x, and diamondslots::y.

Referenced by attempt_hide().

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

◆ starving()

static bool starving ( object op)
static

Definition at line 3265 of file player.cpp.

References give::op.

Referenced by kill_player().

+ Here is the caller graph for this function:

◆ swap_stat()

static void swap_stat ( object op,
int  swap_second 
)
static

Player finishes selecting what stats to swap.

Parameters
opplayer.
swap_secondsecond statistic to swap.
Todo:
why the reinit of exp/ac/...?

Definition at line 1155 of file player.cpp.

References draw_ext_info_format(), fix_object(), get_attr_value(), llevError, LOG(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_UNIQUE, give::op, set_attr_value(), short_stat_name, and Ice::tmp.

Referenced by key_roll_stat().

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

◆ turn_one_transport()

static int turn_one_transport ( object transport,
object captain,
int  dir 
)
static

Turn a transport to an adjacent direction (+1 or -1), updating the move_type flags in the same process.

Parameters
transportwhat to turn. Must be of type TRANSPORT.
captainwho wants to turn the boat.
dirdirection to turn to.
Returns
  • 1 if the transport turned (so can't move anymore this tick)
  • 2 if the transport couldn't turn

Definition at line 2845 of file player.cpp.

References animate_object(), object::direction, esrv_map_scroll(), object::facing, FOR_INV_FINISH, FOR_INV_PREPARE, freearr_x, freearr_y, object::map, ob_blocked(), object_insert_in_map_at(), object_remove(), altar_valkyrie::pl, PLAYER, TRANSPORT, object::type, update_transport_block(), diamondslots::x, object::x, diamondslots::y, and object::y.

Referenced by turn_transport().

+ Here is the call graph for this function: