[CODE] New vwear

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


I added vwear in and didn't like it too much, so I made an adaptible
one.  This assumes you have Oasis installed as it uses NUM_ITEM_TYPE
and NUM_ITEM_WEAR
If you don't have Oasis just define these two values at top of
act.wizard.c

----- act.wizard.c
--- Add these to extern functions:

void vwear_position(int wearpos, struct char_data * ch);
void vwear_type(int type, struct char_data * ch);

--- Add to bottom of file or anywhere you like :)

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); }

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);
}

Even if it makes no significant improvement over old vwear (as in
coding style) it generates a much nicer looking output -- I think.
.-------------------------------------------------.
|     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