Re: [CODE] New vwear

From: The Fractal Dimension Staff (fracdime@GEOCITIES.COM)
Date: 06/22/98


Ok... so I've made a few mistakes here and there... :(
Watch for mailer linewrap here...
Revised edition - and this is pasted from my actual source:

----- act.wizard.c
--- add to extern variables:

extern struct obj_data *obj_proto;      /* prototypes for objs           */

--- add at bottom of code

void vwear_position(int wearpos, struct char_data * ch)
{
  char localbuf[MAX_STRING_LENGTH];
  int nr, found = 0;

  sprintbit(wearpos, wear_bits, buf);
  strcpy(localbuf, "VWEAR: Wear Position Search for");
  sprintf(localbuf + strlen(localbuf), "%s.\r\n", buf);
  for (nr = 0; nr <= top_of_objt; nr++) {
    if (CAN_WEAR(&obj_proto[nr], wearpos)) {
      sprintf(localbuf + strlen(localbuf), "%3d. [%5d] %s\r\n",
        ++found, obj_index[nr].vnum, obj_proto[nr].short_description);
    }
  }
  if (!found)
    sprintf(localbuf + strlen(localbuf), "     [-----] Not
    Found!\r\n");
  page_string(ch->desc, localbuf, 1);
}

void vwear_type(int type, struct char_data * ch)
{
  char localbuf[MAX_STRING_LENGTH];
  int nr, found = 0;

  strcpy(localbuf, "VWEAR: Object Type Search for");
  sprintf(localbuf + strlen(localbuf), "%s.\r\n", item_types[type]);
  for (nr = 0; nr <= top_of_objt; nr++) {
    if (GET_OBJ_TYPE(&obj_proto[nr]) == type) {
      sprintf(localbuf + strlen(localbuf), "%3d. [%5d] %s\r\n",
        ++found, obj_index[nr].vnum, obj_proto[nr].short_description);
    }
  }
  if (!found)
    sprintf(localbuf + strlen(localbuf), "     [-----] Not
    Found!\r\n");
  page_string(ch->desc, localbuf, 1);
}

ACMD(do_vwear)
{
  int i, j, l, types = 0;

  skip_spaces(&argument);

  if (!*argument) {
    strcpy(buf, "Usage: vwear <option>\r\n\r\n");
    strcat(buf, "Vwear options are:\r\n\r\n");
    strcat(buf, "Object types:\r\n");
    for (j = 0, i = 1; i < NUM_ITEM_TYPES; i++)
      sprintf(buf + strlen(buf), "%-15s%s", item_types[i], (!(++j % 5)
      ? "\r\n" : ""));
    strcat(buf, "\r\n");
    strcat(buf, "Wear positions:\r\n");
    for (j = 0, i = 1; i < NUM_ITEM_WEARS; i++)
      sprintf(buf + strlen(buf), "%-15s%s", wear_bits[i], (!(++j % 5)
      ? "\r\n" : ""));
    strcat(buf, "\r\n");
    send_to_char(buf, ch);
    return;
  }

  for (l = 1; l < NUM_ITEM_TYPES; l++) {
    if (is_abbrev(argument, item_types[l])) {
      types = 1;
      break;
    }
  }

  if (!types) {
    for (l = 1; l < NUM_ITEM_WEARS; l++) {
      if (is_abbrev(argument, wear_bits[l])) {
        types = 2;
        break;
      }
    }
  }

  if (types == 1)
    vwear_type(l, ch);
  else if (types == 2)
    vwear_position(1 << l, ch);
  else
    send_to_char("You must use a valid type or position!\r\n", ch);
}

.-------------------------------------------------.
|     Administration of The Fractal Dimension     |
|         "Non-existent MUD of the Year"          |
|       Reach us at fracdime@geocities.com        |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST