From f121d8efc234f3794882b3d2082cd398d90369fc Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 8 May 2021 05:16:21 +0300 Subject: [PATCH 56/57] Rulesave: Save comment about combat_rules.nuke_defender_survival_chance_pct See osdn #42197 Signed-off-by: Marko Lindqvist --- data/ruledit/comments-3.2.txt | 6 ++++++ tools/ruleutil/comments.c | 14 ++++++++++++++ tools/ruleutil/comments.h | 1 + tools/ruleutil/rulesave.c | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt index 22e741f5e2..0e93c3713e 100644 --- a/data/ruledit/comments-3.2.txt +++ b/data/ruledit/comments-3.2.txt @@ -1248,3 +1248,9 @@ nuke_pop_loss_pct = "\n\ ; loose population. Any value below 50 means the city can never be\n\ ; destroyed completely using nuclear.\ " + +nuke_defender_survival_chance_pct = "\n\ +; Percentage chance of a city defender surviving nuclear attack. When set\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.\ +" diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c index be0af995c9..53a29a0690 100644 --- a/tools/ruleutil/comments.c +++ b/tools/ruleutil/comments.c @@ -57,6 +57,7 @@ static struct { char *civstyle_gold_upkeep_style; char *combat_rules_tired_attack; char *combat_rules_nuke_pop_loss; + char *combat_rules_nuke_defender_survival; } comments_storage; /**********************************************************************//** @@ -138,6 +139,9 @@ bool comments_load(void) "entrydoc.tired_attack"); comment_load(comments_storage.combat_rules_nuke_pop_loss, comment_file, "entrydoc.nuke_pop_loss_pct"); + comment_load(comments_storage.combat_rules_nuke_defender_survival, + comment_file, + "entrydoc.nuke_defender_survival_chance_pct"); secfile_check_unused(comment_file); secfile_destroy(comment_file); @@ -433,3 +437,13 @@ void comment_combat_rules_nuke_pop_loss(struct section_file *sfile) comment_entry_write(sfile, comments_storage.combat_rules_nuke_pop_loss, "combat_rules"); } + +/**********************************************************************//** + Write combat_rules nuke_defender_survival_chance_pct settings header. +**************************************************************************/ +void comment_combat_rules_nuke_defender_survival(struct section_file *sfile) +{ + comment_entry_write(sfile, + comments_storage.combat_rules_nuke_defender_survival, + "combat_rules"); +} diff --git a/tools/ruleutil/comments.h b/tools/ruleutil/comments.h index 695c4bb332..a34d0783bc 100644 --- a/tools/ruleutil/comments.h +++ b/tools/ruleutil/comments.h @@ -60,6 +60,7 @@ void comment_civstyle_gameloss_style(struct section_file *sfile); void comment_civstyle_gold_upkeep_style(struct section_file *sfile); void comment_combat_rules_tired_attack(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); #ifdef __cplusplus } diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 5a691f36d0..69e488321e 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1386,6 +1386,10 @@ static bool save_game_ruleset(const char *filename, const char *name) save_default_int(sfile, game.info.nuke_pop_loss_pct, RS_DEFAULT_NUKE_POP_LOSS_PCT, "combat_rules.nuke_pop_loss_pct", NULL); + if (game.info.nuke_defender_survival_chance_pct + != RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT) { + comment_combat_rules_nuke_defender_survival(sfile); + } save_default_int(sfile, game.info.nuke_defender_survival_chance_pct, RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT, "combat_rules.nuke_defender_survival_chance_pct", NULL); -- 2.30.2