Changes in the Airstrike message handling

Eero Tamminen eero.tamminen at netsonic.fi
Thu Jan 6 17:23:34 EST 2005


Hi,

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
* 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...)

While doing this I found a very minor bug in bird.c, I hope I didn't
introduce many new ones... :-)


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 :-)).


	- Eero



More information about the airstrike mailing list