From b08b171fcf9652b4d9de09b24497cde08fb14890 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 10 Sep 2021 21:56:36 +0300 Subject: [PATCH 33/33] Rulesave: Save comment about research tech_cost_style settings See osdn #42853 Signed-off-by: Marko Lindqvist --- data/ruledit/comments-3.2.txt | 23 +++++++++++++++++++++++ tools/ruleutil/comments.c | 12 ++++++++++++ tools/ruleutil/comments.h | 1 + tools/ruleutil/rulesave.c | 2 ++ 4 files changed, 38 insertions(+) diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt index 99a88e5881..0767d116e5 100644 --- a/data/ruledit/comments-3.2.txt +++ b/data/ruledit/comments-3.2.txt @@ -1317,3 +1317,26 @@ radius_permanent = "\n\ ; a squared value, so the radius of the ring of tiles which are workable\n\ ; but not locked (or vice versa) varies but the area is constant.\n\ " + +tech_cost_style = "\ +; Method of calculating technology costs\n\ +; \"Civ I|II\" - Civ (I|II) style. Every new tech add base_tech_cost to\n\ +; cost of next tech.\n\ +; \"Classic\" - Cost of technology is:\n\ +; base_tech_cost * (1 + reqs) * sqrt(1 + reqs) / 2\n\ +; where reqs == number of requirement for tech, counted\n\ +; recursively.\n\ +; \"Classic+\" - Cost are read from tech.ruleset. Missing costs are\n\ +; generated by style \"Classic\".\n\ +; \"Experimental\" - Cost of technology is:\n\ +; base_tech_cost * (reqs^2 / (1 + sqrt(sqrt(reqs + 1)))\n\ +; - 0.5)\n\ +; where reqs == number of requirement for tech, counted\n\ +; recursively. Initial techs` cost will be base_tech_cost.\n\ +; \"Experimental+\" - Cost are read from tech.ruleset. Missing costs are\n\ +; generated by style \"Experimental\".\n\ +; \"Linear\" - Cost of technology is:\n\ +; base_tech_cost * reqs\n\ +; where reqs == number of requirement for tech, counted\n\ +; recursively.\ +" diff --git a/tools/ruleutil/comments.c b/tools/ruleutil/comments.c index f8d2482620..5f115f0406 100644 --- a/tools/ruleutil/comments.c +++ b/tools/ruleutil/comments.c @@ -66,6 +66,7 @@ static struct { char *actions_ui_names; char *actions_dc_initial_odds; char *borders_radius_permanent; + char *research_tech_cost_style; } comments_storage; /**********************************************************************//** @@ -167,6 +168,8 @@ bool comments_load(void) "entrydoc.dc_initial_odds"); comment_load(comments_storage.borders_radius_permanent, comment_file, "entrydoc.radius_permanent"); + comment_load(comments_storage.research_tech_cost_style, comment_file, + "entrydoc.tech_cost_style"); secfile_check_unused(comment_file); secfile_destroy(comment_file); @@ -543,3 +546,12 @@ void comment_borders_radius_permanent(struct section_file *sfile) comment_entry_write(sfile, comments_storage.borders_radius_permanent, "borders"); } + +/**********************************************************************//** + Write research tech_cost_style settings header. +**************************************************************************/ +void comment_research_tech_cost_style(struct section_file *sfile) +{ + comment_entry_write(sfile, comments_storage.research_tech_cost_style, + "research"); +} diff --git a/tools/ruleutil/comments.h b/tools/ruleutil/comments.h index 336a7f579e..bd2a537743 100644 --- a/tools/ruleutil/comments.h +++ b/tools/ruleutil/comments.h @@ -69,6 +69,7 @@ void comment_auto_attack(struct section_file *sfile); void comment_actions_ui_names(struct section_file *sfile); void comment_actions_dc_initial_odds(struct section_file *sfile); void comment_borders_radius_permanent(struct section_file *sfile); +void comment_research_tech_cost_style(struct section_file *sfile); #ifdef __cplusplus } diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index f12165e53a..43bf33a3c4 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1419,6 +1419,8 @@ static bool save_game_ruleset(const char *filename, const char *name) save_default_int(sfile, game.info.border_city_permanent_radius_sq, RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT, "borders.radius_sq_city_permanent", NULL); + + comment_research_tech_cost_style(sfile); secfile_insert_str(sfile, tech_cost_style_name(game.info.tech_cost_style), "research.tech_cost_style"); save_default_int(sfile, game.info.base_tech_cost, -- 2.33.0