Ron Cole <rcole@EZY.NET> writes:
> > if (TOROOM(TOROOM(rnum, i), rev_dir[i]) != rnum) {
>
> If there is no reverse exit, this will crash, or atleast return the wrong
> answer.
>
> > if (TOROOM(rnum, i) == NOWHERE) {
> > sprintf(retbuf + strlen(retbuf), "Room %d: door to the %s leads nowhere\r\n",
> > world[rnum].number, dirs[i]);
>
> Isn't this not possible due to the VALID_EXIT check above?
Right on both counts. Guess there weren't any rooms violating #1 in
my code, so a crash didn't catch it. The other two take it into
account; just that one doesn't. I'm fixing it up and adding other
problems. I'll post it again in a few days.
ObCircle:
Here's a modification of the dig command. Requires Oasis OLC 1.6. It
will create the vnum of the room if it doesn't exist already, and it
works with diagonal directions. Very hackish :) It requires a slight
change to two olc functions as well.
void
redit_setup_new_quiet(DESCRIPTOR_DATA *d)
{
OLC_ROOM(d) = (ROOM_DATA *)mud_calloc(1, sizeof(ROOM_DATA));
OLC_ROOM(d)->name = mud_strdup("An unfinished room");
OLC_ROOM(d)->description = mud_strdup("You are in an unfinished room.\r\n");
OLC_VAL(d) = 0;
}
void
redit_setup_new(DESCRIPTOR_DATA *d)
{
redit_setup_new_quiet(d);
redit_disp_menu(d);
}
void
do_dig(CHAR_DATA *ch, char *argument, int cmd, int subcmd)
{
char buf2[MAX_INPUT_LENGTH];
char buf3[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH];
int iroom = 0, rroom = 0;
int dir = 0;
if (!ch->desc || IS_NPC(ch)) {
send_to_char("Mobs can't dig!\r\n", ch);
return;
}
two_arguments(argument, buf2, buf3);
iroom = atoi(buf3);
rroom = real_room(iroom);
if (!*buf2) {
send_to_char("Format: dig <dir> <room number>\r\n", ch);
return;
}
else if (!*buf3) {
send_to_char("Format: dig <dir> <room number>\r\n", ch);
return;
}
dir = search_block(buf2, short_dirs, FALSE);
if (dir < 0) {
send_to_char("That's not a valid direction\r\n", ch);
return;
}
ch->desc->olc = NULL;
if (rroom <= 0) {
if ((iroom > 0) && (iroom < 32000)) {
ch->desc->olc = (struct olc_data *) mud_malloc(sizeof(struct olc_data));
OLC_NUM(ch->desc) = iroom;
redit_setup_new_quiet(ch->desc);
redit_save_internally(ch->desc);
rroom = real_room(iroom);
if (rroom <= 0) {
send_to_char("ERROR making the new room! Report this to Saga!\r\n", ch);
cleanup_olc(ch->desc, CLEANUP_STRUCTS);
return;
}
send_to_charf(ch, "Creating room %d...\r\n", iroom);
}
else {
send_to_char("That's not a valid room to dig to or create!\r\n", ch);
return;
}
}
if (ch->desc->olc) OLC_ZNUM(ch->desc) = real_zone(iroom);
world[rroom].dir_option[rev_dir[dir]] = (ROOM_DIRECTION_DATA *)mud_malloc(sizeof(ROOM_DIRECTION_DATA));
world[rroom].dir_option[rev_dir[dir]]->general_description = NULL;
world[rroom].dir_option[rev_dir[dir]]->keyword = NULL;
world[rroom].dir_option[rev_dir[dir]]->to_room = ch->in_room;
world[ch->in_room].dir_option[dir] = (ROOM_DIRECTION_DATA *)mud_malloc(sizeof(ROOM_DIRECTION_DATA));
world[ch->in_room].dir_option[dir]->general_description = NULL;
world[ch->in_room].dir_option[dir]->keyword = NULL;
world[ch->in_room].dir_option[dir]->to_room = rroom;
olc_add_to_save_list(real_zone(iroom), OLC_SAVE_ROOM);
olc_add_to_save_list(real_zone(rroom), OLC_SAVE_ROOM);
sprintf(buf, "You make an exit %s to room %d.\r\n", buf2, iroom);
send_to_char(buf, ch);
if (ch->desc->olc) cleanup_olc(ch->desc, CLEANUP_STRUCTS);
}
Another ObCircle: Here's a command to find the next vnums in a given
zone. Works well. Yes it's inefficient as well, but it works.
One-shot commands can afford to be ineffecient :)
void
do_nextvnum(CHAR_DATA *ch, char *argument, int cmd, int subcmd)
{
int fnum = -1, i;
skip_spaces(argument);
if (isdigit(*argument))
fnum = atoi(argument);
if (fnum <= 0 )
fnum = (world[ch->in_room].number/100) * 100;
for (i = fnum; real_zone(i) == real_zone(fnum); i++) {
if (real_object(i) < 0) {
send_to_charf(ch, "Next object -- %4d\r\n", i);
break;
}
}
if (real_object(i) >= 0)
send_to_char("Next object -- none available\r\n", ch);
for (i = fnum; real_zone(i) == real_zone(fnum); i++) {
if (real_mobile(i) < 0) {
send_to_charf(ch, "Next mob -- %4d\r\n", i);
break;
}
}
if (real_mobile(i) >= 0)
send_to_char("Next mob -- none available\r\n", ch);
for (i = fnum; real_zone(i) == real_zone(fnum); i++) {
if (real_room(i) < 0) {
send_to_charf(ch, "Next room -- %4d\r\n", i);
break;
}
}
if (real_room(i) >= 0)
send_to_char("Next room -- none available\r\n", ch);
for (i = fnum; real_zone(i) == real_zone(fnum); i++) {
if (real_trigger(i) < 0) {
send_to_charf(ch, "Next trigger -- %4d\r\n", i);
break;
}
}
if (real_trigger(i) >= 0)
send_to_char("Next trigger -- none available\r\n", ch);
}
Chip
--
James Turner turnerjh@xtn.net UIN: 1102038
http://www.vuse.vanderbilt.edu/~turnerjh/
+------------------------------------------------------------+
| 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