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

[Freeciv-Dev] unit flags/capabilities

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] unit flags/capabilities
From: Andrew Sutton <ansutton@xxxxxxx>
Date: Wed, 28 Nov 2001 15:59:47 -0500

all,

i've been looking over the framework for identifying units and unit 
capabilities, it looks a little clumsy. part of it seems to specify a generic 
unit type, the other seems to specify capabilties of some kind. so i'm 
writing down an idea to extend and organize the unit_flag_id enum.

it seems to me that there are several ways to identify and group units. 
clearly you want to be able to define a generic unit that subscribes to one 
or more aspects defined in the unit_flag_structure, but you're almost out of 
the 32 bit limit. uppling the enum to an unsigned long long and redefining 
the values may help but it isn't very graceful.

one aspect you want to be identify is the classification of unit for combat:
        - defenseless
        - horse
        - pikement
        - marines
        - etc..

another aspect is the military capability (attacks):
        - single attack
        - bombard
        - nuke
        - bomb
        - air attack
        - etc.

then there's non-military capabilities:
        - build city
        - build fortress
        - build airbase
        - irrigate
        - mine
        - etc.

also, other modules may want to add their own categories (magic maybe?) so it 
would be appropriate to allow for easy flexibility aggregating new flag 
values into definition.

based on this differentiation of information, it seems like it might be a 
good idea to define a unit flag as an array of unsigned integers where the 
index into the array defines the category and the the unsigned integer 
defines a value set within the array. actual values should be either #defined 
of static const's.

now if you need more individual flag space, you're options are to a) extend 
the defintion to an unsigned long long for 64 bits of flags or b) add a new 
category.

so you're structure would be this:
#define UNIT_FLAG_CATEGORIES_MAX
typedef unsigned [ UNIT_FLAG_CATEGORIES_MAX ] *unit_class_id;

it'd take a considerable amount of patching to work the changes back to the 
server and client, but IMHO i think it's not a bad idea.

thoughts?

andy


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