From 7a03496480c6bbc408ee4d1fc6e222be1e1a8939 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Wed, 10 Feb 2021 09:32:46 +0100 Subject: [PATCH] action_auto_perf_unit_*(): support action reqs. Support checking action requirements in the action auto performer requirement vector. This makes it possible to choose action auto performer based on action. See osdn #41537 --- server/actiontools.c | 17 +++++++++++------ server/actiontools.h | 9 ++++++--- server/cityturn.c | 4 ++-- server/unittools.c | 6 +++--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/server/actiontools.c b/server/actiontools.c index 31b7e8b4f0..223fe445f4 100644 --- a/server/actiontools.c +++ b/server/actiontools.c @@ -934,13 +934,14 @@ const struct action_auto_perf * action_auto_perf_unit_sel(const enum action_auto_perf_cause cause, const struct unit *actor, const struct player *other_player, - const struct output_type *output) + const struct output_type *eval_output, + const struct action *eval_action) { action_auto_perf_by_cause_iterate(cause, autoperformer) { if (are_reqs_active(unit_owner(actor), other_player, NULL, NULL, unit_tile(actor), actor, unit_type_get(actor), - output, NULL, NULL, + eval_output, NULL, eval_action, &autoperformer->reqs, RPT_CERTAIN)) { /* Select this action auto performer. */ return autoperformer; @@ -975,7 +976,8 @@ const struct action * action_auto_perf_unit_do(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, - const struct output_type *output, + const struct output_type *eval_output, + const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, @@ -988,7 +990,8 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause, const struct unit *tgt_unit; const struct action_auto_perf *autoperf - = action_auto_perf_unit_sel(cause, actor, other_player, output); + = action_auto_perf_unit_sel(cause, actor, other_player, + eval_output, eval_action); if (!autoperf) { /* No matching Action Auto Performer. */ @@ -1073,7 +1076,8 @@ struct act_prob action_auto_perf_unit_prob(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, - const struct output_type *output, + const struct output_type *eval_output, + const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, @@ -1086,7 +1090,8 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause, const struct unit *tgt_unit; const struct action_auto_perf *autoperf - = action_auto_perf_unit_sel(cause, actor, other_player, output); + = action_auto_perf_unit_sel(cause, actor, other_player, + eval_output, eval_action); if (!autoperf) { /* No matching Action Auto Performer. */ diff --git a/server/actiontools.h b/server/actiontools.h index 0f078cf749..ceecb4c6f8 100644 --- a/server/actiontools.h +++ b/server/actiontools.h @@ -66,13 +66,15 @@ const struct action_auto_perf * action_auto_perf_unit_sel(const enum action_auto_perf_cause cause, const struct unit *actor, const struct player *other_player, - const struct output_type *output); + const struct output_type *eval_output, + const struct action *eval_action); const struct action * action_auto_perf_unit_do(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, - const struct output_type *output, + const struct output_type *eval_output, + const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, @@ -82,7 +84,8 @@ struct act_prob action_auto_perf_unit_prob(const enum action_auto_perf_cause cause, struct unit *actor, const struct player *other_player, - const struct output_type *output, + const struct output_type *eval_output, + const struct action *eval_action, const struct tile *target_tile, const struct city *target_city, const struct unit *target_unit, diff --git a/server/cityturn.c b/server/cityturn.c index 80bc96f8a7..689a7f498e 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -702,7 +702,7 @@ static bool upkeep_kill_unit(struct unit *punit, Output_type_id outp, int punit_id; if (!action_auto_perf_unit_sel(AAPC_UNIT_UPKEEP, punit, - NULL, get_output_type(outp))) { + NULL, get_output_type(outp), NULL)) { /* Can't get rid of this unit. It is undisbandable for the current * situation. */ return FALSE; @@ -712,7 +712,7 @@ static bool upkeep_kill_unit(struct unit *punit, Output_type_id outp, /* Try to perform this unit's can't upkeep actions. */ action_auto_perf_unit_do(AAPC_UNIT_UPKEEP, punit, - NULL, get_output_type(outp), + NULL, get_output_type(outp), NULL, NULL, NULL, NULL, NULL); if (wipe_in_the_end && unit_is_alive(punit_id)) { diff --git a/server/unittools.c b/server/unittools.c index 37c276a802..a141bb7000 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -3176,7 +3176,7 @@ static bool unit_survive_autoattack(struct unit *punit) probability->prob = action_auto_perf_unit_prob(AAPC_UNIT_MOVED_ADJ, - penemy, unit_owner(punit), NULL, + penemy, unit_owner(punit), NULL, NULL, tgt_tile, tile_city(tgt_tile), punit, NULL); @@ -3220,7 +3220,7 @@ static bool unit_survive_autoattack(struct unit *punit) /* Previous attacks may have changed the odds. Recalculate. */ peprob->prob = action_auto_perf_unit_prob(AAPC_UNIT_MOVED_ADJ, - penemy, unit_owner(punit), NULL, + penemy, unit_owner(punit), NULL, NULL, tgt_tile, tile_city(tgt_tile), punit, NULL); @@ -3245,7 +3245,7 @@ static bool unit_survive_autoattack(struct unit *punit) unit_activity_handling(penemy, ACTIVITY_IDLE); action_auto_perf_unit_do(AAPC_UNIT_MOVED_ADJ, - penemy, unit_owner(punit), NULL, + penemy, unit_owner(punit), NULL, NULL, tgt_tile, tile_city(tgt_tile), punit, NULL); } else { #ifdef REALLY_DEBUG_THIS -- 2.20.1