Feature #1092 ยป 0076-Load-ui_name-from-action-section.patch
server/ruleset/rscompat.c | ||
---|---|---|
effect_req_append(peffect, e_req);
|
||
}
|
||
}
|
||
/**********************************************************************//**
|
||
Load ui_name of one action
|
||
**************************************************************************/
|
||
bool load_action_ui_name_3_3(struct section_file *file, int act,
|
||
const char *entry_name,
|
||
struct rscompat_info *compat)
|
||
{
|
||
const char *text;
|
||
const char *def = action_ui_name_default(act);
|
||
struct action *paction = action_by_number(act);
|
||
if (entry_name == nullptr) {
|
||
text = def;
|
||
} else {
|
||
text = secfile_lookup_str_default(file, nullptr,
|
||
"actions.%s", entry_name);
|
||
if (text == nullptr && compat->compat_mode && compat->version < RSFORMAT_3_3) {
|
||
text = secfile_lookup_str_default(file, nullptr,
|
||
"actions.%s", ui_name_old_name_3_3(entry_name));
|
||
}
|
||
if (text == nullptr) {
|
||
text = def;
|
||
} else {
|
||
paction->configured = TRUE;
|
||
}
|
||
}
|
||
sz_strlcpy(paction->ui_name, text);
|
||
return TRUE;
|
||
}
|
server/ruleset/rscompat.h | ||
---|---|---|
void rscompat_civil_war_effects_3_3(struct section_file *game_rs);
|
||
bool load_action_ui_name_3_3(struct section_file *file, int act,
|
||
const char *entry_name,
|
||
struct rscompat_info *compat);
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif /* __cplusplus */
|
server/ruleset/ruleload.c | ||
---|---|---|
return ival;
|
||
}
|
||
/**********************************************************************//**
|
||
Load ui_name of one action
|
||
**************************************************************************/
|
||
static bool load_action_ui_name(struct section_file *file, int act,
|
||
const char *entry_name,
|
||
struct rscompat_info *compat)
|
||
{
|
||
const char *text;
|
||
const char *def = action_ui_name_default(act);
|
||
if (entry_name == nullptr) {
|
||
text = def;
|
||
} else {
|
||
text = secfile_lookup_str_default(file, nullptr,
|
||
"actions.%s", entry_name);
|
||
if (text == nullptr && compat->compat_mode && compat->version < RSFORMAT_3_3) {
|
||
text = secfile_lookup_str_default(file, nullptr,
|
||
"actions.%s", ui_name_old_name_3_3(entry_name));
|
||
}
|
||
if (text == nullptr) {
|
||
text = def;
|
||
}
|
||
}
|
||
sz_strlcpy(action_by_number(act)->ui_name, text);
|
||
return TRUE;
|
||
}
|
||
/**********************************************************************//**
|
||
Load max range of an action
|
||
**************************************************************************/
|
||
... | ... | |
entry_name = action_ui_name_ruleset_var_name(act_id);
|
||
}
|
||
load_action_ui_name(file, act_id, entry_name, compat);
|
||
/* FIXME: Allow old style ui_name definitions only in compat mode. */
|
||
if (TRUE /* compat->compat_mode && compat->version < RSFORMAT_3_3 */) {
|
||
load_action_ui_name_3_3(file, act_id, entry_name, compat);
|
||
}
|
||
}
|
||
if (!ok) {
|
||
... | ... | |
const char *sec_name = section_name(psection);
|
||
const char *action_text;
|
||
struct action *paction;
|
||
const char *ui_name;
|
||
action_text = secfile_lookup_str(file, "%s.action", sec_name);
|
||
... | ... | |
}
|
||
paction->configured = TRUE;
|
||
ui_name = secfile_lookup_str_default(file, nullptr,
|
||
"%s.ui_name", sec_name);
|
||
if (ui_name == nullptr) {
|
||
ui_name = action_ui_name_default(action_id(paction));
|
||
}
|
||
sz_strlcpy(paction->ui_name, ui_name);
|
||
} section_list_iterate_end;
|
||
}
|
||
}
|
tools/ruleutil/rulesave.c | ||
---|---|---|
return save_ruleset_file(sfile, filename);
|
||
}
|
||
/**********************************************************************//**
|
||
Save ui_name of one action.
|
||
**************************************************************************/
|
||
static bool save_action_ui_name(struct section_file *sfile,
|
||
int act, const char *entry_name)
|
||
{
|
||
struct action *paction = action_by_number(act);
|
||
const char *ui_name;
|
||
if (action_is_internal(paction)) {
|
||
return TRUE;
|
||
}
|
||
ui_name = paction->ui_name;
|
||
if (ui_name == nullptr) {
|
||
fc_assert(ui_name != nullptr);
|
||
return FALSE;
|
||
}
|
||
if (strcmp(ui_name, action_ui_name_default(act))) {
|
||
secfile_insert_str(sfile, ui_name,
|
||
"actions.%s", entry_name);
|
||
}
|
||
return TRUE;
|
||
}
|
||
/**********************************************************************//**
|
||
Save max range of an action.
|
||
**************************************************************************/
|
||
... | ... | |
action_iterate(act_id) {
|
||
struct action *act = action_by_number(act_id);
|
||
if (!action_id_is_internal(act_id)) {
|
||
save_action_ui_name(sfile,
|
||
act_id, action_ui_name_ruleset_var_name(act_id));
|
||
}
|
||
save_action_kind(sfile, act_id);
|
||
save_action_range(sfile, act_id);
|
||
save_action_actor_consuming_always(sfile, act_id);
|
||
... | ... | |
if (paction->configured) {
|
||
char path[512];
|
||
const char *ui_name;
|
||
fc_snprintf(path, sizeof(path), "action_%d", i);
|
||
secfile_insert_str(sfile, action_rule_name(paction),
|
||
"%s.action", path);
|
||
if (!action_id_is_internal(i)) {
|
||
ui_name = paction->ui_name;
|
||
if (ui_name == nullptr) {
|
||
fc_assert(ui_name != nullptr);
|
||
return FALSE;
|
||
}
|
||
if (strcmp(ui_name, action_ui_name_default(i))) {
|
||
secfile_insert_str(sfile, ui_name,
|
||
"%s.ui_name", path);
|
||
}
|
||
}
|
||
}
|
||
}
|
||