Re: NEWBIE: A new type of door.

From: Admin of The Keep (
Date: 09/29/96

On Sat, 28 Sep 1996, Homer Simpson wrote:

> Hiya all,
>          I would like to make a new type of door. Here's how it would
> work. It starts closed. If it's opened, it will stay open for 2 seconds
> then automatically close again. Any ideas on how I can do this?

Well, I am using some event driven code that I coded some while ago which
makes it incredibly easy to do something like this, but it's still
possible without events.

The way I would do would be to make a linked list like:

  struct auto_close_door_llist {
    room_num in_room;
    byte dir;
    byte time_left;
    struct auto_close_door_llist *next;

Then implement a new door flag (EX_TIMED).  In the function that does
heartbeat handling in comm.c:

  /* Put these at the top of the function */
  extern struct auto_close_door_llist *Timed_Doors;
  struct auto_close_door_llist *td, *temp;
  struct room_exit_data *dr; /* !! See Note Below !! */

  if (!(pulse % PULSE_PER_SECOND)) /* !! See Note Below !! */
    if (Timed_Doors)
      for (td = Timed_Doors; td; td = td->next) {
        dr = world[td->in_room].dir_option[td->dir];
        if (dr && IS_SET(dr->exit_info, EX_TIMED) &&
	    !IS_SET(dr->exit_info, EX_CLOSED)) {
          SET_BIT(dr->exit_info, EX_CLOSED);
          sprintf(buf, "A door to the %s closes.\r\n", dirs[dir]);
          send_to_room(buf, td->in_room);
        REMOVE_FROM_LIST(td, Timed_Doors, next);
You'll also need to define the global linked list in act.movement.c and in
that same file check if the door being opened is set EX_TIMED and if so
add it to the linked list.  Furthermore, you should remove them when timed
exits are closed by the CLOSE command.

NOTE:  I've not looked at the Circle code in at least a month, this is all
done from memory.  Nor have I ever implemented anything like this so this
is just how I think it would work.  I use a linked lists which is not
always neccessary, however, in this implementation I think it's best to
have a dynamic list.  A few of the things in the enclosed snippets may not
be correct for CircleMUD.  I cannot tell you what you must do here or
there.  If there's a great amount of demand, however, I will create a
patch for this.  Also, I'll upload a fix for my do_who patch.  Maybe do a
few more patches, too.


| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

This archive was generated by hypermail 2b30 : 12/18/00 PST