Re: Room, object etc listing code

From: Sammy (samedi@clark.net)
Date: 04/11/96


On Thu, 11 Apr 1996, Chris A. Epler wrote:

> A while back someone posted some code to list out the rooms, objects etc 
> very easily.  I believe the command was called rlist, olist etc...I 
> seemed to have misplaced it however and would like to put it up on Cambot 
> for everyone...

I posted a function to do this a few months ago.  It's untested code and 
needs some improvements like handling zones with more than 100 vnums.  
I'm going to be including a function like this in the next release of 
obuild but it calls some obuild utility functions.

Call the following function with a zone number and a list_type (0 for 
rooms, 1 for objects, 2 for mobs).  This is untested code, but it's all 
based on things I've done before.

Sam

#define CHECKED_FOR_BUGS   FALSE

#define LIST_ROOMS 	0
#define LIST_OBJECTS	1
#define LIST_MOBS	2

void list_stuff(struct char_data *ch, int zone, int list_type)
{
  int i, found = FALSE, rnum;
  char buf[8192];

  switch(list_type) {
    case LIST_ROOMS:
      sprintf(buf, "Rooms in zone #%d:\r\n\r\n", zone);
      for(i = zone * 100; i <= (zone * 100) + 99; i++) {
	r_num = real_room(i);
	if(r_num) {
	  sprintf(buf, "%s%5d - %s\r\n", buf, i, 
	    world[r_num].name ? world[r_num].name : "Unnammed");
	  found = TRUE;
	}
      }
      break;
    case LIST_OBJECTS:
      sprintf(buf, "Objects in zone #%d:\r\n", zone);
      for(i = zone * 100; i <= (zone * 100) + 99; i++) {
	r_num = real_object(i);
	if(r_num) {
	  sprintf(buf, "%s%5d - %s\r\n", buf, i,
	    obj_proto[r_num].short_description ?
	    obj_proto[r_num].short_description : "Unnammed");
	  found = TRUE;
	}
      }
      break;
    case LIST_MOBS:
      sprintf(buf, "Mobs in zone #%d:\r\n", zone);
      for(i = zone * 100; i <= (zone * 100) + 99; i++) {
	r_num = real_mobile(i);
	if(r_num) {
	  sprintf(buf, "%s%5d - %s\r\n", buf, i,
	    mob_proto[r_num].player.short_descr ?
	    mob_proto[r_num].player.short_descr : "Unnammed");
	  found = TRUE;
	}
      }
      break;
  }
  if(!found)
    sprintf(buf, "%sNone!\r\n", buf);
  page_string(ch->desc, buf, 1);
}

#undef LIST_ROOMS
#undef LIST_OBJECTS
#undef LIST_MOBS

#undef CHECKED_FOR_BUGS



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