[CODE][NEWBIE]event system for objects

From: Mundi King (kingmundi@yahoo.com)
Date: 12/20/98


some time ago, i remember there
was a discussion on the mailing
list concerning the way circlemud
handles the extraction of items,
searching of itmes, and various
other routines, and some thoughts
about replacing the long for loops
with an event system, i thought i
would explore this scenario and
started putting together some mock
up code to test the idea, i used
dgevents1_1 from eric green, and
started putting in an event attached
to any object (at the moment) that
would make the object explode, but
i am running into a problem,

to keep the event system clean, i
free the event when the object is
extracted,

however, the event itself causes the
object to be extracted, when i
extract the object from within the
event, i get an exception error
from the event que

void queue_deq(struct queue *q, struct q_element *qe)
{
  int i;

  assert(qe);

  i = qe->key % NUM_EVENT_QUEUES;

  if (qe->prev == NULL)
    q->head[i] = qe->next;
  else
  /* this next line is where the error occurs */
    qe->prev->next = qe->next;

  if (qe->next == NULL)
    q->tail[i] = qe->prev;
  else
    qe->next->prev = qe->prev;

  free(qe);
}


i put up a mock up patch,
http://www.yoda.com/~mundi/save/code/c/circle/tickevents/wip/

note that this patch doesnt do anything
usefull, it gives all objects an extra field,
if you wield an object, then type pull pin,
the event system gets set, checks to see
if the object is in a room (not in your hand),
if it is, it sends a message to the room,
and extracts the object, and crashes the mud,

i was wondering if anyone out there has already
implemented something along these lines,
at much better quality then my feeble attempts




_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com


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



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