Author: sveinung Date: Sat Oct 15 22:44:35 2016 New Revision: 34148 URL: http://svn.gna.org/viewcvs/freeciv?rev=34148&view=rev Log: Introduce action_[id_]has_result().
At the moment an action's result is the same as its action id. Make it possible to write code that checks an action's result without relying on its action id. See patch #7820 Modified: trunk/common/actions.c trunk/common/actions.h Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34148&r1=34147&r2=34148&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Sat Oct 15 22:44:35 2016 @@ -654,6 +654,16 @@ } /************************************************************************** + Returns TRUE iff performing the specified action has the specified + result. +**************************************************************************/ +bool action_has_result(struct action *paction, enum gen_action result) +{ + /* The action result is currently used as the action id. */ + return paction->id == result; +} + +/************************************************************************** Returns TRUE iff the specified action is hostile. **************************************************************************/ bool action_is_hostile(int action_id) Modified: trunk/common/actions.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=34148&r1=34147&r2=34148&view=diff ============================================================================== --- trunk/common/actions.h (original) +++ trunk/common/actions.h Sat Oct 15 22:44:35 2016 @@ -317,6 +317,10 @@ int action_number(const struct action *action); +bool action_has_result(struct action *paction, enum gen_action result); +#define action_id_has_result(action_id, result) \ + action_has_result(action_by_number(action_id), result) + bool action_is_hostile(int action_id); bool action_requires_details(int action_id); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits