Difference for server/player.c from version 1.40 to 1.41


version 1.40 version 1.41
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_player_c =   * static char *rcsid_player_c =
  *   "$Id: player.c,v 1.40 2001/02/23 07:20:39 mwedel Exp $";   *   "$Id: player.c,v 1.41 2001/02/27 03:41:25 mwedel Exp $";
  */   */
   
 /*  /*
Line 69
 
Line 69
   return 1;    return 1;
 }  }
   
 /* Tries to add player on the connection passwd in ns.  /* This no longer sets the player map.  Also, it now updates
  * All we can really get in this is some settings like host and display   * all the pointers so the caller doesn't need to do that.
  * mode.   * Caller is responsible for setting the correct map.
  */  
   
 int add_player(NewSocket *ns) {  
     player *p;  
     char *defname = "nobody";  
     mapstruct *m=NULL;  
   
   
     /* Check for banned players and sites.  usename is no longer accurate,  
      * (can't get it over sockets), so all we really have to go on is  
      * the host.  
      */       */
   static void get_player(player *p) {
     if (checkbanned (defname, ns->host)){  
  fprintf (logfile, "Banned player tryed to add. [%s@%s]\n", defname, ns->host);  
  fflush (logfile);  
  return 0;  
     }  
   
     init_beforeplay(); /* Make sure everything is ready */  
   
     if(m == NULL || m->in_memory != MAP_IN_MEMORY)  
  m = ready_map_name(first_map_path,0);  
     if(m == NULL)  
  fatal(MAP_ERROR);  
     m->timeout = MAP_TIMEOUT(m); /* Just in case we fail to add the player */  
     p=get_player_ob();  
     memcpy(&p->socket, ns, sizeof(NewSocket));  
     p->socket.inbuf.len=0;  
   
     p->weapon_sp=0,p->last_weapon_sp= -1;  
     p->has_hit=0;  
   
     p->peaceful=1; /* default peaceful */  
     p->do_los=1;  
     p->last_weight= -1;  
 #ifdef EXPLORE_MODE  
     p->explore=0;  
 #endif    
   
     free_string(p->ob->name);  
     p->ob->name = NULL;  
     free_object(p->ob);  
     p->ob=get_player(p,m);  
     CLEAR_FLAG(p->ob, FLAG_FRIENDLY);  
     add_friendly_object(p->ob);  
 #ifdef MOTD  
     display_motd(p->ob);  
 #endif  
     p->peaceful=1;  
     p->own_title[0]='\0';  
     get_name(p->ob);  
     return 0;  
 }  
   
 /*  
  * get_player_archetype() return 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!  
  */  
 archetype *get_player_archetype(archetype* at)  
 {  
     archetype *start = at;  
     for (;;) {  
  if (at==NULL || at->next==NULL)  
      at=first_archetype;  
  else  
      at=at->next;  
  if(at->clone.type==PLAYER)  
      return at;  
  if (at == start) {  
      LOG (llevError, "No Player achetypes\n");  
      exit (-1);  
  }  
     }  
 }  
   
   
 object *get_player(player *p, mapstruct *m) {  
     object *op=arch_to_object(get_player_archetype(NULL));      object *op=arch_to_object(get_player_archetype(NULL));
     int i;      int i;
   
     p->loading = NULL;      p->loading = NULL;
     op->map=m;  
     p->fire_on=0,p->run_on=0;      p->fire_on=0,p->run_on=0;
     p->count=0;      p->count=0;
     p->count_left=0;      p->count_left=0;
Line 172
 
Line 94
     p->bed_x=0, p->bed_y=0;      p->bed_x=0, p->bed_y=0;
          
     op->contr=p; /* this aren't yet in archetype */      op->contr=p; /* this aren't yet in archetype */
       p->ob = op;
     op->speed_left=0.5;      op->speed_left=0.5;
     op->speed=1.0;      op->speed=1.0;
     op->direction=5;     /* So player faces south */      op->direction=5;     /* So player faces south */
Line 201
 
Line 124
     p->golem=NULL;      p->golem=NULL;
     p->last_used=NULL;      p->last_used=NULL;
     p->last_used_id=0;      p->last_used_id=0;
   
       p->weapon_sp=0;
       p->last_weapon_sp= -1;
       p->has_hit=0;
   
       p->peaceful=1; /* default peaceful */
       p->do_los=1;
       p->last_weight= -1;
   #ifdef EXPLORE_MODE
       p->explore=0;
   #endif 
   
     strncpy(p->title,op->arch->clone.name,MAX_NAME);      strncpy(p->title,op->arch->clone.name,MAX_NAME);
     op->race = add_string (op->arch->clone.race);      op->race = add_string (op->arch->clone.race);
   
Line 217
 
Line 152
     if(QUERY_FLAG(op,FLAG_READY_SKILL))      if(QUERY_FLAG(op,FLAG_READY_SKILL))
         CLEAR_FLAG(op,FLAG_READY_SKILL);           CLEAR_FLAG(op,FLAG_READY_SKILL);
     p->socket.update_look=0;      p->socket.update_look=0;
       p->own_title[0]='\0';
   }
   
     /* Do this last so that all the pointers are updated */  
     if(m->in_memory != MAP_IN_MEMORY) {  /* This loads the first map an puts the player on it. */
  LOG(llevError,"get_player: Map not in memory?\n");  static void set_first_map(object *op)
  p->loading = m;  {
  p->new_x = 0;      strcpy(op->contr->maplevel, first_map_path);
  p->new_y = 0;      op->x = -1;
  p->removed = 0;      op->y = -1;
  op->x=0;      enter_exit(op, NULL);
  op->y=0;  
     } else {  
  i=find_free_spot(NULL,m,EXIT_X(m->map_object),EXIT_Y(m->map_object),  
  0,SIZEOFFREE);  
  /* If no free spot, just stuff the player wherever it says */  
  if (i==-1) i=0;  
  op->x=EXIT_X(m->map_object)+freearr_x[i];  
  op->y=EXIT_Y(m->map_object)+freearr_y[i];  
  insert_ob_in_map(op, m, op);  
     }      }
     return op;  
   /* Tries to add player on the connection passwd in ns.
    * All we can really get in this is some settings like host and display
    * mode.
    */
   
   int add_player(NewSocket *ns) {
       player *p;
       char *defname = "nobody";
   
   
       /* Check for banned players and sites.  usename is no longer accurate,
        * (can't get it over sockets), so all we really have to go on is
        * the host.
        */
   
       if (checkbanned (defname, ns->host)){
    fprintf (logfile, "Banned player tryed to add. [%s@%s]\n", defname, ns->host);
    fflush (logfile);
    return 0;
 }  }
   
       init_beforeplay(); /* Make sure everything is ready */
   
       p=get_player_ob();
       get_player(p);
       memcpy(&p->socket, ns, sizeof(NewSocket));
       /* Needed because the socket we just copied over needs to be cleared.
        * Note that this can result in a client reset if there is partial data
        * on the uncoming socket.
        */
       p->socket.inbuf.len = 0;
       set_first_map(p->ob);
   
       CLEAR_FLAG(p->ob, FLAG_FRIENDLY);
       add_friendly_object(p->ob);
   #ifdef MOTD
       display_motd(p->ob);
   #endif
       get_name(p->ob);
       return 0;
   }
   
   /*
    * get_player_archetype() return 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!
    */
   archetype *get_player_archetype(archetype* at)
   {
       archetype *start = at;
       for (;;) {
    if (at==NULL || at->next==NULL)
        at=first_archetype;
    else
        at=at->next;
    if(at->clone.type==PLAYER)
        return at;
    if (at == start) {
        LOG (llevError, "No Player achetypes\n");
        exit (-1);
    }
       }
   }
   
   
 object *get_nearest_player(object *mon) {  object *get_nearest_player(object *mon) {
   object *op = NULL;    object *op = NULL;
   player *pl = NULL;    player *pl = NULL;
Line 447
 
Line 438
  return 2;   return 2;
     }      }
     else if(key=='a'||key=='A') {      else if(key=='a'||key=='A') {
  object *tmp;   player *pl = op->contr;
    char *name = op->name;
   
  remove_friendly_object(op);   remove_friendly_object(op);
  op->contr->ob=get_player(op->contr,op->map);   free_object(op);
  tmp=op->contr->ob;   get_player(pl);
  add_friendly_object(tmp);   op = pl->ob;
  tmp->contr->password[0]='~';   add_friendly_object(op);
  if(tmp->name!=NULL)   op->contr->password[0]='~';
      free_string(tmp->name);   if(op->name!=NULL)
        free_string(op->name);
  /* Lets put a space in here */   /* Lets put a space in here */
  new_draw_info(NDI_UNIQUE, 0, op, "\n");   new_draw_info(NDI_UNIQUE, 0, op, "\n");
  get_name(tmp);   get_name(op);
  add_refcount(tmp->name = op->name);   op->name = name;
  op->type=DEAD_OBJECT;   add_refcount(op->name);
  free_object(op);   set_first_map(op);
  op=tmp;  
     } else {      } else {
  /* user pressed something else so just ask again... */   /* user pressed something else so just ask again... */
  play_again(op);   play_again(op);
Line 804
 
Line 797
       return 1;        return 1;
     }      }
     terminate_all_pets(op);      terminate_all_pets(op);
     remove_ob(op);      leave_map(op);
     op->direction=0;      op->direction=0;
     op->contr->count_left=0;      op->contr->count_left=0;
     op->map->players--;  
     /* Just in case we fail to add the player */  
     op->map->timeout = MAP_TIMEOUT(op->map);  
     new_draw_info_format(NDI_UNIQUE | NDI_ALL, 5, NULL,      new_draw_info_format(NDI_UNIQUE | NDI_ALL, 5, NULL,
  "%s quits the game.",op->name);   "%s quits the game.",op->name);
   


Legend:
line(s) removed in v.1.40 
line(s) changed
 line(s) added in v.1.41

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:42