From f860b2f680c05fa233a54b5d8b8e1799a5bfed50 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 11 Jan 2023 02:17:20 +0200 Subject: [PATCH 13/13] is_action_possible(): Avoid repetative action_(id_)get_target_kind() See osdn #46487 Signed-off-by: Marko Lindqvist --- common/actions.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/common/actions.c b/common/actions.c index 6b7eaf7caa..36377b9cc3 100644 --- a/common/actions.c +++ b/common/actions.c @@ -2092,20 +2092,20 @@ is_action_possible(const action_id wanted_action, enum fc_tristate out; struct action *paction; - fc_assert_msg((action_id_get_target_kind(wanted_action) == ATK_CITY - && target_city != NULL) - || (action_id_get_target_kind(wanted_action) == ATK_TILE - && target_tile != NULL) - || (action_id_get_target_kind(wanted_action) == ATK_UNIT - && target_unit != NULL) - || (action_id_get_target_kind(wanted_action) == ATK_UNITS - /* At this level each individual unit is tested. */ - && target_unit != NULL) - || (action_id_get_target_kind(wanted_action) == ATK_SELF), - "Missing target!"); - paction = action_by_number(wanted_action); +#ifndef FREECIV_NDEBUG + enum action_target_kind tkind = action_get_target_kind(paction); +#endif + + fc_assert_msg((tkind == ATK_CITY && target_city != NULL) + || (tkind == ATK_TILE && target_tile != NULL) + || (tkind == ATK_UNIT && target_unit != NULL) + /* At this level each individual unit is tested. */ + || (tkind == ATK_UNITS && target_unit != NULL) + || (tkind == ATK_SELF), + "Missing target!"); + /* Only check requirement against the target unit if the actor can see it * or if the evaluator is omniscient. The game checking the rules is * omniscient. The player asking about his odds isn't. */ -- 2.39.0