[MUD-Dev] Re: [DevMUD] Re: Database module

Felix A. Croes felix at dworkin.nl
Tue Dec 22 22:36:07 CET 1998


J C Lawrence <claw at kanga.nu> wrote:

> Crossed to MUD-Dev as the discussion of ObjectID's is generic to
> server designe as versus DevMUD.
>
> On Sun, 20 Dec 1998 12:05:57 -0800 
> Jon Leonard<jleonard at divcom.slimy.com> wrote:
>
> > Things that we want to look up in the database have numeric IDs to
> > identify them, and there are newid() and recycle_id() to allocate
> > new ones and to tell the database than an ID is no longer in use.  I
> > was planning on using unsigned longs as the ID type (64-bit on
> > frost).
>
> I went thru the problem of ObjectID's and their re-use on MUD-Dev
> extensively.  A key problem is that there may be pointers or
> references to an object after the object has been destructed, and that
> once you have an ObjectID->human_readable->ObjectID translation
> mapping, you can never guarantee that a reference count is accurate.

For DGD, I use the following solution:

Object references internally consist of a pair of numbers, an index
in the object array and an "object reference count".  The object
reference count, a 32 bit number, is increased with one for every
new object created, starting with 2 for the first object.

All objects are referred to by these object references; there are
no direct pointers.  When an object is destructed, its object
reference is immediately set to 0.  When the slot in the object
array is reused for a new object, it gets a new object reference
count.

Since all objects are referred to by their <index, count> pairs,
it is easy to see if the object referred to does still exist:
the reference count will be different if the object has been
destructed.

Every time the mud reboots from a state dump file, all object
references are examined.  Those that refer to now-destructed
objects are given the (invalid) reference count 1.  The remainder
is renumbered, starting at 2.  So, saving the state of the entire
mud in a state dump and rebooting can be used to prevent
object reference count wraparound.  Assuming that 1000 new
objects are created every second on average, it would be
sufficient to reboot at least once every 49 days.

Felix Croes




More information about the mud-dev-archive mailing list