Displaying Closed Exits (useful code?) -fixed a typo

Posted by Gatewaysysop2 on Sat 05 Jul 2003 06:08 PM — 2 posts, 16,232 views.

USA #0
Hey all,

I spent a while last night going through the SML archives looking for a way to get closed exits to display on autoexits as [direction] as well as having them show up under the 'exits' comand output as "Direction - Closed". This is opposed to stock SMAUG where they are not shown in either case unless opened.

Below is what I came up with, 90% of which is drawn off something Xerves (I believe) posted on the SML as a response to someone elses query a long time back. I tweaked this using examples I found in a few places and I finally got it working right. I've tested this with exits that lead to dark rooms, hidden exits, etc. and it appears to work just fine.

I had the initial problem that closed doors leading to rooms flagged 'dark' would display as "Too dark to tell" rather than saying it was "Closed" in that direction. It is my thinking that you shouldn't be able to tell that it's too dark on the other side of a closed door, so I changed that. This way, no matter what's on the other side, if the door is closed it simply says "Closed - Direction".

Again, I take no credit here since this is really just a compilation of the work of others into a configuration that I found the most desirable.

In act_info.c , replace the stock do_exits with:



void do_exits( CHAR_DATA *ch, char *argument )
{
   char buf[MAX_STRING_LENGTH];
   EXIT_DATA *pexit;
   bool found;
   bool fAuto;

   set_char_color( AT_EXITS, ch );
   buf[0] = '\0'; 
   fAuto  = !str_cmp( argument, "auto" );

   if ( !check_blind(ch) )
return;

   strcpy( buf, fAuto ? "Exits:" : "Obvious exits:\n\r" );

   found = FALSE;
   for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
   {
    if ( pexit->to_room
   && (!IS_SET(pexit->exit_info, EX_WINDOW)
    ||   IS_SET(pexit->exit_info, EX_ISDOOR))
    &&  !IS_SET(pexit->exit_info, EX_HIDDEN) )
    {
       found = TRUE;
       if ( fAuto )
       {
          strcat( buf, " " );
          if (IS_SET(pexit->exit_info, EX_CLOSED))
             strcat(buf, "[");
          strcat( buf, dir_name[pexit->vdir] );
          if (IS_SET(pexit->exit_info, EX_CLOSED))
             strcat(buf, "]");
       }
    else
    {
 sprintf( buf + strlen(buf), "%-5s - %s\n\r",
     capitalize( dir_name[pexit->vdir] ),
          room_is_dark( pexit->to_room )
          && !IS_SET(pexit->exit_info, EX_CLOSED)
          ?  "Too dark to tell"
          : IS_SET(pexit->exit_info, EX_CLOSED)
          ? "Closed" : pexit->to_room->name);
  
     }
    }
   }

   if ( !found )
strcat( buf, fAuto ? " none.\n\r" : "None.\n\r" );
   else
     if ( fAuto )
strcat( buf, ".\n\r" );
   send_to_char( buf, ch );
   return;
}
Amended on Sat 26 Jul 2003 07:24 PM by Gatewaysysop2
#1
When copy/pasting the code I was getting a compile error:

Compiling o/act_info.o....
o/act_info.o: In function `do_look':
/host/JD/smaugfuss19/src/act_info.c:1285: undefined reference to `do_exits'
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2

Changed char *argument to const char *argument and it compiled and is working beautifully. Very helpful code, thanks.