Difference for common/item.c from version 1.5 to 1.6


version 1.5 version 1.6
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_item_c =   * static char *rcsid_item_c =
  *   "$Id: item.c,v 1.5 2000/05/23 03:52:21 cvs Exp $";   *   "$Id: item.c,v 1.6 2000/05/23 07:06:32 cvs Exp $";
  */   */
   
 /*  /*
Line 54
 
Line 54
   "seventieth","eightieth","ninetieth"    "seventieth","eightieth","ninetieth"
 };  };
   
   
 /*  /*
  * query_weight(object) returns a character pointer to a static buffer   * query_weight(object) returns a character pointer to a static buffer
  * containing the text-representation of the weight of the given object.   * containing the text-representation of the weight of the given object.
Line 125
 
Line 126
  */   */
 char *ring_desc (object *op)   char *ring_desc (object *op)
 {  {
     static char buf[MAX_BUF];      static char buf[VERY_BIG_BUF];
     int attr, val;      int attr, val,len;
          
     buf[0] = 0;      buf[0] = 0;
   
Line 169
 
Line 170
     if(QUERY_FLAG(op,FLAG_STEALTH))      if(QUERY_FLAG(op,FLAG_STEALTH))
  strcat(buf,"(stealth)");   strcat(buf,"(stealth)");
     /* Shorten some of the names, so they appear better in the windows */      /* Shorten some of the names, so they appear better in the windows */
     DESCRIBE_ABILITY(buf, op->immune, "Immune");      len=strlen(buf);
     DESCRIBE_ABILITY(buf, op->protected, "Pro");      DESCRIBE_ABILITY_SAFE(buf, op->immune, "Immune", &len, VERY_BIG_BUF);
     DESCRIBE_ABILITY(buf, op->vulnerable, "Vuln");      DESCRIBE_ABILITY_SAFE(buf, op->protected, "Pro", &len, VERY_BIG_BUF);
     DESCRIBE_PATH(buf, op->path_attuned, "Attuned");      DESCRIBE_ABILITY_SAFE(buf, op->vulnerable, "Vuln", &len, VERY_BIG_BUF);
     DESCRIBE_PATH(buf, op->path_repelled, "Repelled");      DESCRIBE_PATH_SAFE(buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF);
     DESCRIBE_PATH(buf, op->path_denied, "Denied");      DESCRIBE_PATH_SAFE(buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF);
       DESCRIBE_PATH_SAFE(buf, op->path_denied, "Denied", &len, VERY_BIG_BUF);
     if(buf[0] == 0 && op->type!=SKILL)      if(buf[0] == 0 && op->type!=SKILL)
  strcpy(buf,"of adornment");   strcpy(buf,"of adornment");
     return buf;      return buf;
Line 188
 
Line 190
 {  {
     static char buf[HUGE_BUF];      static char buf[HUGE_BUF];
     char buf2[HUGE_BUF];      char buf2[HUGE_BUF];
       int len=0;
   
     if(op->name == NULL)      if(op->name == NULL)
  return "(null)";   return "(null)";
     if(!op->nrof && !op->weight && !op->title && !is_magical(op))       if(!op->nrof && !op->weight && !op->title && !is_magical(op))
  return op->name; /* To speed things up (or make things slower?) */   return op->name; /* To speed things up (or make things slower?) */
     if(op->nrof) {      if(op->nrof) {
  strcpy(buf, get_number(op->nrof));   safe_strcat(buf, get_number(op->nrof), &len, HUGE_BUF);
   
    if (op->nrof!=1) safe_strcat(buf, " ", &len, HUGE_BUF);
    safe_strcat(buf,op->name, &len, HUGE_BUF);
   
 #if 0  
  /* if nrof==1, then get_number returns 'a'. Add an 'n' if appropriate*/  
  if(op->nrof==1&&QUERY_FLAG(op,FLAG_AN))  
      strcat(buf,"n");  
 #endif  
  if (op->nrof!=1) strcat(buf, " ");  
  strcat(buf,op->name);  
  if (op->nrof != 1) {   if (op->nrof != 1) {
      char *buf3 = strstr(buf, " of ");       char *buf3 = strstr(buf, " of ");
      if (buf3!=NULL) {       if (buf3!=NULL) {
Line 214
 
Line 213
   
  if(cp!=NULL)   if(cp!=NULL)
      *cp='\0'; /* Strip the 'y' */       *cp='\0'; /* Strip the 'y' */
  strcat(buf,"ies");   safe_strcat(buf,"ies", &len, HUGE_BUF);
      } else if (buf[strlen(buf)-1]!='s')        } else if (buf[strlen(buf)-1]!='s')
  /* if the item ends in 's', then adding another one is    /* if the item ends in 's', then adding another one is
  * not the way to pluralize it.  The only item where this    * not the way to pluralize it.  The only item where this
  * matters (that I know of) is bracers, as they start of    * matters (that I know of) is bracers, as they start of
  * plural    * plural
  */   */
  strcat(buf,"s");   safe_strcat(buf,"s", &len, HUGE_BUF);
   
      /* If buf3 is set, then this was a string that contained       /* If buf3 is set, then this was a string that contained
       * something of something (potion of dexterity.)  The part before        * something of something (potion of dexterity.)  The part before
Line 229
 
Line 228
       * (after and including the " of "), to the buffer string.        * (after and including the " of "), to the buffer string.
       */        */
      if (buf3)       if (buf3)
  strcat(buf, buf2);   safe_strcat(buf, buf2, &len, HUGE_BUF);
  }   }
     } else {      } else {
  /* if nrof is 0, the object is not mergable, and thus, op->name   /* if nrof is 0, the object is not mergable, and thus, op->name
     should contain the name to be used. */      should contain the name to be used. */
  strcpy(buf,op->name);   safe_strcat(buf,op->name, &len, HUGE_BUF);
     }      }
     if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) {      if (op->title && QUERY_FLAG(op,FLAG_IDENTIFIED)) {
  strcat(buf, " ");   safe_strcat(buf, " ", &len, HUGE_BUF);
  strcat(buf, op->title);   safe_strcat(buf, op->title, &len, HUGE_BUF);
     }      }
   
     switch(op->type) {      switch(op->type) {
Line 248
 
Line 247
       case ROD:        case ROD:
  if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {   if (QUERY_FLAG(op,FLAG_IDENTIFIED)||QUERY_FLAG(op,FLAG_BEEN_APPLIED)) {
      if(!op->title) {       if(!op->title) {
  strcat(buf," of ");   safe_strcat(buf," of ", &len, HUGE_BUF);
  strcat(buf,spells[op->stats.sp].name);   safe_strcat(buf,spells[op->stats.sp].name, &len, HUGE_BUF);
  if(op->type != SPELLBOOK)   if(op->type != SPELLBOOK) {
      sprintf(buf+strlen(buf), " (lvl %d)", op->level);       sprintf(buf2, " (lvl %d)", op->level);
        safe_strcat(buf, buf2, &len, HUGE_BUF);
    }
      }       }
  }   }
  break;   break;
Line 264
 
Line 265
      /* If ring has a title, full description isn't so useful */        /* If ring has a title, full description isn't so useful */
      char *s = ring_desc(op);       char *s = ring_desc(op);
      if (s[0]) {       if (s[0]) {
  strcat (buf, " ");   safe_strcat (buf, " ", &len, HUGE_BUF);
  strncat (buf, s, HUGE_BUF-strlen(buf)-1);   safe_strcat(buf, s, &len, HUGE_BUF);
  buf[HUGE_BUF-1]=0;  
      }       }
  }   }
 #endif  #endif
Line 274
 
Line 274
       default:        default:
  if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) &&    if(op->magic && ((QUERY_FLAG(op,FLAG_BEEN_APPLIED) &&
     need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) {      need_identify(op)) || QUERY_FLAG(op,FLAG_IDENTIFIED))) {
      sprintf(buf + strlen(buf), " %+d", op->magic);       sprintf(buf2, " %+d", op->magic);
        safe_strcat(buf, buf2, &len, HUGE_BUF);
  }   }
     }      }
     return buf;      return buf;
