Re: [Newbie] How do I add races and hometowns?

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 06/15/01


On Fri, 15 Jun 2001, Stacey F. Hanna wrote:

>   if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
>       !EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))
>     slen += sprintf(buf + slen, "%c ", LOWER(*dirs[door]));
>   else if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE &&
>       EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))
>     slen += sprintf(buf + slen, "!%c ", LOWER(*dirs[door]));

A little bit cleaner:

  if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE) {
    if (!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))
      slen += sprintf(buf + slen, "%c ", LOWER(*dirs[door]));
    else
      slen += sprintf(buf + slen, "!%c ", LOWER(*dirs[door]));
  }

Shorter, cleaner (but maybe confusing) to a person not familiar with C:

  if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE)
    slen += sprintf(buf + slen, "%s%c ",
                    EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) ? "!" : "",
                    LOWER(*dirs[door]));

No real benefit in repeating conditions.  :)


--
Daniel A. Koepke (dak), dkoepke@circlemud.org
Caveat emptor: I say what I mean and mean what I say.  Listen well.
Caveat venditor: Say what you mean, mean what you say.  Say it well.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST