Crossfire Server, Trunk  R22047
login.c File Reference
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "define.h"
#include "loader.h"
#include "output_file.h"
#include "spells.h"
#include "sproto.h"
#include "server.h"
+ Include dependency graph for login.c:

Go to the source code of this file.


void check_login (object *op, int check_pass)
int check_name (player *me, const char *name)
static void copy_file (const char *filename, FILE *fpout)
void delete_character (const char *name)
void destroy_object (object *op)
void emergency_save (int flag)
int save_player (object *op, int flag)
int verify_player (const char *name, char *password)
static void wrong_password (object *op)

Detailed Description

Player login/logout/save functions.

Definition in file login.c.

Function Documentation

◆ check_login()

void check_login ( object *  op,
int  check_pass 

Actually login a player, load from disk and such.

check_passIf true, we should do password checking. Otherwise, we just log this character in. This later setting is used for the account code, where that already does authentication.
describe connect/login/logout/disconnect process.

Definition at line 501 of file login.c.

References add_string(), pl::bed_x, pl::bed_y, pl::bowtype, buf, liv::Cha, check_password(), check_path(), CLEAR_FLAG, liv::Con, confirm_password(), containers, liv::Dex, pl::digestion, draw_ext_info(), draw_ext_info_format(), enter_player_maplevel(), esrv_add_spells(), esrv_new_player(), esrv_send_inventory(), esrv_send_pickup(), EVENT_LOGIN, events_execute_global_event(), final_free_player(), first_map_path, first_player, fix_object(), FLAG_FRIENDLY, FLAG_NO_FIX_PLAYER, FLAG_REMOVED, FLAG_USE_ARMOUR, FLAG_USE_SHIELD, pl::gen_grace, pl::gen_hp, pl::gen_sp, has_been_loaded(), pl::has_directory, socket_struct::host, i18n_get_language_by_code(), liv::Int, is_dragon_pl(), key_inventory, keyrings, kill_player(), knowledge_send_known(), pl::language, leave(), legal_range(), pl::levgrace, pl::levhp, pl::levsp, link_player_skills(), pl::listening, llevDebug, llevError, llevInfo, LO_NEWFILE, load_object(), Settings::localdir, LOG(), login_check_shutdown(), pl::maplevel, MAX_BUF, pl::mode, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, MSG_TYPE_ADMIN_PLAYER, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_SUCCESS, pl::name_changed, NDI_ALL, NDI_DK_ORANGE, NDI_UNIQUE, pl::next, pl::no_shout, Ns_Dead, pl::ob, object_find_by_type_and_arch_name(), object_remove(), object_reset(), object_sum_weight(), object_update_speed(), pl::orig_stats, pl::party, party_confirm_password(), party_find(), party_form(), party_join(), party_rejoin_always, party_rejoin_no, party_set_password(), party_struct::partyname, pl::password, pl::peaceful, pl::petmode, player_set_own_title(), player_set_state(), Settings::playerdir, liv::Pow, pticks, QUERY_FLAG, quest_send_initial_states(), range_none, pl::rejoin_party, remove_unpaid_objects(), Settings::reset_loc_time, save_player(), pl::savebed_map, Settings::search_items, pl::search_str, set_dragon_name(), SET_FLAG, Settings::set_title, settings, pl::shoottype, snprintf, pl::socket, pl::spellparam, ST_PLAYING, pl::state, liv::Str, strdup_local, strlcpy(), pl::ticks_played, pl::title, TRUE, pl::unapply, unapply_always, unapply_never, unapply_nochoice, pl::unarmed_skill, pl::usekeys, liv::Wis, pl::write_buf, and wrong_password().

Referenced by account_play_cmd(), and receive_player_password().

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

◆ check_name()

int check_name ( player me,
const char *  name 

Ensure player's name is valid.

meplayer to report to.
namename to check.
Return values
0invalid name.
1valid name.

Definition at line 163 of file login.c.

References draw_ext_info(), draw_ext_info_format(), MAX_NAME, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, NDI_UNIQUE, pl::ob, and playername_ok().

Referenced by receive_player_name().

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

◆ copy_file()

static void copy_file ( const char *  filename,
FILE *  fpout 

Copy a file.

filenamesource file.
fpoutwhere to copy to.

Definition at line 445 of file login.c.

References buf, llevError, LOG(), and MAX_BUF.

Referenced by save_player().

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

◆ delete_character()

void delete_character ( const char *  name)

Totally deletes a character. The contents of its directory are effectively totally removed. Used when a player 'quits' the game, or dies on a server with permadeath and no resurrect.

nameplayer to delete.

Definition at line 87 of file login.c.

References buf, Settings::localdir, MAX_BUF, Settings::playerdir, remove_directory(), settings, and snprintf.

Referenced by key_confirm_quit(), and kill_player_permadeath().

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

◆ destroy_object()

void destroy_object ( object *  op)

Recursively object_free_drop_inventory() op and its inventory.

opobject to totally object_free_drop_inventory().
trash that function

Definition at line 191 of file login.c.

References FLAG_REMOVED, object_free_drop_inventory(), object_remove(), and QUERY_FLAG.

Referenced by save_player(), and trap_disarm().

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

◆ emergency_save()

void emergency_save ( int  flag)

Save all players.

flagif non zero, it means that we want to try and save everyone, but keep the game running. Thus, we don't want to free any information.

Definition at line 41 of file login.c.

References draw_ext_info(), first_map_path, first_player, hiscore_check(), llevError, llevInfo, LOG(), pl::maplevel, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOADSAVE, NDI_UNIQUE, pl::next, pl::ob, save_player(), and trying_emergency_save.

+ Here is the call graph for this function:

◆ save_player()

int save_player ( object *  op,
int  flag 

Saves a player to disk.

opplayer to save.
flagif is set, it's only backup, ie dont remove objects from inventory. If BACKUP_SAVE_AT_HOME is set, and the flag is set, then the player will be saved at the emergency save location.
non zero if successful.

Definition at line 212 of file login.c.

References account_char_add(), account_char_save(), socket_struct::account_chars, account_get_account_for_char(), account_link(), socket_struct::account_name, pl::bed_x, pl::bed_y, pl::bowtype, liv::Cha, checksum(), CLEAR_FLAG, liv::Con, copy_file(), destroy_object(), liv::Dex, pl::digestion, draw_ext_info(), draw_ext_info_format(), Settings::emergency_mapname, esrv_send_inventory(), FLAG_NO_FIX_PLAYER, FLAG_WIZ, pl::gen_grace, pl::gen_hp, pl::gen_sp, i18n_get_language_code(), liv::Int, key_inventory, keyrings, knowledge_first_player_save(), pl::language, pl::levgrace, pl::levhp, pl::levsp, pl::listening, llevDebug, llevError, Settings::localdir, LOG(), make_path_to_file(), MAX_BUF, MAX_SKILLS, MIN, pl::mode, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOADSAVE, pl::name_changed, NDI_ALL_DMS, NDI_RED, NDI_UNIQUE, pl::no_shout, pl::ob, of_close(), of_open(), pl::orig_stats, pl::party, party_get_password(), party_struct::partyname, pl::password, pl::peaceful, pl::petmode, pets_terminate_all(), player_get_own_title(), player_has_own_title(), Settings::playerdir, liv::Pow, QUERY_FLAG, quest_first_player_save(), range_none, pl::rejoin_party, SAVE_ERROR_OK, SAVE_FLAG_NO_REMOVE, SAVE_FLAG_SAVE_UNPAID, SAVE_MODE, save_object(), pl::savebed_map, SET_FLAG, Settings::set_title, settings, pl::shoottype, snprintf, pl::socket, ST_GET_PARTY_PASSWORD, ST_PLAYING, pl::state, liv::Str, tempnam_secure(), pl::ticks_played, Settings::tmpdir, TRUE, pl::unapply, unapply_never, unapply_nochoice, pl::unarmed_skill, unlink, pl::usekeys, and liv::Wis.

Referenced by account_play_cmd(), apply_savebed(), check_login(), command_kick2(), command_save(), do_server(), drop_object(), emergency_save(), enter_exit(), kill_player_not_permadeath(), kill_player_permadeath(), player_changer_type_process(), and process_players1().

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

◆ verify_player()

int verify_player ( const char *  name,
char *  password 

This verify that a character of name exits, and that it matches password.

nameplayer name.
passwordplayer's password, not encrypted.
Return values
0there is match.
1no such player.
2incorrect password.

Definition at line 110 of file login.c.

References buf, check_password(), llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, Settings::playerdir, settings, and snprintf.

Referenced by account_add_player_cmd(), and create_player_cmd().

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

◆ wrong_password()

static void wrong_password ( object *  op)

Simple function to print errors when password is not correct, and reinitialise the name.


Definition at line 466 of file login.c.

References draw_ext_info(), FREE_AND_COPY, get_name(), llevInfo, LOG(), MAX_PASSWORD_FAILURES, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, NDI_UNIQUE, and Ns_Dead.

Referenced by check_login().

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