From f1c30e83e39f1543e7dd48bd31831b4d6631168f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 23 Apr 2023 01:14:01 +0300 Subject: [PATCH 29/29] Don't send internal actions to client User/client will not be able to initiate those actions, so don't present them in the UI. See osdn #47903 Signed-off-by: Marko Lindqvist --- common/actions.h | 11 +++++++++++ server/unithand.c | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/common/actions.h b/common/actions.h index 95c6ae287a..9b23b1b930 100644 --- a/common/actions.h +++ b/common/actions.h @@ -429,6 +429,17 @@ struct action_enabler } \ } +/* TODO: Turn this to an iteration over precalculated list */ +#define action_noninternal_iterate(_act_) \ +{ \ + action_iterate(_act_) { \ + if (!action_id_is_internal(_act_)) { + +#define action_noninternal_iterate_end \ + } \ + } action_iterate_end; \ +} + #define action_by_result_iterate(_paction_, _act_id_, _result_) \ { \ action_iterate(_act_id_) { \ diff --git a/server/unithand.c b/server/unithand.c index 3d70ca4c9a..50f0b3e469 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -2299,7 +2299,7 @@ void handle_unit_get_actions(struct connection *pc, /* Find out what can be done to the targets. */ /* Set the probability for the actions. */ - action_iterate(act) { + action_noninternal_iterate(act) { if (action_id_get_actor_kind(act) != AAK_UNIT) { /* Not relevant. */ continue; @@ -2389,11 +2389,11 @@ void handle_unit_get_actions(struct connection *pc, probabilities[act] = ACTPROB_IMPOSSIBLE); break; } - } action_iterate_end; + } action_noninternal_iterate_end; /* Analyze the probabilities. Decide what targets to send and if an * explanation is needed. */ - action_iterate(act) { + action_noninternal_iterate(act) { if (action_prob_possible(probabilities[act])) { /* An action can be done. No need to explain why no action can be * done. */ @@ -2447,7 +2447,7 @@ void handle_unit_get_actions(struct connection *pc, break; } } - } action_iterate_end; + } action_noninternal_iterate_end; /* Send possible actions and targets. */ dsend_packet_unit_actions(pc, -- 2.39.2