(btw, xxviper, I added you to the cc: field because I would like to continue this discussion with you...) > I noticed you store pointers to victim, object, etc.. How do you deal with > a char or vict logging out, or an obj/mob being deleted, after the event has > been loaded but before it has been executed? I have imped my own events queue > and have been toying with the idea of having every char, mob, and obj have > a pointer to a linked list that points to every event that they are loaded > for. The other option is, on the freeing of a char/obj, to go through the > whole event queue and compare every pointer to see if it matches. In my event queue, this is what I did. I would search the list when a char or obj is extracted and see if they have any events pointing to them. I would be interested in hearing how others have done it. Well, I've been thinking about it for awhile, and I guess that one must decide which of the two methods above to use depending on how much one plans on using the queue. If you are going to have practically everything loaded into the queue, then I think it would be worth it to use memory and allocate a linked list for every char/obj that points to all events of which they are a part. For example, say the structure that holds one event is called struct event_queue_element { ... struct char_data ch; /* void pointers to various recipients in queue events */ void *victim1; void *victim2; ... } Then you could define another structure, struct queue_element_list { void *me; struct queue_element_list *next_in_list; }; Then every char and obj would have in their struct a pointer to this list: ... struct queue_element_list *queue_elements; ... and whenever you load something into the queue (creating a new element), for every ch or victim you assign in that element, create a new member of this linked list and add it to the obj/char in question's *queue_elements list. You would put the void *me pointer pointing to the char/obj's own entry in the queue element, and if that char/obj gets extracted, part of the extraction process will go through the linked list and NULL all relevant pointers.. then when you call the queue event and check the pointer that's supposed to have a victim, if its null you can respond appropriately ("Your victim is gone.")... you might also have to do this if they even just go to the next room or something... Hmmm. This is another problem I have run into with the queue, conflicting events. Again, to deal with those you would either have to go through the entire queue list to find any possible conflicting events, or else have each char/obj store the linked list that I outlined above. Or you could divide all possible actions into different queues, only allowing one event per char in any particular queue... what do you think?
This archive was generated by hypermail 2b30 : 12/07/00 PST