Re: look_in_direction & auto_exits

From: George Greer (greerga@circlemud.org)
Date: 01/09/02


On Wed, 9 Jan 2002, Karl B Buchner wrote:

>void look_in_direction(struct char_data * ch, int dir){
>        room_rnum original = IN_ROOM(ch);
>        char_from_room(ch);
>        char_to_room(world[original].dir_option[dir].to_room)
>        look_at_room(ch);
>        char_from_room(ch);
>        char_to_room(original);
>}

Ewwww! *gag*

Wouldn't it be better to just do:

void look_in_direction(struct char_data *ch, room_rnum room, int dir)
{
  /* Perhaps you want to sanity check the arguments too? */
  struct room_direction_data *rdata = world[room].dir_option[dir];

  if (rdata) {
    if (rdata->general_description)
      send_to_char(rdata->general_description, ch);
    else
      send_to_char("You see nothing special.\r\n", ch);

    if (EXIT_FLAGGED(rdata, EX_CLOSED) && rdata->keyword) {
      sprintf(buf, "The %s is closed.\r\n", fname(rdata->keyword));
      send_to_char(buf, ch);
    } else if (EXIT_FLAGGED(rdata, EX_ISDOOR) && rdata->keyword) {
      sprintf(buf, "The %s is open.\r\n", fname(rdata->keyword));
      send_to_char(buf, ch);
    }
  } else
    send_to_char("Nothing special there...\r\n", ch);
}

(The astute will notice I basically just replaced "EXIT(ch, dir)" with
"rdata".)

--
George Greer
greerga@circlemud.org

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