Go to the documentation of this file.
42 #ifndef NO_EMERGENCY_SAVE
70 "Emergency save failed, checking score...");
77 LOG(
llevInfo,
"Emergency saves disabled, no save attempted\n");
116 if (strpbrk(
name,
"/.\\") != NULL) {
138 if (strlen(
buf) >=
sizeof(
buf)-1) {
143 fp = fopen(
buf,
"r");
153 if (!strncmp(
buf,
"password ", 9)) {
184 "Your username cannot be blank.");
190 "That name contains illegal characters. Use letters, hyphens and underscores only. Hyphens and underscores are not allowed as the first character.");
195 "That name is too long. (Max length: %d characters)",
MAX_NAME);
210 while (
op->inv != NULL)
234 object *container = NULL;
238 #ifdef BACKUP_SAVE_AT_HOME
239 int16_t backup_x, backup_y;
251 "Your game is not valid, game not saved.");
290 "Can't get secure temporary file for save.");
291 LOG(
llevDebug,
"Can't get secure temporary file for save.\n");
297 container =
op->container;
298 op->container = NULL;
306 fprintf(fp,
"gen_hp %d\n",
pl->
gen_hp);
307 fprintf(fp,
"gen_sp %d\n",
pl->
gen_sp);
311 fprintf(fp,
"bowtype %d\n",
pl->
bowtype);
312 fprintf(fp,
"petmode %d\n",
pl->
petmode);
316 fprintf(fp,
"pickup %u\n",
pl->
mode);
324 fprintf(fp,
"outputs_sync %d\n", 16);
325 fprintf(fp,
"outputs_count %d\n", 1);
332 #ifdef BACKUP_SAVE_AT_HOME
333 if (
op->map != NULL && flag == 0)
337 fprintf(fp,
"map %s\n",
op->map->path);
351 fprintf(fp,
"lev_array %d\n",
MIN(
op->level, 10));
352 for (i = 1; i <=
MIN(
op->level, 10) && i <= 10; i++) {
353 fprintf(fp,
"%d\n",
pl->
levhp[i]);
354 fprintf(fp,
"%d\n",
pl->
levsp[i]);
364 fprintf(fp,
"endplst\n");
368 #ifdef BACKUP_SAVE_AT_HOME
392 "Can't save character!");
405 op->contr->last_skill_ob[i] = NULL;
408 while (
op->inv != NULL)
421 "Can't open file for save.");
426 fprintf(fp,
"checksum %lx\n",
checksum);
432 "Can't close file for save.");
437 if (flag && container != NULL)
438 op->container = container;
448 if (!
op->contr->has_directory) {
449 op->contr->has_directory = 1;
489 "\nA character with this name already exists. "
490 "Please choose another name, or make sure you entered your "
491 "password correctly.\n");
496 op->contr->socket.password_fails++;
499 "You gave an incorrect password too many times, "
500 "you will now be dropped from the server.");
502 LOG(
llevInfo,
"A player connecting from %s has been dropped for password failure\n",
503 op->contr->socket.host);
530 time_t elapsed_save_time = 0;
532 char *party_name = NULL, party_password[9];
535 party_password[0] = 0;
539 if (pltmp !=
pl && pltmp->
ob->
name != NULL && !strcmp(pltmp->ob->name,
op->name)) {
549 pltmp->socket.status =
Ns_Dead;
574 if (fstat(fileno(fp), &statbuf)) {
576 elapsed_save_time = 0;
578 elapsed_save_time = time(NULL)-statbuf.st_mtime;
579 if (elapsed_save_time < 0) {
580 LOG(
llevError,
"Player file %s was saved in the future? (%ld time)\n",
filename, (
long)elapsed_save_time);
581 elapsed_save_time = 0;
585 if (fgets(bufall,
MAX_BUF, fp) != NULL) {
586 if (!strncmp(bufall,
"checksum ", 9)) {
587 if ( fgets(bufall,
MAX_BUF, fp) == NULL ) {
591 if (sscanf(bufall,
"password %s\n",
buf)) {
609 if (!correct && password) {
616 pl->last_save_time = time(NULL);
635 while (fgets(bufall,
MAX_BUF, fp) != NULL) {
636 char *val_string, *p;
638 sscanf(bufall,
"%s %d\n",
buf, &
value);
640 val_string = bufall + strlen(
buf) +1;
641 p = strchr(val_string,
'\n');
650 uvalue = strtoul(val_string, (
char **)NULL, 10);
652 if (!strcmp(
buf,
"endplst"))
656 else if (!strcmp(
buf,
"unarmed_skill"))
658 else if (!strcmp(
buf,
"explore"))
660 else if (!strcmp(
buf,
"gen_hp"))
662 else if (!strcmp(
buf,
"shoottype"))
664 else if (!strcmp(
buf,
"bowtype"))
666 else if (!strcmp(
buf,
"petmode"))
668 else if (!strcmp(
buf,
"gen_sp"))
670 else if (!strcmp(
buf,
"gen_grace"))
672 else if (!strcmp(
buf,
"listening"))
674 else if (!strcmp(
buf,
"peaceful"))
676 else if (!strcmp(
buf,
"no_shout"))
678 else if (!strcmp(
buf,
"digestion"))
680 else if (!strcmp(
buf,
"pickup")) {
682 }
else if (!strcmp(
buf,
"partial_commands")) {
685 else if (!strcmp(
buf,
"map"))
687 else if (!strcmp(
buf,
"savebed_map"))
689 else if (!strcmp(
buf,
"bed_x"))
691 else if (!strcmp(
buf,
"bed_y"))
693 else if (!strcmp(
buf,
"Str"))
695 else if (!strcmp(
buf,
"Dex"))
697 else if (!strcmp(
buf,
"Con"))
699 else if (!strcmp(
buf,
"Int"))
701 else if (!strcmp(
buf,
"Pow"))
703 else if (!strcmp(
buf,
"Wis"))
705 else if (!strcmp(
buf,
"Cha"))
707 else if (!strcmp(
buf,
"usekeys")) {
708 if (!strcmp(val_string,
"key_inventory"))
710 else if (!strcmp(val_string,
"keyrings"))
712 else if (!strcmp(val_string,
"containers"))
715 LOG(
llevDebug,
"load_player: got unknown usekeys type: %s\n", val_string);
716 }
else if (!strcmp(
buf,
"unapply")) {
717 if (!strcmp(val_string,
"unapply_nochoice"))
719 else if (!strcmp(val_string,
"unapply_never"))
721 else if (!strcmp(val_string,
"unapply_always"))
724 LOG(
llevDebug,
"load_player: got unknown unapply type: %s\n", val_string);
725 }
else if (!strcmp(
buf,
"lev_array")) {
726 for (i = 1; i <=
value; i++) {
730 count = fscanf(fp,
"%d\n", &j);
737 count = fscanf(fp,
"%d\n", &j);
744 count = fscanf(fp,
"%d\n", &j);
752 }
else if (!strcmp(
buf,
"party_rejoin_mode"))
754 else if (!strcmp(
buf,
"party_rejoin_name"))
756 else if (!strcmp(
buf,
"party_rejoin_password")) {
757 strncpy(party_password, val_string,
sizeof(party_password));
758 party_password[
sizeof(party_password) - 1] = 0;
759 }
else if (!strcmp(
buf,
"language")) {
762 else if (!strcmp(
buf,
"ticks_played")) {
786 LOG(
llevInfo,
"login: %s from %s\n",
op->name,
op->contr->socket.host);
845 "%s has entered the game.",
850 op->contr->socket.update_look = 1;
857 if (
op->stats.hp < 0) {
859 "Your character was dead last time you played.");
924 snprintf(
buf,
MAX_BUF,
"Couldn't rejoin party %s: %s.", party_name, party ?
"invalid password." :
"no such party.");
sstring add_string(const char *str)
void object_remove(object *op)
void pets_terminate_all(object *owner)
signed long object_sum_weight(object *op)
#define MSG_TYPE_COMMAND_SUCCESS
void set_dragon_name(object *pl, const object *abil, const object *skin)
void object_reset(object *op)
#define MSG_TYPE_ADMIN_PLAYER
int check_path(const char *name, int prepend_dir)
object * object_find_by_type_and_arch_name(const object *who, int type, const char *name)
int load_object(FILE *fp, object *op, int bufstate, int map_flags)
#define SAVE_FLAG_NO_REMOVE
#define QUERY_FLAG(xyz, p)
void login_check_shutdown(object *const op)
void destroy_object(object *op)
void esrv_new_player(player *pl, uint32_t weight)
void esrv_send_inventory(object *pl, object *op)
partylist * party_find(const char *partyname)
int player_has_own_title(const struct pl *pl)
void esrv_send_pickup(player *pl)
static void wrong_password(object *op)
#define PROFILE_BEGIN(expr)
uint32_t partial_commands
int account_link(const char *account_name, const char *player_name)
void player_set_own_title(struct pl *pl, const char *title)
EXTERN char first_map_path[MAX_BUF]
void esrv_add_spells(player *pl, object *spell)
static void copy_file(const char *filename, FILE *fpout)
void hiscore_check(object *op, int quiet)
void make_path_to_file(const char *filename)
void party_join(object *op, partylist *party)
static unsigned checksum(const mtar_raw_header_t *rh)
#define PROFILE_END(var, expr)
Account_Chars * account_chars
char savebed_map[MAX_BUF]
void link_player_skills(object *op)
void final_free_player(player *pl)
int party_confirm_password(const partylist *party, const char *password)
int playername_ok(const char *cp)
const char * unarmed_skill
int of_close(OutputFile *of)
const char * account_get_account_for_char(const char *charname)
void remove_unpaid_objects(object *op, object *env, int free_items)
int save_player(object *op, int flag)
int legal_range(object *op, int r)
void enter_player_maplevel(object *op)
sstring i18n_get_language_code(int language)
FILE * tempnam_secure(const char *dir, const char *pfx, char **filename)
int check_name(player *me, const char *name)
#define FREE_AND_COPY(sv, nv)
EXTERN player * first_player
void fix_object(object *op)
void party_set_password(partylist *party, const char *password)
void leave(player *pl, int draw_exit)
const char * player_get_own_title(const struct pl *pl)
int is_dragon_pl(const object *op)
partylist * party_form(object *op, const char *partyname)
size_t strlcpy(char *dst, const char *src, size_t size)
int i18n_get_language_by_code(const char *code)
#define MSG_TYPE_ADMIN_LOADSAVE
void remove_directory(const char *path)
void quest_first_player_save(player *pl)
const char * party_get_password(const partylist *party)
void LOG(LogLevel logLevel, const char *format,...)
FILE * of_open(OutputFile *of, const char *fname)
#define MAX_PASSWORD_FAILURES
party_rejoin_mode rejoin_party
#define FLAG_NO_FIX_PLAYER
int verify_player(const char *name, char *password)
#define CLEAR_FLAG(xyz, p)
void object_update_speed(object *op)
void delete_character(const char *name)
void account_char_add(Account_Chars *chars, player *pl)
#define MSG_TYPE_ADMIN_LOGIN
#define ST_GET_PARTY_PASSWORD
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
void object_free_drop_inventory(object *ob)
EXTERN long trying_emergency_save
void player_set_state(player *pl, uint8_t state)
void emergency_save(int flag)
void check_login(object *op, const char *password)
bool check_password(const char *typed, const char *crypted)
void knowledge_send_known(player *pl)
void confirm_password(object *op)
void account_char_save(Account_Chars *chars)
#define SAVE_FLAG_SAVE_UNPAID
void kill_player(object *op, const object *killer)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
void events_execute_global_event(int eventcode,...)
int save_object(FILE *fp, object *op, int flag)
void quest_send_initial_states(player *pl)
mapstruct * has_been_loaded(const char *name)
void get_name(object *op)
void knowledge_first_player_save(player *pl)