From 9db5667cd383223104f4749226b8422592a6d154 Mon Sep 17 00:00:00 2001 From: dark-ether Date: Tue, 19 Jul 2022 16:56:24 -0300 Subject: [PATCH] renamed action list to action array, changed the comments and functions to reflect this --- ai/default/daicity.c | 8 ++++---- client/helpdata.c | 10 +++++----- client/packhand.c | 12 ++++++------ common/actions.c | 20 ++++++++++---------- common/actions.h | 14 +++++++------- server/advisors/advdata.c | 14 +++++++------- server/advisors/autosettlers.c | 24 ++++++++++++------------ server/advisors/autosettlers.h | 12 ++++++------ tools/ruleutil/rulesave.c | 2 +- 9 files changed, 58 insertions(+), 58 deletions(-) diff --git a/ai/default/daicity.c b/ai/default/daicity.c index 14a4dc5158..87a091a4d6 100644 --- a/ai/default/daicity.c +++ b/ai/default/daicity.c @@ -387,8 +387,8 @@ static void dai_upgrade_units(struct city *pcity, int limit, bool military) { /* Find upgrade unit actions */ int i = 0; - action_list_add_all_by_result(upgrade_actions, &i, ACTRES_UPGRADE_UNIT); - action_list_end(upgrade_actions, i); + action_array_add_all_by_result(upgrade_actions, &i, ACTRES_UPGRADE_UNIT); + action_array_end(upgrade_actions, i); } dai_calc_data(pplayer, NULL, &expenses, NULL); @@ -412,7 +412,7 @@ static void dai_upgrade_units(struct city *pcity, int limit, bool military) continue; } - action_list_iterate(upgrade_actions, act_id) { + action_array_iterate(upgrade_actions, act_id) { if (action_ever_possible(act_id)) { const struct action *paction = action_by_number(act_id); int cost = unit_upgrade_price(pplayer, old_type, punittype); @@ -438,7 +438,7 @@ static void dai_upgrade_units(struct city *pcity, int limit, bool military) increase_maxbuycost(pplayer, cost); } } - } action_list_iterate_end; + } action_array_iterate_end; } } unit_list_iterate_end; } diff --git a/client/helpdata.c b/client/helpdata.c index b08759ae07..212705ddae 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -1349,18 +1349,18 @@ char *helptext_building(char *buf, size_t bufsz, struct player *pplayer, /* Find Manhattan dependent nuke actions */ int i = 0; - action_list_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); - action_list_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); + action_array_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); + action_array_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); - action_list_end(nuke_actions, i); + action_array_end(nuke_actions, i); } - action_list_iterate(nuke_actions, act_id) { + action_array_iterate(nuke_actions, act_id) { if (num_role_units(action_id_get_role(act_id)) > 0) { u = get_role_unit(action_id_get_role(act_id), 0); break; } - } action_list_iterate_end; + } action_array_iterate_end; if (u) { struct advance *req = NULL; diff --git a/client/packhand.c b/client/packhand.c index 0233757304..8aa6c61860 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -1638,7 +1638,7 @@ void handle_unit_info(const struct packet_unit_info *packet) static void action_decision_handle(struct unit *punit) { if (!gui_options.popup_attack_actions) { - action_list_iterate(auto_attack_actions, act_id) { + action_array_iterate(auto_attack_actions, act_id) { if (utype_can_do_action(unit_type_get(punit), act_id)) { /* An auto action like auto attack could be legal. Check for those * at once so they won't have to wait for player focus. */ @@ -1650,7 +1650,7 @@ static void action_decision_handle(struct unit *punit) REQEST_BACKGROUND_FAST_AUTO_ATTACK); return; } - } action_list_iterate_end; + } action_array_iterate_end; } /* This should be done in the foreground */ @@ -4891,7 +4891,7 @@ static action_id auto_attack_act(const struct act_prob *act_probs) { action_id attack_action = ACTION_NONE; - action_list_iterate(auto_attack_actions, act_id) { + action_array_iterate(auto_attack_actions, act_id) { if (action_prob_possible(act_probs[act_id])) { /* An attack. */ if (attack_action == ACTION_NONE) { @@ -4902,13 +4902,13 @@ static action_id auto_attack_act(const struct act_prob *act_probs) return ACTION_NONE; } } - } action_list_iterate_end; - action_list_iterate(auto_attack_blockers, act_id) { + } action_array_iterate_end; + action_array_iterate(auto_attack_blockers, act_id) { if (action_prob_possible(act_probs[act_id])) { /* An interesting non attack action has been found. */ return ACTION_NONE; } - } action_list_iterate_end; + } action_array_iterate_end; return attack_action; } diff --git a/common/actions.c b/common/actions.c index e764634828..491b8643cc 100644 --- a/common/actions.c +++ b/common/actions.c @@ -7473,28 +7473,28 @@ bool action_univs_not_blocking(const struct action *paction, } /**********************************************************************//** - Terminate an action list of the specified size. - @param act_list the list to end + Terminate an action array of the specified size. + @param act_array the array to end @param size the number of elements to include in the list **************************************************************************/ -void action_list_end(action_id *act_list, int size) +void action_array_end(action_id *act_array, int size) { fc_assert_ret(size <= MAX_NUM_ACTIONS); if (size < MAX_NUM_ACTIONS) { - /* An action list is terminated by ACTION_NONE */ - act_list[size] = ACTION_NONE; + /* An action array is terminated by ACTION_NONE */ + act_array[size] = ACTION_NONE; } } /**********************************************************************//** - Add all actions with the specified result to the specified action list + Add all actions with the specified result to the specified action array starting at the specified position. - @param act_list the list to add the actions to - @param position index in act_list that is updated as action are added + @param act_array the array to add the actions to + @param position index in act_array that is updated as action are added @param result all actions with this result are added. **************************************************************************/ -void action_list_add_all_by_result(action_id *act_list, +void action_array_add_all_by_result(action_id *act_array, int *position, enum action_result result) { @@ -7504,7 +7504,7 @@ void action_list_add_all_by_result(action_id *act_list, /* Assume one result for each action. */ fc_assert_ret(*position < MAX_NUM_ACTIONS); - act_list[(*position)++] = paction->id; + act_array[(*position)++] = paction->id; } } action_iterate_end; } diff --git a/common/actions.h b/common/actions.h index 7f3795ac7f..fc24dd98f1 100644 --- a/common/actions.h +++ b/common/actions.h @@ -510,19 +510,19 @@ struct action_enabler } action_iterate_end; \ } -#define action_list_iterate(_act_list_, _act_id_) \ +#define action_array_iterate(_act_array_, _act_id_) \ { \ int _pos_; \ \ for (_pos_ = 0; _pos_ < NUM_ACTIONS; _pos_++) { \ - const action_id _act_id_ = _act_list_[_pos_]; \ + const action_id _act_id_ = _act_array_[_pos_]; \ \ if (_act_id_ == ACTION_NONE) { \ /* No more actions in this list. */ \ break; \ } -#define action_list_iterate_end \ +#define action_array_iterate_end \ } \ } @@ -613,10 +613,10 @@ action_auto_perf_iterate(_act_perf_) { \ } action_auto_perf_iterate_end #define action_auto_perf_actions_iterate(_autoperf_, _act_id_) \ - action_list_iterate(_autoperf_->alternatives, _act_id_) + action_array_iterate(_autoperf_->alternatives, _act_id_) #define action_auto_perf_actions_iterate_end \ - action_list_iterate_end + action_array_iterate_end /* Hard coded location of action auto performers. Used for conversion while * action auto performers aren't directly exposed to the ruleset. */ @@ -952,8 +952,8 @@ bool action_mp_full_makes_legal(const struct unit *actor, bool action_is_in_use(struct action *paction); /* Action lists */ -void action_list_end(action_id *act_list, int size); -void action_list_add_all_by_result(action_id *act_list, +void action_array_end(action_id *act_array, int size); +void action_array_add_all_by_result(action_id *act_array, int *position, enum action_result result); diff --git a/server/advisors/advdata.c b/server/advisors/advdata.c index ad89b95209..519bb1876e 100644 --- a/server/advisors/advdata.c +++ b/server/advisors/advdata.c @@ -269,10 +269,10 @@ bool adv_data_phase_init(struct player *pplayer, bool is_new_phase) int i = 0; /* Conventional nukes */ - action_list_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); - action_list_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); + action_array_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); + action_array_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); /* TODO: worry about spy nuking too? */ - action_list_end(nuke_actions, i); + action_array_end(nuke_actions, i); } fc_assert_ret_val(adv != NULL, FALSE); @@ -364,15 +364,15 @@ bool adv_data_phase_init(struct player *pplayer, bool is_new_phase) } /* If they build nukes, worry a lot. */ - action_list_iterate(nuke_actions, act_id) { + action_array_iterate(nuke_actions, act_id) { if (unit_can_do_action(punit, act_id)) { danger_of_nukes = TRUE; } - } action_list_iterate_end; + } action_array_iterate_end; } unit_list_iterate_end; /* Check for nuke capability */ - action_list_iterate(nuke_actions, act_id) { + action_array_iterate(nuke_actions, act_id) { int i; int nuke_units = num_role_units(action_id_get_role(act_id)); @@ -384,7 +384,7 @@ bool adv_data_phase_init(struct player *pplayer, bool is_new_phase) adv->threats.nuclear = 1; } } - } action_list_iterate_end; + } action_array_iterate_end; } players_iterate_end; /* Increase from fear to terror if opponent actually has nukes */ diff --git a/server/advisors/autosettlers.c b/server/advisors/autosettlers.c index 82b3358eed..244b956373 100644 --- a/server/advisors/autosettlers.c +++ b/server/advisors/autosettlers.c @@ -96,32 +96,32 @@ void auto_settlers_ruleset_init(void) int i; i = 0; - action_list_add_all_by_result(as_actions_transform, &i, + action_array_add_all_by_result(as_actions_transform, &i, ACTRES_CULTIVATE); - action_list_add_all_by_result(as_actions_transform, &i, + action_array_add_all_by_result(as_actions_transform, &i, ACTRES_PLANT); - action_list_add_all_by_result(as_actions_transform, &i, + action_array_add_all_by_result(as_actions_transform, &i, ACTRES_TRANSFORM_TERRAIN); - action_list_end(as_actions_transform, i); + action_array_end(as_actions_transform, i); i = 0; - action_list_add_all_by_result(as_actions_extra, &i, + action_array_add_all_by_result(as_actions_extra, &i, ACTRES_IRRIGATE); - action_list_add_all_by_result(as_actions_extra, &i, + action_array_add_all_by_result(as_actions_extra, &i, ACTRES_MINE); - action_list_add_all_by_result(as_actions_extra, &i, + action_array_add_all_by_result(as_actions_extra, &i, ACTRES_ROAD); - action_list_add_all_by_result(as_actions_extra, &i, + action_array_add_all_by_result(as_actions_extra, &i, ACTRES_BASE); - action_list_end(as_actions_extra, i); + action_array_end(as_actions_extra, i); i = 0; - action_list_add_all_by_result(as_actions_rmextra, &i, + action_array_add_all_by_result(as_actions_rmextra, &i, ACTRES_CLEAN_POLLUTION); - action_list_add_all_by_result(as_actions_rmextra, &i, + action_array_add_all_by_result(as_actions_rmextra, &i, ACTRES_CLEAN_FALLOUT); /* We could have ACTRES_PILLAGE here, but currently we don't */ - action_list_end(as_actions_rmextra, i); + action_array_end(as_actions_rmextra, i); } /**********************************************************************//** diff --git a/server/advisors/autosettlers.h b/server/advisors/autosettlers.h index 3933b8fa5d..84ca4fad10 100644 --- a/server/advisors/autosettlers.h +++ b/server/advisors/autosettlers.h @@ -69,30 +69,30 @@ extern action_id as_actions_transform[MAX_NUM_ACTIONS]; #define as_transform_action_iterate(_act_) \ { \ - action_list_iterate(as_actions_transform, _act_) + action_array_iterate(as_actions_transform, _act_) #define as_transform_action_iterate_end \ - action_list_iterate_end \ + action_array_iterate_end \ } extern action_id as_actions_extra[MAX_NUM_ACTIONS]; #define as_extra_action_iterate(_act_) \ { \ - action_list_iterate(as_actions_extra, _act_) + action_array_iterate(as_actions_extra, _act_) #define as_extra_action_iterate_end \ - action_list_iterate_end \ + action_array_iterate_end \ } extern action_id as_actions_rmextra[MAX_NUM_ACTIONS]; #define as_rmextra_action_iterate(_act_) \ { \ - action_list_iterate(as_actions_rmextra, _act_) + action_array_iterate(as_actions_rmextra, _act_) #define as_rmextra_action_iterate_end \ - action_list_iterate_end \ + action_array_iterate_end \ } #endif /* FC__AUTOSETTLERS_H */ diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 7c09297100..6370349374 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -586,7 +586,7 @@ static bool save_action_auto_actions(struct section_file *sfile, j++; } - action_list_end((action_id *)unit_acts, j); + action_array_end((action_id *)unit_acts, j); ret = secfile_insert_enum_vec(sfile, &unit_acts, j, gen_action, "%s", actions_path); -- 2.37.1