[INFO NEEDED][SEMI-CODE] Event based queue

From: Doppleganger Software (doppsoft@TZC.COM)
Date: 10/31/97


Ok, what I have is a 'white-page' of an event based queue I am working
on, but I need a little help.  I am not very familiar on how the MUD, or
coding in general, handles time.  Also, I am looking for suggestions on
how to slim down the code, possibly make it more efficient.  And info I
am looking for help on filling in will be in << >>'s


struct event_type {
  int event;
  <<time_data>> time_of_event_to_occur;
  int info2;
  int info3;
  int info4;
  char *arg;
  void *subject;
  void *target;
  struct event_type *next;
};


void add_event(struct event_type *incoming)
{
  struct event_type *temp, *next_event;

  if (!event_queue) {
    event_queue = incoming;
    incoming->next = NULL;
    return;
  }
  for (test = event_queue; test; test = next_event) {
    next_event = text->next;
    if (<<incoming->time_of_event is before test->time_of_event>>)
      break;
  }
  test->next = incoming;
  incoming->next = next_event;

}

void process_events(void)
{
  struct event_type temp, next_event;

  if (!event_queue)
    return;

  if (<<event_queue->time_of_event is after current_time>>)
    return;

  for (test = event_queue; test; test = next_event) {
    next_event = test->next;
    if (<<test->time_of_event is equal or before current_time>>) {
      do_event(test);
      event_queue = next_event;
      free(test);
    }
  }
}

As you can see, this is partially coded, partially not.  With this
system, some commands will obviously be put in the event_queue and then
dealt with later, and some will go through automatically.  I am wondering
what the thoughts are on if a person is 'waiting for command' and they
type in another command that must be waited for.  For example, say the
person is casting a spell that takes a few seconds RL time...if they type
in 'west', so that they move immediately after the spell goes off, how
should I handle that?  I was thinking flagging every character that is
'waiting for command' as such, then removing that when they do the
command.  Then, if they type in another command, it puts that command
into a 'personal' event_queue.  Then, when they do the command in the
main queue, it pulls one from their personal queue.  My problem with this
is that personal queue can get pretty big if they want to fill it up with
commands for some bizzare reason (or a client that sends a lot)  My other
idea is that if they are 'waiting for event' it saves only the next
command, no others.  Any thoughts that any of you would like to share?


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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