From fd0e3230f6771abce0eb6e885bd1a352c4047665 Mon Sep 17 00:00:00 2001 From: dark-ether Date: Fri, 11 Mar 2022 20:36:54 -0300 Subject: [PATCH 1/2] used sed and ripgrep to change all ocurrences of action_list and act_list to action_group and act_group to allow the future creation of a action speclist --- ai/default/daicity.c | 8 ++++---- client/helpdata.c | 10 +++++----- client/packhand.c | 12 ++++++------ common/actions.c | 14 +++++++------- common/actions.h | 14 +++++++------- common/unit.h | 6 +++--- server/advisors/advdata.c | 14 +++++++------- server/advisors/autosettlers.c | 24 ++++++++++++------------ server/advisors/autosettlers.h | 12 ++++++------ server/ruleset.c | 6 +++--- server/savegame/savecompat.c | 4 ++-- tools/ruleutil/rulesave.c | 8 ++++---- 12 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ai/default/daicity.c b/ai/default/daicity.c index 577aef20a9..1211ac3873 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_group_add_all_by_result(upgrade_actions, &i, ACTRES_UPGRADE_UNIT); + action_group_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_group_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_group_iterate_end; } } unit_list_iterate_end; } diff --git a/client/helpdata.c b/client/helpdata.c index f9929e8005..79768f2975 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -1339,18 +1339,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_group_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); + action_group_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); - action_list_end(nuke_actions, i); + action_group_end(nuke_actions, i); } - action_list_iterate(nuke_actions, act_id) { + action_group_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_group_iterate_end; if (u) { cat_snprintf(buf, bufsz, diff --git a/client/packhand.c b/client/packhand.c index db4f14b394..c63640bb3b 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -1637,7 +1637,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_group_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. */ @@ -1649,7 +1649,7 @@ static void action_decision_handle(struct unit *punit) REQEST_BACKGROUND_FAST_AUTO_ATTACK); return; } - } action_list_iterate_end; + } action_group_iterate_end; } /* This should be done in the foreground */ @@ -4885,7 +4885,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_group_iterate(auto_attack_actions, act_id) { if (action_prob_possible(act_probs[act_id])) { /* An attack. */ if (attack_action == ACTION_NONE) { @@ -4896,13 +4896,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_group_iterate_end; + action_group_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_group_iterate_end; return attack_action; } diff --git a/common/actions.c b/common/actions.c index 602a0cc31e..8c8a360c02 100644 --- a/common/actions.c +++ b/common/actions.c @@ -7477,27 +7477,27 @@ bool action_univs_not_blocking(const struct action *paction, /**********************************************************************//** Terminate an action list of the specified size. - @param act_list the list to end + @param act_group the list 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_group_end(action_id *act_group, 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; + act_group[size] = ACTION_NONE; } } /**********************************************************************//** Add all actions with the specified result to the specified action list 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_group the list to add the actions to + @param position index in act_group 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_group_add_all_by_result(action_id *act_group, int *position, enum action_result result) { @@ -7507,7 +7507,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_group[(*position)++] = paction->id; } } action_iterate_end; } diff --git a/common/actions.h b/common/actions.h index 0b524636ba..ed6fa57260 100644 --- a/common/actions.h +++ b/common/actions.h @@ -505,19 +505,19 @@ struct action_enabler } action_iterate_end; \ } -#define action_list_iterate(_act_list_, _act_id_) \ +#define action_group_iterate(_act_group_, _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_group_[_pos_]; \ \ if (_act_id_ == ACTION_NONE) { \ /* No more actions in this list. */ \ break; \ } -#define action_list_iterate_end \ +#define action_group_iterate_end \ } \ } @@ -608,10 +608,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_group_iterate(_autoperf_->alternatives, _act_id_) #define action_auto_perf_actions_iterate_end \ - action_list_iterate_end + action_group_iterate_end /* Hard coded location of action auto performers. Used for conversion while * action auto performers aren't directly exposed to the ruleset. */ @@ -948,8 +948,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_group_end(action_id *act_group, int size); +void action_group_add_all_by_result(action_id *act_group, int *position, enum action_result result); diff --git a/common/unit.h b/common/unit.h index 74c851d893..e082bb2521 100644 --- a/common/unit.h +++ b/common/unit.h @@ -272,11 +272,11 @@ bool is_real_activity(enum unit_activity activity); extern Activity_type_id real_activities[ACTIVITY_LAST]; -#define activity_type_list_iterate(_act_list_, _act_) \ +#define activity_type_list_iterate(_act_group_, _act_) \ { \ int _act_i_; \ - for (_act_i_ = 0; _act_list_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \ - Activity_type_id _act_ = _act_list_[_act_i_]; + for (_act_i_ = 0; _act_group_[_act_i_] != ACTIVITY_LAST; _act_i_++) { \ + Activity_type_id _act_ = _act_group_[_act_i_]; #define activity_type_list_iterate_end \ } \ diff --git a/server/advisors/advdata.c b/server/advisors/advdata.c index 0d8943e44f..b0de1dcca7 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_group_add_all_by_result(nuke_actions, &i, ACTRES_NUKE); + action_group_add_all_by_result(nuke_actions, &i, ACTRES_NUKE_UNITS); /* TODO: worry about spy nuking too? */ - action_list_end(nuke_actions, i); + action_group_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_group_iterate(nuke_actions, act_id) { if (unit_can_do_action(punit, act_id)) { danger_of_nukes = TRUE; } - } action_list_iterate_end; + } action_group_iterate_end; } unit_list_iterate_end; /* Check for nuke capability */ - action_list_iterate(nuke_actions, act_id) { + action_group_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_group_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 b0eca1ce0c..d867da95b9 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_group_add_all_by_result(as_actions_transform, &i, ACTRES_CULTIVATE); - action_list_add_all_by_result(as_actions_transform, &i, + action_group_add_all_by_result(as_actions_transform, &i, ACTRES_PLANT); - action_list_add_all_by_result(as_actions_transform, &i, + action_group_add_all_by_result(as_actions_transform, &i, ACTRES_TRANSFORM_TERRAIN); - action_list_end(as_actions_transform, i); + action_group_end(as_actions_transform, i); i = 0; - action_list_add_all_by_result(as_actions_extra, &i, + action_group_add_all_by_result(as_actions_extra, &i, ACTRES_IRRIGATE); - action_list_add_all_by_result(as_actions_extra, &i, + action_group_add_all_by_result(as_actions_extra, &i, ACTRES_MINE); - action_list_add_all_by_result(as_actions_extra, &i, + action_group_add_all_by_result(as_actions_extra, &i, ACTRES_ROAD); - action_list_add_all_by_result(as_actions_extra, &i, + action_group_add_all_by_result(as_actions_extra, &i, ACTRES_BASE); - action_list_end(as_actions_extra, i); + action_group_end(as_actions_extra, i); i = 0; - action_list_add_all_by_result(as_actions_rmextra, &i, + action_group_add_all_by_result(as_actions_rmextra, &i, ACTRES_CLEAN_POLLUTION); - action_list_add_all_by_result(as_actions_rmextra, &i, + action_group_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_group_end(as_actions_rmextra, i); } /**********************************************************************//** diff --git a/server/advisors/autosettlers.h b/server/advisors/autosettlers.h index 3933b8fa5d..dbccb21063 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_group_iterate(as_actions_transform, _act_) #define as_transform_action_iterate_end \ - action_list_iterate_end \ + action_group_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_group_iterate(as_actions_extra, _act_) #define as_extra_action_iterate_end \ - action_list_iterate_end \ + action_group_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_group_iterate(as_actions_rmextra, _act_) #define as_rmextra_action_iterate_end \ - action_list_iterate_end \ + action_group_iterate_end \ } #endif /* FC__AUTOSETTLERS_H */ diff --git a/server/ruleset.c b/server/ruleset.c index aaaa41461e..edbaf15e9d 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -6220,7 +6220,7 @@ static bool load_action_post_success_force(struct section_file *file, struct action *paction) { struct action_auto_perf *auto_perf; - char action_list_path[100]; + char action_group_path[100]; if (action_post_success_forced_ruleset_var_name(paction) == NULL) { /* Not relevant. */ @@ -6237,11 +6237,11 @@ static bool load_action_post_success_force(struct section_file *file, paction->id)); /* Load the list of actions. */ - fc_snprintf(action_list_path, sizeof(action_list_path), + fc_snprintf(action_group_path, sizeof(action_group_path), "actions.%s", action_post_success_forced_ruleset_var_name(paction)); if (!load_action_auto_actions(file, auto_perf, - action_list_path, filename)) { + action_group_path, filename)) { return FALSE; } diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 9b0eeb5326..a1380857e1 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -1527,7 +1527,7 @@ static void compat_load_030100(struct loaddata *loading, plrno, unit); if ((action_unitstr = secfile_lookup_str_default(loading->file, "", - "player%d.u%d.action_list", + "player%d.u%d.action_group", plrno, unit))) { int order_num; @@ -2147,7 +2147,7 @@ static void compat_load_dev(struct loaddata *loading) plrno, unit); if ((action_unitstr = secfile_lookup_str_default(loading->file, "", - "player%d.u%d.action_list", + "player%d.u%d.action_group", plrno, unit))) { int order_num; diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 49e8ddaaec..44b8759cc8 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -584,7 +584,7 @@ static bool save_action_auto_actions(struct section_file *sfile, j++; } - action_list_end((action_id *)unit_acts, j); + action_group_end((action_id *)unit_acts, j); ret = secfile_insert_enum_vec(sfile, &unit_acts, j, gen_action, "%s", actions_path); @@ -972,7 +972,7 @@ static bool save_action_post_success_force(struct section_file *sfile, int performer_slot, struct action *paction) { - char action_list_path[100]; + char action_group_path[100]; if (action_post_success_forced_ruleset_var_name(paction) == NULL) { /* Not relevant. */ @@ -984,10 +984,10 @@ static bool save_action_post_success_force(struct section_file *sfile, return TRUE; } - fc_snprintf(action_list_path, sizeof(action_list_path), + fc_snprintf(action_group_path, sizeof(action_group_path), "actions.%s", action_post_success_forced_ruleset_var_name(paction)); - if (!save_action_auto_actions(sfile, performer_slot, action_list_path)) { + if (!save_action_auto_actions(sfile, performer_slot, action_group_path)) { return FALSE; } -- 2.35.1