Difference for server/c_object.c from version 1.24 to 1.25


version 1.24 version 1.25
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_c_object_c =   * static char *rcsid_c_object_c =
  *   "$Id: c_object.c,v 1.24 2001/05/14 11:42:07 darth_bob Exp $";   *   "$Id: c_object.c,v 1.25 2001/06/13 10:51:31 michtoen Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 51
 
Line 51
    last->ob=(NEW);\     last->ob=(NEW);\
           last->id=(COUNT);            last->id=(COUNT);
   
 /* This is a subset of the parse_id command.  Basically, name can be  
  * a string seperated lists of things to match, with certain keywords.  
  * pl is the player (only needed to set count properly)  
  * op is the item we are trying to match.  Calling function takes care  
  * of what action might need to be done and if it is valid  
  * (pickup, drop, etc.)  Return NONZERO if we have a match.  A higher  
  * value means a better match.  0 means no match.  
  *  
  * Brief outline of the procedure:  
  * We take apart the name variable into the individual components.  
  * cases for 'all' and unpaid are pretty obvious.  
  * Next, we check for a count (either specified in name, or in the  
  * player object.)  
  * If count is 1, make a quick check on the name.  
  * IF count is >1, we need to make plural name.  Return if match.  
  * Last, make a check on the full name.  
  */  
 int item_matched_string(object *pl, object *op, char *name)  
 {  
   
     char *cp, local_name[MAX_BUF];  
     int count,retval=0;  
   
     strcpy(local_name, name); /* strtok is destructive to name */  
     for (cp=strtok(local_name,","); cp; cp=strtok(NULL,",")) {  
  while (cp[0]==' ') ++cp; /* get rid of spaces */  
 /* LOG(llevDebug,"Trying to match %s\n", cp);*/  
  /* All is a very generic match - low match value */  
  if (!strcmp(cp,"all")) return 1;  
  /* unpaid is a little more specific */  
  if (!strcmp(cp,"unpaid") && QUERY_FLAG(op,FLAG_UNPAID)) return 2;  
  if (!strcmp(cp,"cursed") && QUERY_FLAG(op,FLAG_KNOWN_CURSED) &&  
      (QUERY_FLAG(op,FLAG_CURSED) ||QUERY_FLAG(op,FLAG_DAMNED)))  
  return 2;  
  /* Allow for things like '100 arrows' */  
  if ((count=atoi(cp))!=0) {  
      cp=strchr(cp, ' ');  
      while (cp && cp[0]==' ') ++cp; /* get rid of spaces */  
  }  
  else count=pl->contr->count;  
  if (!cp || cp[0]=='\0' || count<0) return 0;  
  /* base name matched - not bad */  
  if (strcasecmp(cp,op->name)==0 && !count) retval=24;  
  else if (count>1) { /* Need to plurify name for proper match */  
      char newname[MAX_BUF];  
      strcpy(newname, op->name);  
      if (QUERY_FLAG(op,FLAG_NEED_IE)) {  
  char *cp1=strrchr(newname,'y');  
                 if(cp1!=NULL)  
                     *cp1='\0'; /* Strip the 'y' */  
                 strcat(newname,"ies");  
      }  
      else strcat(newname,"s");  
      if (!strcasecmp(newname,cp)) {  
  pl->contr->count=count; /* May not do anything */  
  retval=26;  
      }  
  }  
  else if (count==1) {  
      if (!strcasecmp(op->name,cp)) {  
  pl->contr->count=count; /* May not do anything */  
  retval=26;  
      }  
  }  
  if (!strcasecmp(cp,query_name(op))) retval=20;  
  else if (!strcasecmp(cp,query_short_name(op))) retval=18;  
  else if (!strcasecmp(cp,query_base_name(op,0))) retval=16;  
  else if (!strcasecmp(cp,query_base_name(op,1))) retval=16;  
  else if (!strncasecmp(cp,query_base_name(op,0),  
  MIN(strlen(cp),strlen(query_base_name(op,0))))) retval=14;  
  else if (!strncasecmp(cp,query_base_name(op,1),  
  MIN(strlen(cp),strlen(query_base_name(op,1))))) retval=14;  
  if (retval) {  
      pl->contr->count=count;  
      return retval;  
  }  
     }  
     return 0;  
 }  
   
 /* Search the inventory of 'pl' for what matches best with params.  /* Search the inventory of 'pl' for what matches best with params.
  * we use item_matched_string above - this gives us consistent behaviour   * we use item_matched_string above - this gives us consistent behaviour
  * between many commands.  Return the best match, or NULL if no match.   * between many commands.  Return the best match, or NULL if no match.
Line 629
 
Line 549
  /* Tell a client what happened rest of objects.  tmp2 is now the   /* Tell a client what happened rest of objects.  tmp2 is now the
  * original object   * original object
  */    */
    if (op->type == PLAYER)
    {
  if (was_destroyed (tmp2, tmp2_tag))   if (was_destroyed (tmp2, tmp2_tag))
        esrv_del_item (op->contr, tmp2_tag);         esrv_del_item (op->contr, tmp2_tag);
  else   else
        esrv_send_item (op, tmp2);         esrv_send_item (op, tmp2);
    };
     } else      } else
       remove_ob (tmp);        remove_ob (tmp);
   
           /* GROS: Added script_drop support */
           if (tmp->script_drop!=NULL) {
                   printf("Script_drop is %s\n", tmp->script_drop);
                   guile_call_event(op, tmp ,NULL, 0, NULL, 0,0, tmp->script_drop, SCRIPT_FIX_ALL);
           };
           if (tmp->script_str_drop!=NULL) {
                   guile_call_event_str(op, tmp ,NULL, 0, NULL, 0,0, tmp->script_str_drop, SCRIPT_FIX_ALL);
           };
   
   
     if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) {      if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) {
       sprintf(buf,"You drop the %s.", query_name(tmp));        sprintf(buf,"You drop the %s.", query_name(tmp));
       new_draw_info(NDI_UNIQUE, 0,op,buf);        new_draw_info(NDI_UNIQUE, 0,op,buf);
       new_draw_info(NDI_UNIQUE, 0,op,"The gods who lent it to you retrieves it.");        new_draw_info(NDI_UNIQUE, 0,op,"The gods who lent it to you retrieves it.");
         if (op->type==PLAYER)
  esrv_del_item (op->contr, tmp->count);   esrv_del_item (op->contr, tmp->count);
       free_object(tmp);        free_object(tmp);
       fix_player(op);        fix_player(op);
Line 650
 
Line 584
  *  the player here.    *  the player here.
  */   */
 #ifdef SAVE_INTERVAL  #ifdef SAVE_INTERVAL
       if (op->type == PLAYER)
       {
     if (!QUERY_FLAG(tmp, FLAG_UNPAID) &&       if (!QUERY_FLAG(tmp, FLAG_UNPAID) &&
       (tmp->nrof ? tmp->value * tmp->nrof : tmp->value > 2000))        (tmp->nrof ? tmp->value * tmp->nrof : tmp->value > 2000))
 #if SAVE_INTERVAL  #if SAVE_INTERVAL
Line 659
 
Line 595
 }  }
 #else  #else
  save_player(op,1); /* To avoid cheating */   save_player(op,1); /* To avoid cheating */
           };
   };
 #endif  #endif
 #endif /* SAVE_INTERVAL */  #endif /* SAVE_INTERVAL */
   
