I lied. He's right. I just looked and my code doesn't use 2 loops through the event queue. It used to have 2 loops, but I guess I got rid of it at some point.
There is one thing I have done that I think is worth noting... To cut down on CPU, #define BUCKET_COUNT 64 event *event_list[BUCKET_COUNT]; int current_bucket; I actually have 64 queues, and each one is 1/64th the size. I advance current_bucket each time I pass through my process_events function. New events are added to bucket (e->ttl+current_bucket)%BUCKET_COUNT and ttl is set to ttl/BUCKET_COUNT. You'll notice this is similar to a radix sort or the hashing used to store room mob and obj indexes. A fairly small change, and if you use a large enough array, you should mostly only be processing events that will be fired on that pulse. --Palrich. ----- Original Message ----- From: "Davion Kalhen" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Thursday, February 05, 2004 8:18 PM Subject: Re: Linked lists, new element > Ug. I'm sorry about this, but this morning after getting home from work, I > posted stuff on the event list posted by Jeremy I believe it was, and I > don't think it sent... if it did, my bad ;). I can't remember your exact > code at all (After 12 hour shifts, the memory goes down the toilet). But, I > remember you had two for loops in your update function. If yours is called > as often as mine (Every cycle) that can much up some serious CPU if your > lists are large enough. I'd say switch to a doubly linked list (->next > ->prev), or right before the "event->delay-- <= 0" do the check to see if > its to be killed, if it is, even_last->next = event->next, etc. You know the > drill. But that should cut down on the CPU usage alittle and it eliminates > that redundant for loop. I hope this helps. > > Davion > > _________________________________________________________________ > Add photos to your messages with MSN 8. Get 2 months FREE*. > http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca > > > -- > ROM mailing list > [email protected] > http://www.rom.org/cgi-bin/mailman/listinfo/rom

