[airstrike] Changes in the Airstrike message handling
eero.tamminen at netsonic.fi
Fri Jan 7 12:30:06 EST 2005
> > I have done the following changes in the Airstrike message handling:
> > * Sprite message handling functions return an int instead of a message
> > * AI message handling functions return an int instead of a message
> > * The new message handling return values are:
> > MSG_RET_UNKNOWN = 0,
> > MSG_RET_ACK,
> > MSG_RET_YES,
> > MSG_RET_NO
> Maybe YES and ACK can be unified to YES?
I think of them as semantically slightly different:
- ACK is an acknowledgment of understanding/handling of a message
- YES is a reply to request about a capability
Hm. It might be good to emphatize this somehow. For now I'll just have the
capability messages grouped in the list of messages enums and add some
comments about handling them to the msg_types.h header.
> > * Corresponding message functions have now been removed
> > (msg_unknown() has been replaced with msg_none() for the scheduler)
> > * I've replaced the msg_ask() and msg_is_true() message functions with
> > a single sprite_ask() function for querying about sprite
> > capabilities. It will ask the sprite (e.g. MSG_HAS_AI,
> > MSG_ACCEPT_BONUSES) and will check whether the return value is
> > MSG_RET_YES. It's currently in msg_types.h, but might be moved to
> > sprite.h (except that it knowns about message internals...)
Basically YES & NO should be used only as return values for sprite_ask()
I think, or did you have some other use for them?
> > Now, if one wants to query e.g. biplane for it's target (which will in
> > turn ask it's AI for that information), there needs to be a new
> > messages like: msg_t msg_set_target_pointer(sprite_t **target);
> > sprite_t **msg_get_target_pointer(msg_t msg);
> > The caller getting it's pointer back modified (to point to the target)
> > should then do referencing etc. required stuff.
> > The reason for this change is that this way we don't get dangling
> > pointers so easily or at least it will be a bit more explicit (you have
> > a specific message for it :-)).
> Yup, I think this is the right way. I will start adding and fixing
> stuff on sunday.
> I will probably be in #airstrike on irc.freenode.net if anyone likes to
> join in.
More information about the airstrike