Re: [CODE] Info Channel

From: James Turner (turnerjh@XTN.NET)
Date: 06/25/98

George <greerga@CIRCLEMUD.ORG> writes:

> >OBCircle: I'm writing a function to verify a zone.  One thing it will
> >check is that the world is toplogically sound (ie going east then west
> >brings you back to the same room and so forth), that both sides of an
> >exit have doors, etc.  Anyone have any ideas for what else would be
> >good to check for?  When it's done I'll be glad to post it here if
> >anyone is interested.
> Would probably be a good extension for 'show errors'.
> Who's Chip?

ObSelf: I'm Chip; it's the name I go by usually, though it isn't my
legal name :)

Okay here's a first version of do_verify (maybe best called mudlint or
moblint for now *grin*).  It might be good in show errors, but
sometimes a one-way exit is a good thing and not an error.  I've made
it so that adding new functions to check for errors is as as simple as
possible.  I'll be adding more as time goes by.  Also, the macro use
is a touch hacky; might be time to bring the macros from graph.c and
put them somewhere global.  Also note that it can overrun buf so you
might want to use a larger buffer (my global buf is bigger than

Might be best to change check_exits to three functions, but it would
be trivial.  Note the warning output is similar to GCC.  It would be
nice to keep this consistant (though copying GCC isn't necessary).

-cut here-

typedef const char *(*verify_func)(int);

#define VALID_EXIT(x, y) (world[(x)].dir_option[(y)] && \
                          (TOROOM(x, y) != NOWHERE))
#define IS_DOOR(x, y) (IS_SET(world[(x)].dir_option[(y)]->exit_info, EX_ISDOOR))
#define IS_CLOSED(x, y) (IS_SET(world[(x)].dir_option[(y)]->exit_info, EX_CLOSED))

const char *
check_exits(int rnum)
  static char retbuf[MAX_STRING_LENGTH];
  int i;

  if (rnum == NOWHERE) return NULL;

  retbuf[0] = 0;

  for (i = 0; i < NUM_OF_DIRS; i++) {
    if (VALID_EXIT(rnum, i)) {
      if (TOROOM(TOROOM(rnum, i), rev_dir[i]) != rnum) {
        sprintf(retbuf + strlen(retbuf), "Room %d: going %s then %s doesn't return to starting room\r\n",
                world[rnum].number, dirs[i], dirs[rev_dir[i]]);
      if (TOROOM(rnum, i) == NOWHERE) {
        sprintf(retbuf + strlen(retbuf), "Room %d: door to the %s leads nowhere\r\n",
                world[rnum].number, dirs[i]);
      if (IS_DOOR(rnum, i) && (!VALID_EXIT(TOROOM(rnum, i), rev_dir[i]) || !IS_DOOR(TOROOM(rnum, i), rev_dir[i]))) {
        sprintf(retbuf + strlen(retbuf), "Room %d: door to the %s doesn't have a door on the other side\r\n",
                world[rnum].number, dirs[i]);
      if (IS_CLOSED(rnum, i) && (!VALID_EXIT(TOROOM(rnum, i), rev_dir[i]) || !IS_CLOSED(TOROOM(rnum, i), rev_dir[i]))) {
        sprintf(retbuf + strlen(retbuf), "Room %d: door to the %s is closed, but other side isn't\r\n",
                world[rnum].number, dirs[i]);
  if (retbuf[0])
    return retbuf;
    return NULL;

do_verify(CHAR_DATA *ch, char *argument, int cmd, int subcmd)
  int a = -1, b = -1, i, vfn;
  verify_func vfs[] = {check_exits, NULL};
  const char *s;

  sscanf(argument, "%d %d", &a, &b);

  buf[0] = 0;

  if (a < 0 || b < 0 || a == b) {
    send_to_char("Usage: verify <first room> <last room>\r\n", ch);

  for (vfn = 0; vfs[vfn]; vfn++) {
    for (i = a; i <= b; i++) {
      s = vfs[vfn](real_room(i));
      if (s)
        strcat(buf, s);

  if (buf[0])
    page_string(ch->desc, buf, 1);
    send_to_char("No errors found.\r\n", ch);

-cut here-

Chip/James/<insert explitive here>

James Turner                   UIN: 1102038

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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