On Friday, October 31, 1997 10:24 PM, Daniel Koepke [SMTP:dkoepke@CALIFORNIA.COM] wrote: > On Fri, 31 Oct 1997, Doppleganger Software wrote: > > -> <<time_data>> time_of_event_to_occur; > > The easiest way would be to just make it an integer and have > heartbeat() update the counter every second (or however slow/fast you > want it updated). > By checking each entry in the queue for being a particular value you add one major difficulty. The value will eventually roll over due to variable size limitations. A routine that decrements the time left and then fires the event when the time has been reached avoids this problem. That's how I've implemented the various event queues on my mud. Granted changing a variable's value incurs extra overhead than just comparing it. You don't have to check the specials cases though, so it's probably a wash processor time wise. > -> if (<<incoming->time_of_event is before test->time_of_event>>) > > ...which would make this a simple, "if (incoming->time <= test->time)" > > -> if (<<test->time_of_event is equal or before current_time>>) { > > and this would be changed to, "if (!(--test->time))" > > Yes, it's a very basic solution, but it works, it's simple, and > trivial to implement (then again, I seem to call a lot of stuff > "trivial" without ever checking if they are, in fact, trivial to code; > but it seems fairly simple [to me], so this might actually be > trivial). > The first queue is a real PITA. The rest are trivial :-) --Mallory Neither sweat, nor blood, nor frustration, nor lousy manuals nor missing parts, nor wrong parts shall keep me from my task. --Christopher Hicks +------------------------------------------------------------+ | 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