Re: Code

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 04/05/02


On Sat, 6 Apr 2002, Moppe Sewerin wrote:

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

Yikes, you weren't kidding about that.  It's nearly a maintainence
nightmare.  A quick, untested revision:

    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 )
            {
                if ( *buf != '\0' )
                    slen += sprintf(slen + buf, ", ");

                if ( !EXIT_FLAGGED(EXIT(ch, door), EX_ISDOOR) )
                    slen += sprintf(slen + buf, "%s", dirs[door]);
                else if ( EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) )
                    slen += sprintf(slen + buf, "[%s]", dirs[door]);
                else
                    slen += sprintf(slen + buf, "(%s)", dirs[door]);
            }
        }

        sprintf(buf2, "%sExits: %s.%s\r\n", CCCYN(ch, C_NRM),
                (*buf != '\0' ? buf : "None", CCNRM(ch, C_NRM));
        send_to_char(buf2, ch);
    }

-dak

--
   +---------------------------------------------------------------+
   | 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