03 Feb, 2010, boblinski wrote in the 1st comment:
Votes: 0
What I'm wanting to do is change do_exits so that..

a) when an exit door is closed.. that direction (when you "look") is shown with brackets around it… Example:
If in a room with avaliable directions north, east and south… but east directions door is closed.. it will show like this:
Quote
[Exits: north (east) south]


b) when you type "exit" it currently shows what is in the direction of a closed door… however I would like closed exits do simply appear with (closed) instead… As for the example room above.. this would be the situation:
Quote
Obvious exits:
North - Northern Arena
East - (closed)
South - Southern Arena


This is my current do_exit:
void do_exits (CHAR_DATA * ch, char *argument)
{
extern char *const dir_name[];
char buf[MAX_STRING_LENGTH];
EXIT_DATA *pexit; /** LINE 1499 **/
bool found;
bool fAuto;
bool closed;
int door;

fAuto = !str_cmp (argument, "auto");

if (!check_blind (ch))
return;

if (fAuto)
sprintf (buf, "{o[Exits:");
else if (IS_IMMORTAL (ch))
sprintf (buf, "Obvious exits from room %d:\n\r", ch->in_room->vnum);
else
sprintf (buf, "Obvious exits:\n\r");

found = FALSE;
closed = FALSE;

//editted for showing closed exits
for (door = 0; door <= 5; door++)
{
if (IS_SET (pexit->exit_info, EX_CLOSED))
closed = TRUE;

if ((pexit = ch->in_room->exit[door]) != NULL
&& pexit->u1.to_room != NULL
&& can_see_room (ch, pexit->u1.to_room))
{
found = TRUE;
if (fAuto)
{
strcat (buf, " ");
if (closed)
{
strcat (buf, "(");
strcat (buf, dir_name[door]);
strcat (buf, ")");
}
else
strcat (buf, dir_name[door]);
}
else
{
if (closed)
{
sprintf (buf + strlen (buf), "%-5s - %s",
capitalize (dir_name[door]), "(closed)");
if (IS_IMMORTAL (ch))
sprintf (buf + strlen (buf), " (room %d)\n\r", pexit->u1.to_room->vnum);
}
else
{
sprintf (buf + strlen (buf), "%-5s - %s",
capitalize (dir_name[door]),
room_is_dark (pexit->u1.to_room)
? "Too dark to tell" : pexit->u1.to_room->name);
if (IS_IMMORTAL (ch))
sprintf (buf + strlen (buf),
" (room %d)\n\r", pexit->u1.to_room->vnum);
else
sprintf (buf + strlen (buf), "\n\r");
}
}
}
closed = FALSE;
}
//done

if (!found)
strcat (buf, fAuto ? " none" : "None.\n\r");

if (fAuto)
strcat (buf, "]{x\n\r");

send_to_char (buf, ch);
return;
}


This is my compile warning:
Quote
gcc -Wall -O -ggdb -DNOCRYPT -DQMFIXES -c -o obj/act_info.o act_info.c
act_info.c: In function `do_exits':
act_info.c:1499: warning: 'pexit' might be used uninitialized in this function


And once I boot up the mud.. it crashes after the MOTD.

Any help would be very appreciated,
Bob.
03 Feb, 2010, Kjwah wrote in the 2nd comment:
Votes: 0
You're calling pexit before it's been initialized.

//editted for showing closed exits
for (door = 0; door <= 5; door++)
{
if (IS_SET (pexit->exit_info, EX_CLOSED))
closed = TRUE;


If you look at the next section of code, pexit gets initialized.

if ((pexit = ch->in_room->exit[door]) != NULL
&& pexit->u1.to_room != NULL
&& can_see_room (ch, pexit->u1.to_room))
{
found = TRUE;


So, you should probably move that if check to somewhere after it's been initialized. :)
0.0/2