[airstrike] Re: Goal oriented gameplay (was: generators, triggers and aiming)
Eero Tamminen
eero.tamminen at netsonic.fi
Tue Jan 11 14:06:08 EST 2005
Hi,
> > * Add types to objects:
> > - Member for the object type
> > - Parent link that points to parent object type
> > - Helper function that traverses the type tree to root and checks
> > whether object or it's parent type had requested type
>
> I have checked in my solution to this to src/core/object.[ch]. It's
> not used anywhere
> yet though. I solved the typechecking with the function
>
> void *obj_ref(void *object, object_type_t *assumed_type);
>
> which must be used to take a reference to an object. This function may
> check if the object is of the assumed type (or inherits from that type).
I guess it calls something like:
void *obj_check_type(void *object, object_type_t *assumed_type);
Which asserts or sigsegvs if type doesn't match.
Without debug the function would be just:
#define obj_type_check(obj, type) (obj)
I guess this function would be used in all of these:
- ref
- deref
- refkill
And all the sprite specific cast macros?
We could do something like this in e.g. sprites/biplane.c and other sprites:
---------------------
#define BIPLANE(obj) ((struct biplane *)obj_type_check(obj, biplane_type))
static msgret sigget(void *s, msg_t msg)
{
struct biplane *bs = BIPLANE(s);
----------------
For base sprite and mech types there should be similar casts.
These casts should be used everywhere instead of non-checking C casts
(I can add this to my TODO once we've agreed on this and the functions are
there).
> > * Note: Sprite capabilities and attribute checks are handled with
> > messages (e.g. MSG_IS_WALKING). This is needed by triggers
>
> We could also use the (currently underused) enum sprite_flags field
> of each sprite. Currently it has only one bit used.
Heh, I would assume 31 flags to be more than enough for the whole game. :)
I'll add to my todo moving the HAS_AI etc. messages using sprite flags
instead as that will save the function call (sprite_ask is already inline).
- Eero
More information about the airstrike
mailing list