liblist2.txt

From: Anthony Rye (ajrye@ONE.NET)
Date: 07/04/98


__________________________SNIP_____________________________________________
/* ************************************************************************
Modified by: Whitedemon
Original Code By: Stormrider <stormrider@hotmail.com>
Subject: Olist/Rlist/Mlist/Zlist
************************************************************************** */

I made no change to the original code (didn't see a need to) i just added
in a new command. So all credits to the original coder.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You'll want to define three SCMDs in interpreter.h, as in:
#define SCMD_OLIST      0
#define SCMD_MLIST      1
#define SCMD_RLIST      2
#define SCMD_ZLIST      3

And don't forget to fix interpreter.c, with the solo ACMD(do_liblist); and
{ "mlist" , POS_DEAD, do_liblist, LVL_*whatever*, SCMD_MLIST },
{ "olist" , POS_DEAD, do_liblist, LVL_*whatever*, SCMD_OLIST },
{ "rlist" , POS_DEAD, do_liblist, LVL_*whatever*, SCMD_RLIST },
{ "zlist" , POS_DEAD, do_liblist, LVL_*whatever*, SCMD_ZLIST },


ACMD(do_liblist)
{
  extern struct room_data *world;
  extern struct index_data *mob_index;
  extern struct char_data *mob_proto;
  extern struct index_data *obj_index;
  extern struct obj_data *obj_proto;
  extern struct zone_data *zone_table
  extern int top_of_objt;
  extern int top_of_mobt;
  extern int top_of_world;

  int first, last, nr, found = 0;

  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2) {
    switch (subcmd) {
      case SCMD_RLIST:
        send_to_char("Usage: rlist <begining number> <ending number>\r\n", ch);
        break;
      case SCMD_OLIST:
        send_to_char("Usage: olist <begining number> <ending number>\r\n", ch);
        break;
      case SCMD_MLIST:
        send_to_char("Usage: mlist <begining number> <ending number>\r\n", ch);
        break;
      case SCMD_ZLIST:
        send_to_char("Usage: zlist <begining number> <ending number>\r\n", ch);
        break;
      default:
        sprintf(buf, "SYSERR:: invalid SCMD passed to ACMDdo_build_list!");
        mudlog(buf, BRF, LVL_GOD, TRUE);
        break;
    }
    return;
  }

  first = atoi(buf);
  last = atoi(buf2);

  if ((first < 0) || (first > 99999) || (last < 0) || (last > 99999)) {
    send_to_char("Values must be between 0 and 99999.\n\r", ch);
    return;
  }

  if (first >= last) {
    send_to_char("Second value must be greater than first.\n\r", ch);
    return;
  }

  switch (subcmd) {
    case SCMD_RLIST:
      sprintf(buf, "Room List From Vnum %d to %d\r\n", first, last);
      for (nr = 0; nr <= top_of_world && (world[nr].number <= last); nr++) {
        if (world[nr].number >= first) {
          sprintf(buf, "%s%5d. [%5d] (%3d) %s\r\n", buf, ++found,
                  world[nr].number, world[nr].zone,
                  world[nr].name);
        }
      }
      break;
    case SCMD_OLIST:
      sprintf(buf, "Object List From Vnum %d to %d\r\n", first, last);
      for (nr = 0; nr <= top_of_objt && (obj_index[nr].virtual <= last); nr++) {
        if (obj_index[nr].virtual >= first) {
          sprintf(buf, "%s%5d. [%5d] %s\r\n", buf, ++found,
                  obj_index[nr].virtual,
                  obj_proto[nr].short_description);
        }
      }
      break;
    case SCMD_MLIST:
      sprintf(buf, "Mob List From Vnum %d to %d\r\n", first, last);
      for (nr = 0; nr <= top_of_mobt && (mob_index[nr].virtual <= last); nr++) {
        if (mob_index[nr].virtual >= first) {
          sprintf(buf, "%s%5d. [%5d] %s\r\n", buf, ++found,
                  mob_index[nr].virtual,
                  mob_proto[nr].player.short_descr);
        }
      }
      break;
    case SCMD_ZLIST:
      sprintf(buf, "Zone List From Vnum %d to %d\r\n", first, last);
      for (nr = 0; nr <= top_of_zone_table && (zone_table[nr].number <= last); nr++) {
        if (zone_table[nr].number >= first) {
          sprintf(buf, "%s%5d. [%5d] (%3d) %s\r\n", buf, ++found,
                  zone_table[nr].number, zone_table[nr]..lifespan,
                  zone_table[nr].name);
        }
      }
      break;
    default:
      sprintf(buf, "SYSERR:: invalid SCMD passed to ACMDdo_build_list!");
      mudlog(buf, BRF, LVL_GOD, TRUE);
      return;
  }

  if (!found) {
    switch (subcmd) {
      case SCMD_RLIST:
        send_to_char("No rooms found within those parameters.\r\n", ch);
        break;
      case SCMD_OLIST:
        send_to_char("No objects found within those parameters.\r\n", ch);
        break;
      case SCMD_MLIST:
        send_to_char("No mobiles found within those parameters.\r\n", ch);
        break;
      case SCMD_ZLIST:
        send_to_char("No zones found within those parameters.\r\n", ch);
        break;
      default:
        sprintf(buf, "SYSERR:: invalid SCMD passed to do_build_list!");
        mudlog(buf, BRF, LVL_GOD, TRUE);
        break;
    }
    return;
  }

  page_string(ch->desc, buf, 1);
}

----------------------------------------------------SNIP
Sorry for the spamm!


     +------------------------------------------------------------+
     | 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