Project

General

Profile

Feature #1091 ยป 0075-Add-support-for-dummy-action-sections-in-actions.rul.patch

Marko Lindqvist, 11/09/2024 04:10 PM

View differences:

common/actions.c
action = fc_malloc(sizeof(*action));
action->id = id;
action->configured = FALSE;
action->result = result;
common/actions.h
struct action
{
action_id id;
bool configured;
enum action_result result;
bv_action_sub_results sub_results;
server/ruleset/ruleload.c
#define ACHIEVEMENT_SECTION_PREFIX "achievement_"
#define ENABLER_SECTION_PREFIX "enabler_"
#define ACTION_ENABLER_SECTION_PREFIX "actionenabler_"
#define ACTION_SECTION_PREFIX "action_"
#define MULTIPLIER_SECTION_PREFIX "multiplier_"
#define COUNTER_SECTION_PREFIX "counter_"
......
}
if (ok) {
sec = secfile_sections_by_name_prefix(file,
ENABLER_SECTION_PREFIX);
sec = secfile_sections_by_name_prefix(file, ACTION_SECTION_PREFIX);
if (sec != nullptr) {
section_list_iterate(sec, psection) {
const char *sec_name = section_name(psection);
const char *action_text;
struct action *paction;
action_text = secfile_lookup_str(file, "%s.action", sec_name);
if (action_text == nullptr) {
ruleset_error(nullptr, LOG_ERROR,
"\"%s\" [%s] missing action to configure.",
filename, sec_name);
ok = FALSE;
break;
}
paction = action_by_rule_name(action_text);
if (paction == nullptr) {
ruleset_error(nullptr, LOG_ERROR,
"\"%s\" [%s] lists unknown action type \"%s\".",
filename, sec_name, action_text);
ok = FALSE;
break;
}
if (paction->configured) {
ruleset_error(nullptr, LOG_ERROR,
"\"%s\" [%s] duplicate configuration for action \"%s\".",
filename, sec_name, action_text);
ok = FALSE;
break;
}
paction->configured = TRUE;
} section_list_iterate_end;
}
}
if (ok) {
sec = secfile_sections_by_name_prefix(file, ENABLER_SECTION_PREFIX);
if (sec == nullptr && compat->compat_mode && compat->version < RSFORMAT_3_3) {
sec = secfile_sections_by_name_prefix(file,
......
action_text = secfile_lookup_str(file, "%s.action", sec_name);
if (action_text == NULL) {
ruleset_error(NULL, LOG_ERROR,
if (action_text == nullptr) {
ruleset_error(nullptr, LOG_ERROR,
"\"%s\" [%s] missing action to enable.",
filename, sec_name);
ok = FALSE;
......
}
paction = action_by_rule_name(action_text);
if (!paction) {
ruleset_error(NULL, LOG_ERROR,
if (paction == nullptr) {
ruleset_error(nullptr, LOG_ERROR,
"\"%s\" [%s] lists unknown action type \"%s\".",
filename, sec_name, action_text);
ok = FALSE;
tools/ruleutil/rulesave.c
size_t i, j;
size_t ret;
const struct action_auto_perf *auto_perf =
action_auto_perf_by_number(aap);
const struct action_auto_perf *auto_perf
= action_auto_perf_by_number(aap);
for (i = 0, j = 0;
i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE;
......
return FALSE;
}
for (i = 0; i < MAX_NUM_ACTIONS; i++) {
struct action *paction = action_by_number(i);
if (!action_is_in_use(paction)) {
/* Don't mention non enabled actions. */
continue;
}
if (paction->configured) {
char path[512];
fc_snprintf(path, sizeof(path), "action_%d", i);
secfile_insert_str(sfile, action_rule_name(paction),
"%s.action", path);
}
}
comment_enablers(sfile);
sect_idx = 0;
action_enablers_iterate(pae) {
    (1-1/1)