ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/login.C
(Generate patch)

Comparing deliantra/server/server/login.C (file contents):
Revision 1.6 by root, Tue Aug 29 08:01:37 2006 UTC vs.
Revision 1.7 by root, Wed Aug 30 06:06:27 2006 UTC

1/* 1/*
2 * static char *rcsid_login_c = 2 * static char *rcsid_login_c =
3 * "$Id: login.C,v 1.6 2006/08/29 08:01:37 root Exp $"; 3 * "$Id: login.C,v 1.7 2006/08/30 06:06:27 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
374 374
375 return 1; 375 return 1;
376} 376}
377 377
378void check_login(object *op) { 378void check_login(object *op) {
379 FILE *fp;
380 char filename[MAX_BUF]; 379 char filename[MAX_BUF];
381 char buf[MAX_BUF],bufall[MAX_BUF]; 380 char buf[MAX_BUF],bufall[MAX_BUF];
382 int i,value,comp; 381 int i,value,comp;
383 long checksum = 0; 382 long checksum = 0;
384 player *pl = op->contr; 383 player *pl = op->contr;
385 int correct = 0; 384 int correct = 0;
386 time_t elapsed_save_time=0;
387 struct stat statbuf;
388 385
389 strcpy (pl->maplevel,first_map_path); 386 strcpy (pl->maplevel,first_map_path);
390
391 sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,op->name,op->name); 387 sprintf(filename,"%s/%s/%s/%s.pl",settings.localdir,settings.playerdir,op->name,op->name);
392 388
389 object_thawer thawer (filename);
393 /* If no file, must be a new player, so lets get confirmation of 390 /* If no file, must be a new player, so lets get confirmation of
394 * the password. Return control to the higher level dispatch, 391 * the password. Return control to the higher level dispatch,
395 * since the rest of this just deals with loading of the file. 392 * since the rest of this just deals with loading of the file.
396 */ 393 */
397 if ((fp=open_and_uncompress(filename,1,&comp)) == NULL) { 394 if (!thawer) {
398 confirm_password(op); 395 confirm_password(op);
399 return; 396 return;
400 } 397 }
401 if (fstat(fileno(fp), &statbuf)) {
402 LOG(llevError,"Unable to stat %s?\n", filename);
403 elapsed_save_time=0;
404 } else {
405 elapsed_save_time = time(NULL) - statbuf.st_mtime;
406 if (elapsed_save_time<0) {
407 LOG(llevError,"Player file %s was saved in the future? (%d time)\n", filename, elapsed_save_time);
408 elapsed_save_time=0;
409 }
410 }
411 398
412 object_thawer thawer (fp, filename);
413
414 if(fgets(bufall,MAX_BUF,fp) != NULL) { 399 if(fgets(bufall,MAX_BUF,thawer) != NULL) {
415 if(!strncmp(bufall,"checksum ",9)) { 400 if(!strncmp(bufall,"checksum ",9)) {
416 checksum = strtol(bufall+9,(char **) NULL, 16); 401 checksum = strtol(bufall+9,(char **) NULL, 16);
417 (void) fgets(bufall,MAX_BUF,fp); 402 (void) fgets(bufall,MAX_BUF,thawer);
418 } 403 }
419 if(sscanf(bufall,"password %s\n",buf)) { 404 if(sscanf(bufall,"password %s\n",buf)) {
420 /* New password scheme: */ 405 /* New password scheme: */
421 correct=check_password(pl->write_buf+1,buf); 406 correct=check_password(pl->write_buf+1,buf);
422 } 407 }
460 strcpy(pl->savebed_map, first_map_path); 445 strcpy(pl->savebed_map, first_map_path);
461 pl->bed_x=0, pl->bed_y=0; 446 pl->bed_x=0, pl->bed_y=0;
462 pl->spellparam[0] = '\0'; 447 pl->spellparam[0] = '\0';
463 448
464 /* Loop through the file, loading the rest of the values */ 449 /* Loop through the file, loading the rest of the values */
465 while (fgets(bufall,MAX_BUF,fp)!=NULL) { 450 while (fgets(bufall,MAX_BUF,thawer)!=NULL) {
466 sscanf(bufall,"%s %d\n",buf,&value); 451 sscanf(bufall,"%s %d\n",buf,&value);
467 if (!strcmp(buf,"endplst")) 452 if (!strcmp(buf,"endplst"))
468 break; 453 break;
469 else if (!strcmp(buf,"oid")) 454 else if (!strcmp(buf,"oid"))
470 thawer.get (pl, value); 455 thawer.get (pl, value);
541 else LOG(llevDebug,"load_player: got unknown unapply type: %s\n", bufall+8); 526 else LOG(llevDebug,"load_player: got unknown unapply type: %s\n", bufall+8);
542 } 527 }
543 else if (!strcmp(buf,"lev_array")){ 528 else if (!strcmp(buf,"lev_array")){
544 for(i=1;i<=value;i++) { 529 for(i=1;i<=value;i++) {
545 int j; 530 int j;
546 fscanf(fp,"%d\n",&j); 531 fscanf(thawer,"%d\n",&j);
547 pl->levhp[i]=j; 532 pl->levhp[i]=j;
548 fscanf(fp,"%d\n",&j); 533 fscanf(thawer,"%d\n",&j);
549 pl->levsp[i]=j; 534 pl->levsp[i]=j;
550 fscanf(fp,"%d\n",&j); 535 fscanf(thawer,"%d\n",&j);
551 pl->levgrace[i]=j; 536 pl->levgrace[i]=j;
552 } 537 }
553 /* spell_array code removed - don't know when that was last used. 538 /* spell_array code removed - don't know when that was last used.
554 * Even the load code below will someday be replaced by spells being 539 * Even the load code below will someday be replaced by spells being
555 * objects. 540 * objects.
580 op->contr = pl; 565 op->contr = pl;
581 pl->ob = op; 566 pl->ob = op;
582 567
583 /* this loads the standard objects values. */ 568 /* this loads the standard objects values. */
584 load_object(thawer, op, LO_NEWFILE,0); 569 load_object(thawer, op, LO_NEWFILE,0);
585 close_and_delete(fp, comp);
586 570
587 CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER); 571 CLEAR_FLAG(op, FLAG_NO_FIX_PLAYER);
588 572
589 strncpy(pl->title, op->arch->clone.name, sizeof(pl->title)-1); 573 strncpy(pl->title, op->arch->clone.name, sizeof(pl->title)-1);
590 pl->title[sizeof(pl->title)-1] = '\0'; 574 pl->title[sizeof(pl->title)-1] = '\0';
598 if (check_path(pl->maplevel,1)==-1) { 582 if (check_path(pl->maplevel,1)==-1) {
599 if (check_path(pl->maplevel,0)==-1) { 583 if (check_path(pl->maplevel,0)==-1) {
600 strcpy(pl->maplevel, pl->savebed_map); 584 strcpy(pl->maplevel, pl->savebed_map);
601 op->x = pl->bed_x, op->y = pl->bed_y; 585 op->x = pl->bed_x, op->y = pl->bed_y;
602 } 586 }
603 }
604
605 /* If player saved beyond some time ago, and the feature is
606 * enabled, put the player back on his savebed map.
607 */
608 if ((settings.reset_loc_time >0) && (elapsed_save_time > settings.reset_loc_time)) {
609 strcpy(pl->maplevel, pl->savebed_map);
610 op->x = pl->bed_x, op->y = pl->bed_y;
611 } 587 }
612 588
613 /* make sure he's a player--needed because of class change. */ 589 /* make sure he's a player--needed because of class change. */
614 op->type = PLAYER; 590 op->type = PLAYER;
615 591

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines