[DGD] Shadows issue

Felix A. Croes felix at dworkin.nl
Fri Jul 17 13:16:26 CEST 2009


Kamil N <kamiln at gmail.com> wrote:

> Well, I agree shadowing is not the best thing on earth, but I can't
> really come with solution that makes them obsolete. As far as I
> remember shadows had lots drawbacks (determining which object is going
> to be the final one masking when more than one shadows is applied and
> they all mask the same function, security issues etc), but in some
> cases they were really useful.
>
> So my question is more about good ways to avoid shadows, rather than
> reproducing them in DGD environment. I can imagine alot of situations
> when I may need to _temporarily_ change result or behaviour of some
> function in (for example) player object. It goes for all things like
> changing gender due to some curse, changing whole body as I mentioned
> in earlier post, basically change anything that may require change due
> to some game design (curses, guild membership, mounts, sitting at the
> table etc.).

You can turn things around.  Rather than letting the shadow determine
which functions are overridden, you can let the shadowed object decide
what functionality <can> be overriden, and either make those directly
configurable (i.e. with a set_guild_title function) or let it call
a different object to handle it.  Like this:

    void set_shadow(object obj) { shadow = obj; }

    string query_guild_title()
    {
	if (shadow) {
	    return shadow->query_guild_title();
	}

	return guild_title;
    }

Regards,
Felix Croes



More information about the DGD mailing list