[SNIPPET] Owhere Mwhere

From: Gordon Forsythe (boah@SPRYNET.COM)
Date: 06/24/98

Using the normal immortal where, you get spammed if you do a where on
something like 'black' if you have lots of mobs and objects with black in
their aliases.  So I created two commands which uses page_string, one for
objects, one for mobs.  True, It's pretty much plopped together sections from
the normal where (most of the trouble was for the owhere command).
I put this in act.informative.c.  I'm taking for granted that you all know to
put the ACMD stuff in interpreter.c.
extern struct index_data *obj_index;

  int found = 0, num = 0;
  register struct obj_data *k;

  one_argument(argument, arg);
  sprintf(buf, "Objects\r\n");
  for (num = 0, k = object_list; k; k = k->next)
    if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) {
      found = 1;
      sprintf(buf + strlen(buf), "%3d. %-25s - ", num, k->short_description);
      if (k->in_room > NOWHERE) {
        sprintf(buf + strlen(buf), "[%5d] %s\r\n",
            GET_ROOM_VNUM(IN_ROOM(k)), world[k->in_room].name);
      } else if (k->carried_by) {
        sprintf(buf + strlen(buf), "carried by %s\r\n",
            PERS(k->carried_by, ch));
      } else if (k->worn_by) {
        sprintf(buf + strlen(buf), "worn by %s\r\n",
            PERS(k->worn_by, ch));
      } else if (k->in_obj) {
        sprintf(buf + strlen(buf), "inside %s, vnum [%d]\r\n",
            k->in_obj->short_description, GET_OBJ_VNUM(k->in_obj));
      } else {
        sprintf(buf + strlen(buf), "in an unknown location\r\n");
  if (!found)
    send_to_char("Couldn't find any such thing.\r\n", ch);
    page_string(ch->desc, buf, 1);

  int found = 0, num = 0;
  register struct char_data *i;

  sprintf(buf, "Mobs\r\n");
  one_argument(argument, arg);
  for (i = character_list; i; i = i->next)
    if (CAN_SEE(ch, i) && i->in_room != NOWHERE && isname(arg,
i->player.name)) {
      found = 1;
      sprintf(buf + strlen(buf), "M%3d. %-25s - [%5d] %s\r\n", ++num,
             GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name);
  page_string(ch->desc, buf, 1);
--Da End--
If you see anything wrong with them, by all means, let me know via my email.
Gordon Forsythe/Crom
Visit G on the web:  |Coder for SlashFang MUD
http://gman.base.org |mud.guam.net:4000
      GRF Web-Publishing (coming soon!)

     | 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