[DGD] Some questions

Noah Lee Gibbs angelbob at monkeyspeak.com
Tue Apr 1 01:46:30 CEST 2003


  I don't claim to be the resident expert on this stuff, but lemme take a 
try at it.

On Mon, 31 Mar 2003, Ben Chambers wrote:
> It should go in the auto object of course.  But wouldn't that be a memory
> problem to have that many copies of pointers to the object daemon?

  You can usually locate it using find_object().  The way I do it is to 
have a #define for OBJECTD, one that evaluates to 
"/usr/System/sys/objectd.c".  Then I can say "OBJECTD->whatever_func()" 
to call functions.  Or I can grab a pointer in the class I want it in, or 
whatever.
  No reason to keep it sitting around in AUTO.

> Is it
> possible to just use like a static in C++ so that only one instance of the
> pointer exists but they can all access it?

  You could make one class grab a copy, then call the "global" instance of 
that class to get it.  For instance "MYSTORAGECLASS->get_objectd()" or the 
equivalent.  I just use find_object().

> Also, in Design Patterns there a concept known as a flyweight. [...]
> instead of actually having multiple
> copies of that string, you can copy the pointer, which is faster and saves
> memory.  Is this possible to do using object pointers or something in DGD?

  Kinda.  You can't have it persist across threads, though.  That's 
because DGD constantly swaps objects out to disk, so it needs to store 
things in little memory arenas.  Those memory arenas are done per-object.  
If you want objects that don't come with their own memory arenas, they're 
called LightWeight Objects, or LWOs.  Details on my web site under the LPC 
Reference section.

> For example, for every instance of a weapon, instead of actually copying the
> string, simply point to a copy of the text?  Would this make any difference
> on performance (memory or speed wise?)

  DGD does a certain amount of this transparently and internally, though 
you can pretend it doesn't when you're coding.
  Alternately, you could use inheritance and trade speed for space.  I'm 
using data inheritance on some objects in Phantasmal and doing this kind 
of thing.  So object detail lists are actually compiled every time you ask 
for the list of details.
  If that gets to be a big deal for speed then I'll cache the results in 
certain cases, flipping the speed/space lever back in the other direction 
:-)

-- 
angelbob at monkeyspeak.com
See my page of DGD documentation at
"http://phantasmal.sourceforge.net/DGD/"
If you post to the DGD list, you may see yourself there!

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list