[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Displaying Closed Exits (useful code?) -fixed a typo

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Gatewaysysop2   USA  (142 posts)  [Biography] bio
Date Sat 05 Jul 2003 06:08 PM (UTC)  quote  ]

Amended on Sat 26 Jul 2003 07:24 PM (UTC) by Gatewaysysop2

Message
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;
}

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] top

Posted by Rhayne   (14 posts)  [Biography] bio
Date Reply #1 on Mon 03 Sep 2012 05:06 AM (UTC)  quote  ]
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,852 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]