1 | /* |
1 | /* |
2 | * static char *rcsid_login_c = |
2 | * static char *rcsid_login_c = |
3 | * "$Id: login.C,v 1.9 2006/08/31 06:23:20 root Exp $"; |
3 | * "$Id: login.C,v 1.11 2006/09/03 22:45:57 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
346 | #else |
346 | #else |
347 | save_object(freezer, op, 3); /* don't check and don't remove */ |
347 | save_object(freezer, op, 3); /* don't check and don't remove */ |
348 | #endif |
348 | #endif |
349 | |
349 | |
350 | char filename[MAX_BUF]; |
350 | char filename[MAX_BUF]; |
351 | sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,op->name,op->name); |
351 | sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,&op->name,&op->name); |
352 | make_path_to_file(filename); |
352 | make_path_to_file(filename); |
353 | freezer.save (filename); |
353 | freezer.save (filename); |
354 | |
354 | |
355 | CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER); |
355 | CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER); |
356 | |
356 | |
… | |
… | |
377 | long checksum = 0; |
377 | long checksum = 0; |
378 | player *pl = op->contr; |
378 | player *pl = op->contr; |
379 | int correct = 0; |
379 | int correct = 0; |
380 | |
380 | |
381 | strcpy (pl->maplevel,first_map_path); |
381 | strcpy (pl->maplevel,first_map_path); |
382 | sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,op->name,op->name); |
382 | sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,&op->name,&op->name); |
383 | |
383 | |
384 | object_thawer thawer (filename); |
384 | object_thawer thawer (filename); |
385 | /* If no file, must be a new player, so lets get confirmation of |
385 | /* If no file, must be a new player, so lets get confirmation of |
386 | * the password. Return control to the higher level dispatch, |
386 | * the password. Return control to the higher level dispatch, |
387 | * since the rest of this just deals with loading of the file. |
387 | * since the rest of this just deals with loading of the file. |
… | |
… | |
407 | } |
407 | } |
408 | if (!correct) { |
408 | if (!correct) { |
409 | new_draw_info(NDI_UNIQUE, 0,op," "); |
409 | new_draw_info(NDI_UNIQUE, 0,op," "); |
410 | new_draw_info(NDI_UNIQUE, 0,op,"Wrong Password!"); |
410 | new_draw_info(NDI_UNIQUE, 0,op,"Wrong Password!"); |
411 | new_draw_info(NDI_UNIQUE, 0,op," "); |
411 | new_draw_info(NDI_UNIQUE, 0,op," "); |
412 | FREE_AND_COPY(op->name, "noname"); |
412 | op->name = |
413 | FREE_AND_COPY(op->name_pl, "noname"); |
413 | op->name_pl = "noname"; |
414 | op->contr->socket.password_fails++; |
414 | op->contr->socket.password_fails++; |
415 | if (op->contr->socket.password_fails >= MAX_PASSWORD_FAILURES) { |
415 | if (op->contr->socket.password_fails >= MAX_PASSWORD_FAILURES) { |
416 | new_draw_info(NDI_UNIQUE, 0,op, |
416 | new_draw_info(NDI_UNIQUE, 0,op, |
417 | "You gave an incorrect password too many times, you will now be dropped from the server."); |
417 | "You gave an incorrect password too many times, you will now be dropped from the server."); |
418 | LOG(llevInfo, "A player connecting from %s has been dropped for password failure\n", |
418 | LOG(llevInfo, "A player connecting from %s has been dropped for password failure\n", |
… | |
… | |
519 | else if (!strcmp(bufall+8,"unapply_always\n")) |
519 | else if (!strcmp(bufall+8,"unapply_always\n")) |
520 | pl->unapply=unapply_always; |
520 | pl->unapply=unapply_always; |
521 | else LOG(llevDebug,"load_player: got unknown unapply type: %s\n", bufall+8); |
521 | else LOG(llevDebug,"load_player: got unknown unapply type: %s\n", bufall+8); |
522 | } |
522 | } |
523 | else if (!strcmp(buf,"lev_array")){ |
523 | else if (!strcmp(buf,"lev_array")){ |
524 | for(i=1;i<=value;i++) { |
524 | for(i=1;i<=value;i++) |
525 | int j; |
525 | { |
526 | fscanf(thawer,"%d\n",&j); |
526 | char line[128]; |
527 | pl->levhp[i]=j; |
527 | fgets (line, 128, thawer); pl->levhp[i] = atoi (line); |
528 | fscanf(thawer,"%d\n",&j); |
528 | fgets (line, 128, thawer); pl->levsp[i] = atoi (line); |
529 | pl->levsp[i]=j; |
529 | fgets (line, 128, thawer); pl->levgrace[i] = atoi (line); |
530 | fscanf(thawer,"%d\n",&j); |
|
|
531 | pl->levgrace[i]=j; |
|
|
532 | } |
530 | } |
533 | /* spell_array code removed - don't know when that was last used. |
531 | /* spell_array code removed - don't know when that was last used. |
534 | * Even the load code below will someday be replaced by spells being |
532 | * Even the load code below will someday be replaced by spells being |
535 | * objects. |
533 | * objects. |
536 | */ |
534 | */ |
537 | } else if (!strcmp(buf,"known_spell")) { |
535 | } else if (!strcmp(buf,"known_spell")) { |
… | |
… | |
559 | reset_object(op); |
557 | reset_object(op); |
560 | op->contr = pl; |
558 | op->contr = pl; |
561 | pl->ob = op; |
559 | pl->ob = op; |
562 | |
560 | |
563 | /* this loads the standard objects values. */ |
561 | /* this loads the standard objects values. */ |
564 | load_object(thawer, op, LO_NEWFILE,0); |
562 | load_object (thawer, op, 0); |
565 | |
563 | |
566 | CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER); |
564 | CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER); |
567 | |
565 | |
568 | strncpy(pl->title, op->arch->clone.name, sizeof(pl->title)-1); |
566 | strncpy(pl->title, op->arch->clone.name, sizeof(pl->title)-1); |
569 | pl->title[sizeof(pl->title)-1] = '\0'; |
567 | pl->title[sizeof(pl->title)-1] = '\0'; |
… | |
… | |
619 | set_dragon_name(op, abil, skin); |
617 | set_dragon_name(op, abil, skin); |
620 | } |
618 | } |
621 | |
619 | |
622 | new_draw_info(NDI_UNIQUE, 0,op,"Welcome Back!"); |
620 | new_draw_info(NDI_UNIQUE, 0,op,"Welcome Back!"); |
623 | new_draw_info_format(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, |
621 | new_draw_info_format(NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, |
624 | "%s has entered the game.",pl->ob->name); |
622 | "%s has entered the game.", &pl->ob->name); |
625 | |
623 | |
626 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (filename)); |
624 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (filename)); |
627 | INVOKE_PLAYER (LOGIN, pl); |
625 | INVOKE_PLAYER (LOGIN, pl); |
628 | |
626 | |
629 | op->contr->socket.update_look=1; |
627 | op->contr->socket.update_look=1; |
… | |
… | |
636 | if (op->stats.hp<0) { |
634 | if (op->stats.hp<0) { |
637 | new_draw_info(NDI_UNIQUE, 0,op,"Your character was dead last your played."); |
635 | new_draw_info(NDI_UNIQUE, 0,op,"Your character was dead last your played."); |
638 | kill_player(op); |
636 | kill_player(op); |
639 | if (pl->state != ST_PLAYING) return; |
637 | if (pl->state != ST_PLAYING) return; |
640 | } |
638 | } |
641 | LOG(llevInfo,"LOGIN: Player named %s from ip %s\n", op->name, |
639 | LOG(llevInfo,"LOGIN: Player named %s from ip %s\n", &op->name, op->contr->socket.host); |
642 | op->contr->socket.host); |
|
|
643 | |
640 | |
644 | /* Do this after checking for death - no reason sucking up bandwidth if |
641 | /* Do this after checking for death - no reason sucking up bandwidth if |
645 | * the data isn't needed. |
642 | * the data isn't needed. |
646 | */ |
643 | */ |
647 | esrv_new_player(op->contr,op->weight+op->carrying); |
644 | esrv_new_player(op->contr,op->weight+op->carrying); |