From 787ea994dac3152b1ef2451c58746b01c40fe7b9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 25 May 2021 03:58:39 +0300 Subject: [PATCH 47/47] Rulesave: Save comment about auto_attack settings See osdn #42385 Signed-off-by: Marko Lindqvist --- data/ruledit/comments-3.2.txt | 10 ++++++++++ tools/ruleutil/comments.c | 11 +++++++++++ tools/ruleutil/comments.h | 1 + tools/ruleutil/rulesave.c | 2 ++ 4 files changed, 24 insertions(+) diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt index 06be53fcba..de6e8e563c 100644 --- a/data/ruledit/comments-3.2.txt +++ b/data/ruledit/comments-3.2.txt @@ -1266,3 +1266,13 @@ nuke_defender_survival_chance_pct = "\n\ ; to 50 roughly half of defenders will survive nuclear attack. When set to\n\ ; 0 no defenders will survive. When set to 100 all defenders will survive.\ " + +auto_attack = "\n\ +; An auto attack may be triggered when another unit moves to an adjacent\n\ +; tile and the autoattack server setting is enabled. The following details\n\ +; are ruleset controlled.\n\ +; attack_actions - the actions to try during an auto attack in the order\n\ +; they should be tried.\n\ +; if_attacker - this requirement vector must be true before a unit even\n\ +; considers to auto attack.\ +" diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c index 8701b2fe98..596076e208 100644 --- a/tools/ruleutil/comments.c +++ b/tools/ruleutil/comments.c @@ -60,6 +60,7 @@ static struct { char *combat_rules_only_killing_veteran; char *combat_rules_nuke_pop_loss; char *combat_rules_nuke_defender_survival; + char *auto_attack; } comments_storage; /**********************************************************************//** @@ -148,6 +149,8 @@ bool comments_load(void) comment_load(comments_storage.combat_rules_nuke_defender_survival, comment_file, "entrydoc.nuke_defender_survival_chance_pct"); + comment_load(comments_storage.auto_attack, comment_file, + "entrydoc.auto_attack"); secfile_check_unused(comment_file); secfile_destroy(comment_file); @@ -472,3 +475,11 @@ void comment_combat_rules_nuke_defender_survival(struct section_file *sfile) comments_storage.combat_rules_nuke_defender_survival, "combat_rules"); } + +/**********************************************************************//** + Write auto_attack settings header. +**************************************************************************/ +void comment_auto_attack(struct section_file *sfile) +{ + comment_entry_write(sfile, comments_storage.auto_attack, "auto_attack"); +} diff --git a/tools/ruleutil/comments.h b/tools/ruleutil/comments.h index 62a8399ee9..0b7d489b87 100644 --- a/tools/ruleutil/comments.h +++ b/tools/ruleutil/comments.h @@ -63,6 +63,7 @@ void comment_combat_rules_tired_attack(struct section_file *sfile); void comment_combat_rules_only_killing_veteran(struct section_file *sfile); void comment_combat_rules_nuke_pop_loss(struct section_file *sfile); void comment_combat_rules_nuke_defender_survival(struct section_file *sfile); +void comment_auto_attack(struct section_file *sfile); #ifdef __cplusplus } diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 1b7445f710..fface7b28d 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1277,6 +1277,8 @@ static bool save_game_ruleset(const char *filename, const char *name) const struct action_auto_perf *auto_perf = action_auto_perf_by_number(ACTION_AUTO_MOVED_ADJ); + comment_auto_attack(sfile); + save_action_auto_actions(sfile, ACTION_AUTO_MOVED_ADJ, "auto_attack.attack_actions"); -- 2.30.2