Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CF: object structure layout.




On 17 Jun 1999, Kjetil Torgrim Homme wrote:
> [Mark Wedel]
> >    True.  But to have the server effectively use the os paging for
> >   unusued maps, the unused objects must be disassociated from the
> >   lists that the program is using for the active maps.  So that sort
> >   of goes back to having the needed lists referanced from the map
> >   structure, and not global lists.

To "free" up memory in a way that makes it possible to swap out 
efficiently, all pointers to objects must be rewritten to be two-way, so 
that you can easily move an object in memory.  That way you can have some 
garbace-cleaning algorithm putting all free objects in the same memory 
space.  This would mean going away from normal malloc for objects...
Probably not worth it, as you loose out when you start swapping anywa.  
And with ram prices these days...Crossfire was made to run on a Sun 3/50 
with, hmm what was it, 8Mb of ram?
Btw, all pointers really should become two-way anyway, so that when an 
object is freed, you can quickly remove all pointers to it.  This used to 
be the #1 bug in crossfire...I added some hacks to avoid it as much as 
possible, but it was never perfect.

As for processing active objects, an old idea I never got around to
implementing was to have a sorted binary tree of objects to process.

When processing an object, you remove the previous pointer to it from this
list, and calculate when in time it will next be processed.  Then you
search this location in the binary tree and insert a new pointer.  You
could even add pointers to other time events to this tree, like swapping
out maps, autosaving characters, sending server stuff to clients, etc.  I
think this is the way time events are usually handled in bigger network
projects.

The advantage of just 1 list is that when an object is freed, you only 
have to find and remove it from this one list (by way of two-way pointer 
back from object to binary time-event tree).

-Frank.
-
[you can put yourself on the announcement list only or unsubscribe altogether
by sending an email stating your wishes to crossfire-request@ifi.uio.no]