Re: Code

From: Moppe Sewerin (mans@graphiclife.com)
Date: 04/05/02


On fredag, april 5, 2002, at 10:59 , SoulReaper Is here wrote:

> How do i change the autoexits so that it shows even closed doors but
> with a
> # in front of the exit?

This Autoexit code puts all exits with open doors inside (), all exits
with closed doors inside [].

Example:
Exits: north, (east), [south].


A bit Spaghetti code; with some pointless comparisons, but it works!

===== Beginning of Code =====

void do_auto_exits(struct char_data * ch)
{
   int door, slen = 0;

   *buf = '\0';

   for (door = 0; door < NUM_OF_DIRS; door++) {

     if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) &&                             !EXIT_FLAGGED(EXIT(ch, door)
, EX_ISDOOR)) {

             if (*buf) {
                 slen += sprintf(buf + slen, ", ");
             }

             slen += sprintf(buf + slen, "%s", dirs[door]);

     } else if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) {

             if (*buf) {
                 slen += sprintf(buf + slen, ", ");
             }

             slen += sprintf(buf + slen, "[%s]", dirs[door]);

     } else if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
EXIT_FLAGGED(EXIT(ch, door), EX_ISDOOR) &&
        !EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) {

             if (*buf) {
                 slen += sprintf(buf + slen, ", ");
             }

             slen += sprintf(buf + slen, "(%s)", dirs[door]);
     }
   }

   sprintf(buf2, "%sExits: %s.%s\r\n", CCCYN(ch, C_NRM),
          *buf ? buf : "None", CCNRM(ch, C_NRM));

   send_to_char(buf2, ch);
}

===== End of Code =====

Regards

Måns Sewerin

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT