From 7c98a71c9bc37732d7c2f2c6938ee697706f33b3 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 19 Jul 2021 08:18:33 +0200 Subject: [PATCH] request_unit_load(): prepare for multiple Board. Simplify request_unit_load() by using the code that picks an embark action by action result to handle board too. At the moment "Transport Board" is the only action with that result. See osdn #42642 --- client/control.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/client/control.c b/client/control.c index a929e01510..8732f81dd5 100644 --- a/client/control.c +++ b/client/control.c @@ -2053,22 +2053,20 @@ void request_unit_load(struct unit *pcargo, struct unit *ptrans, if (ptrans && can_client_issue_orders() && could_unit_load(pcargo, ptrans)) { - if (same_pos(unit_tile(pcargo), ptile)) { - request_do_action(ACTION_TRANSPORT_BOARD, - pcargo->id, ptrans->id, 0, ""); - } else { - action_by_result_iterate(paction, act_id, ACTRES_TRANSPORT_EMBARK) { - if (action_prob_possible(action_prob_vs_unit(pcargo, paction->id, - ptrans))) { - /* Try the first action that may be legal. */ - /* Implement something like do_disband_alternative() if a ruleset - * appears where this isn't good enough. */ - request_do_action(paction->id, - pcargo->id, ptrans->id, 0, ""); - break; - } - } action_by_result_iterate_end; - } + action_by_result_iterate(paction, act_id, + same_pos(unit_tile(pcargo), ptile) + ? ACTRES_TRANSPORT_BOARD + : ACTRES_TRANSPORT_EMBARK) { + if (action_prob_possible(action_prob_vs_unit(pcargo, paction->id, + ptrans))) { + /* Try the first action that may be legal. */ + /* Implement something like do_disband_alternative() if a ruleset + * appears where this isn't good enough. */ + request_do_action(paction->id, + pcargo->id, ptrans->id, 0, ""); + break; + } + } action_by_result_iterate_end; /* Sentry the unit. */ /* FIXME: Should not sentry if above loading fails (transport moved away, -- 2.30.2