Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] Re: (PR#12930) RFC: generalizing output types in effects
Home

[Freeciv-Dev] Re: (PR#12930) RFC: generalizing output types in effects

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12930) RFC: generalizing output types in effects
From: "Benoit Hudson" <bh@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 1 May 2005 10:37:47 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12930 >

On Thu, Apr 28, 2005 at 10:16:06PM -0700, Jason Short wrote:
> 2.  Add a new parameter to the effect structure.  I'm not entirely sure
> how this would work, but it would amount to a new entry in the
> [effect_xxx] section in the effects.ruleset.  This would be its very own
> variable in the effect structure in effects.h.  Advantages: fast.
> Disadvantages: more effect parameters bloat the (user) API; parameter is
> specific to just a few effect types; lots of work to code.

It needn't bloat the ruleset, if we smarten up the parser a tiny bit.

Then we have essentially two classes of bonuses: one-dimensional ones
take an enum value and return the bonus (the current case);
two-dimensional ones take enum and an int:
    get_city_bonus2(pcity, EFT_OUTPUT_PCT, O_GOLD)
to get the effect of marketplaces etc, for instance, or
    get_city_bonus2(pcity, EFT_MAKE_CONTENT, 2)
to get the effect of temples and cathedrals, which happens at stage two
of modifying citizen happiness.

Various other bonuses would be unaffected:
        get_city_bonus(pcity, EFT_DEFENSE_PCT)
or whatever (I'm making up all of these names).

Do we need more than 2-d?  It wouldn't be hard to go for 3, but I can't
think why we would want to.

We could also use just one function, at the cost of some checking:
    get_city_bonus(const struct city *pcity, enum effect_type, ...)
a la fcntl.  This may be a bad idea, I'm not sure.

I'm not sure why this solution is particularly complicated, as compared
to the making the output type a requirement (which is... interesting).

        -- Benoît





[Prev in Thread] Current Thread [Next in Thread]