Okay cool, real discussion. I logged out of the CircleMUD server (Why is it taking so long??) but I still received this one. On Fri, 17 Nov 1995, Pink Floyd wrote: > 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 I think I posted a general version of the event server. As it stands now, there is an object which acts as the player handler. This allows faster searches (than linked list), plus puts all the in depth stuff behind the interface. The current way this is handled is to pass the player PID (Player ID Number) as the argument, then at the beginning of the event, ask the player handler for a pointer to the given PID (or Mobile ID Number as it may). If this doesn't exist anymore (character logged out, player died, etc) then I either return without doing anything (in the case of a cargo ship moving players) or print a message like "The basilisk has moved out of range." if the enemy moved during the spell delay. (Movement was distance based, not room based in my server. IE it was possible for two people to be in the same wheat field and see each other, but be too far away for a sling to be used as a weapon.) > Another option I had was to not store any of those pointers, but to keep a > copy of the original argument that the char typed (all queue events originally > come from a ACMD function) and just parse the argument every time that event Exactly. See above. > mobs leaving the room in the middle of having a spell cast at them, or players > logging out while someone is backstabbing them, etc. Which do you think would > be more efficient, parsing the arg everytime or having every char have a > linked list of pointers to every event queue of which they are a part? > More efficient or better? It would be faster to avoid any linear search, but it is more complex overall to store pointers, since when the event is executed and removed, you must find every mobile and object that had a reference to that event and blank that pointer, or else you will have seg faults later on. Since I have character and mobile handlers, I can search the player list in (log n) time (compared to order n time for a linear search). Not a huge boost, but provides enough gain that I can allow the events to ask the character handler for the character's onject pointer each time it is executed - and then not worry about storing pointers in several places that I must track down when the event gets dequeued. > (I hope this isn't too incoherent.) Same here =) > > By the way, I am also planning on having combat in the queue, so there are no > combat ticks, everyone attacks at their own rate which is a function of many > things. I can control the action down to the 1/10 of a second, but I was > wondering if this would produce way to much spam (like, making a prompt in > between every attack in the room might cause way too much spam). Any > suggestions? > To handle this (and a realistic combat system based on speed, dexterity, weapon type, encumbrance, etc) I just gave each player a prompt timer, so that the fastest each player could get a prompt in combat was 1 second. This avoided spam yet seemed to give the players enough info at the appropriate time. You might also consider putting combat into a separate queue from world events, and from player events. (I have 4 event queues like that). It just made it easier to comtrol aspects of combat, and find the combat events. I had a "peace" type of spell, and it was a lot easier to flush the smaller combat queue of combat events in my area then to parse the whole list of world events, looking for combat events. On average, a single event queue for the entire game turned out to have 52 events pending. Hope this helps someone.
This archive was generated by hypermail 2b30 : 12/07/00 PST