Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: unit flags/capabilities
Home

[Freeciv-Dev] Re: unit flags/capabilities

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: unit flags/capabilities
From: vze2zq63@xxxxxxxxxxx
Date: Thu, 29 Nov 2001 13:45:36 -0500
Reply-to: jdorje@xxxxxxxxxxxx

Reinier Post wrote:

On Thu, Nov 29, 2001 at 08:51:25AM -0500, Andrew Sutton wrote:

if you really want to add a new unit that defines a new field, say fuel (for aircraft), then the correct thing to do would be to "derive" a new structure for it. you'd end up with this:

struct unit
{
        unit_type       type;
        unit_flags      flags;
        // other generic information
};

struct aircraft
{
        struct unit     base;
        unsigned        fuel;
};


So now, at every place in the code where units are used, we need to expect
a whole set of possible unit subtypes and test for the type with a case
construct?  You can write wrappers to take care of this, but it's going
to make the code much slower.  And I can't see much practical benefit:
adding a new property and associated behaviour will be *more* work than
it was before.

Are you sure this is what you intend to do?


How would this proposed inheritence system handle flying settlers?

We're not talking about a system with a fixed list of units for the ruleset to pick from (or, at least IMO, we shouldn't be). Ultimately a more flexible system that allows the ruleset to specify every property of the unit would be better. This would also allow SMAC-style units with a minimum of fuss.

jason



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