|
Verify Command [by James Turner] |
|
|
|
Posted Wednesday, August 12th @ 11:38:29 PM, by George Greer in the Zones dept.
Added Jul 6, 1998. Click the link below to read it or download it.
From: James Turner <turnerjh@XTN.NET>
Subject: Verify Command
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
MAX_STRING_LENGTH).
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_CLOSE
D))
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 ret
urn 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]) || !I
S_CLOSED(TOROOM(rnum, i), rev_dir[i]))) {
sprintf(retbuf + strlen(retbuf), "Room %d: door to the %s is closed, bu
t other side isn't\r\n",
world[rnum].number, dirs[i]);
}
}
}
if (retbuf[0])
return retbuf;
else
return NULL;
}
void 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);
return;
}
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);
else
send_to_char("No errors found.\r\n", ch);
}
-cut here-
Chip/James/<insert explitive here>
<< Vehicle code [by Chris Jacobson] | Reply | View as text | Threaded | Vwear command [by WarRat] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|