[DGD] Inherited objects list

Mordengaard mordengaard at blueyonder.co.uk
Fri Oct 28 12:09:01 CEST 2005


From: "Lord Lerkista" <lordlerkista at gmx.net>
> I've another question, it's safe to remove all variables and use 
> mappings??
> For example:
>
> int ac;
> int weight;
> string name;
> string short;
>
> ac = 10;
> weight = 5;
> name = "shield";
> short = "a small wooden shield";
>
> i want to do something like this:
>
> mapping vars;
>
> vars = ([ ]);
>
> vars["ac"] = 10;
> vars["weight"] = 5;
> vars["name"] = "shield";
> vars["short"] = "a small wooden shield";
>
> I like this way because i can get a list of variables - values from any 
> object
> Any disadvantage of this method??

I successfully used this system on an early version of Yhared (which started 
out based on 2.4.5), before we started the transition over to the Kernel 
lib, and didn't find any issues with it apart from dealing with variables 
with a zero value (which essentially don't exist in the mapping under 2.4.5) 
and differentiating between variables inherited from different models... in 
the end we allocated a prefix to each variable name (so o_ was object, p_ 
was player etc) and that made it easier when displaying the properties of 
objects with a simple "stat" command and optional filters (so "stat statue 
p" displayed all the properties of a statue objecting starting with 'p').
Another issue you might find is data size - since a mapping is 
essentially -two- arrays, you've doubled the size of the data associated 
with every single object in the game.
Oh, and unless you write in property read/write functions for each property, 
you'll need a wide-open set_prop/query_prop system which is very easy to 
abuse for anyone with code/wizard access.

Mordengaard (Yhared MUD) 




More information about the DGD mailing list