Line 292
 
Line 293
  *   *
  */   */
 char *query_name(object *op) {  char *query_name(object *op) {
     static char buf[5][MAX_BUF];      static char buf[5][HUGE_BUF];
     static int use_buf=0;      static int use_buf=0;
       int len=0;
   
     use_buf++;      use_buf++;
     use_buf %=5;      use_buf %=5;
   
     strcpy (buf[use_buf], query_short_name(op));      safe_strcat(buf[use_buf], query_short_name(op), &len, HUGE_BUF);
   
     if (QUERY_FLAG(op,FLAG_INV_LOCKED))      if (QUERY_FLAG(op,FLAG_INV_LOCKED))
  strcat(buf[use_buf], " *");   safe_strcat(buf[use_buf], " *", &len, HUGE_BUF);
     if (op->type == CONTAINER && ((op->env && op->env->container == op) ||       if (op->type == CONTAINER && ((op->env && op->env->container == op) ||
  (!op->env && QUERY_FLAG(op,FLAG_APPLIED))))   (!op->env && QUERY_FLAG(op,FLAG_APPLIED))))
  strcat(buf[use_buf]," (open)");   safe_strcat(buf[use_buf]," (open)", &len, HUGE_BUF);
   
     if (QUERY_FLAG(op,FLAG_KNOWN_CURSED)) {      if (QUERY_FLAG(op,FLAG_KNOWN_CURSED)) {
  if(QUERY_FLAG(op,FLAG_DAMNED))   if(QUERY_FLAG(op,FLAG_DAMNED))
      strcat(buf[use_buf], " (damned)");       safe_strcat(buf[use_buf], " (damned)", &len, HUGE_BUF);
  else if(QUERY_FLAG(op,FLAG_CURSED))   else if(QUERY_FLAG(op,FLAG_CURSED))
      strcat(buf[use_buf], " (cursed)");       safe_strcat(buf[use_buf], " (cursed)", &len, HUGE_BUF);
     }      }
     /* Basically, if the object is known magical (detect magic spell on it),      /* Basically, if the object is known magical (detect magic spell on it),
      * and it isn't identified,  print out the fact that       * and it isn't identified,  print out the fact that
Line 322
 
Line 324
      * abilities, especially for artifact items.       * abilities, especially for artifact items.
      */       */
     if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED))      if (QUERY_FLAG(op,FLAG_KNOWN_MAGICAL) && !QUERY_FLAG(op,FLAG_IDENTIFIED))
  strcat(buf[use_buf], " (magic)");   safe_strcat(buf[use_buf], " (magic)", &len, HUGE_BUF);
     if(QUERY_FLAG(op,FLAG_APPLIED)) {      if(QUERY_FLAG(op,FLAG_APPLIED)) {
  switch(op->type) {   switch(op->type) {
    case BOW:     case BOW:
    case WAND:     case WAND:
    case ROD:     case ROD:
    case HORN:     case HORN:
      strcat(buf[use_buf]," (readied)");       safe_strcat(buf[use_buf]," (readied)", &len, HUGE_BUF);
      break;       break;
    case WEAPON:     case WEAPON:
      strcat(buf[use_buf]," (wielded)");       safe_strcat(buf[use_buf]," (wielded)", &len, HUGE_BUF);
      break;       break;
    case ARMOUR:     case ARMOUR:
    case HELMET:     case HELMET:
Line 344
 
Line 346
    case GIRDLE:     case GIRDLE:
    case BRACERS:     case BRACERS:
    case CLOAK:     case CLOAK:
      strcat(buf[use_buf]," (worn)");       safe_strcat(buf[use_buf]," (worn)", &len, HUGE_BUF);
      break;       break;
    case CONTAINER:     case CONTAINER:
      strcat(buf[use_buf]," (active)");       safe_strcat(buf[use_buf]," (active)", &len, HUGE_BUF);
      break;       break;
    case SKILL:     case SKILL:
    default:     default:
      strcat(buf[use_buf]," (applied)");       safe_strcat(buf[use_buf]," (applied)", &len, HUGE_BUF);
  }   }
     }      }
     if(QUERY_FLAG(op, FLAG_UNPAID))      if(QUERY_FLAG(op, FLAG_UNPAID))
  strcat(buf[use_buf]," (unpaid)");   safe_strcat(buf[use_buf]," (unpaid)", &len, HUGE_BUF);
   
     return buf[use_buf];      return buf[use_buf];
 }  }


Legend:
line(s) removed in v.1.5 
line(s) changed
 line(s) added in v.1.6

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