Line 671
 
Line 609
     tmp->x = op->x;      tmp->x = op->x;
     tmp->y = op->y;      tmp->y = op->y;
   
       if (op->type == PLAYER)
     esrv_del_item (op->contr, tmp->count);      esrv_del_item (op->contr, tmp->count);
     insert_ob_in_map(tmp, op->map, op);      insert_ob_in_map(tmp, op->map, op);
   
Line 686
 
Line 625
     fix_player(op); /* This is overkill, fix_player() is called somewhere */       fix_player(op); /* This is overkill, fix_player() is called somewhere */
      /* in object.c */       /* in object.c */
   
       if (op->type == PLAYER)
       {
     op->contr->socket.update_look = 1;      op->contr->socket.update_look = 1;
 /*    esrv_send_item (op, tmp);*/  /*    esrv_send_item (op, tmp);*/
     /* Need to update the weight for the player */      /* Need to update the weight for the player */
     esrv_send_item (op, op);      esrv_send_item (op, op);
       };
   
 #ifdef USE_LIGHTING  #ifdef USE_LIGHTING
     if(tmp->glow_radius>0) remove_light_from_list(tmp,op);      if(tmp->glow_radius>0) remove_light_from_list(tmp,op);
Line 736
 
Line 676
       return;        return;
     }      }
   
       if (op->type == PLAYER)
       {
     if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) {      if (op->contr->last_used==tmp && op->contr->last_used_id == tmp->count) {
       object *n=NULL;        object *n=NULL;
       if(tmp->below != NULL)        if(tmp->below != NULL)
Line 748
 
Line 690
       else        else
    op->contr->last_used_id = 0;     op->contr->last_used_id = 0;
     }      }
       };
   
     if (op->container) {      if (op->container) {
           if (op->type == PLAYER)
           {
       put_object_in_sack (op, op->container, tmp, op->contr->count);        put_object_in_sack (op, op->container, tmp, op->contr->count);
     } else {      } else {
                   put_object_in_sack(op, op->container, tmp, 0);
           };
       } else {
           if (op->type == PLAYER)
           {
       drop_object (op, tmp, op->contr->count);        drop_object (op, tmp, op->contr->count);
           } else {
                   drop_object(op,tmp,0);
           };
     }      }
       if (op->type == PLAYER)
     op->contr->count = 0;      op->contr->count = 0;
 }  }
   
Line 889
 
Line 843
  }   }
  if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop.");   if (!did_one) new_draw_info(NDI_UNIQUE, 0,op,"Nothing to drop.");
     }      }
       if (op->type==PLAYER)
       {
     op->contr->count=0;      op->contr->count=0;
     op->contr->socket.update_look=1;      op->contr->socket.update_look=1;
       };
 /*    draw_look(op);*/  /*    draw_look(op);*/
     return 0;      return 0;
 }  }


Legend:
line(s) removed in v.1.24 
line(s) changed
 line(s) added in v.1.25

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