From 2a01298586c5a2aba2a474e326d4cbbd4881a14e Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Wed, 28 Apr 2021 20:05:37 +0200 Subject: [PATCH] civmanual: check action can target terrain. Update existing checks if an action can be performed against a tile with a given terrain type to also check if the action itself may be enabled against the terrain type. It may be impossible to perform it even if it has a x_time above 0 or a defined result. See osdn #42106 --- tools/civmanual.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/civmanual.c b/tools/civmanual.c index 2d75d3d29b..3ad42fb913 100644 --- a/tools/civmanual.c +++ b/tools/civmanual.c @@ -479,6 +479,8 @@ static bool manual_command(struct tag_types *tag_info) fprintf(doc, "\n\n"); terrain_type_iterate(pterrain) { struct extra_type **r; + struct universal for_terr + = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }}; if (0 == strlen(terrain_rule_name(pterrain))) { /* Must be a disabled piece of terrain */ @@ -508,26 +510,33 @@ static bool manual_command(struct tag_types *tag_info) pterrain->movement_cost, pterrain->defense_bonus); fprintf(doc, "\n"); - if (pterrain->irrigation_time != 0) { + if (pterrain->irrigation_time != 0 + && action_id_univs_not_blocking(ACTION_IRRIGATE, + NULL, &for_terr)) { fprintf(doc, "\n", pterrain->irrigation_food_incr, pterrain->irrigation_time); } else { fprintf(doc, "\n", _("impossible")); } - if (pterrain->cultivate_result != NULL) { + if (pterrain->cultivate_result != NULL + && action_id_univs_not_blocking(ACTION_CULTIVATE, + NULL, &for_terr)) { fprintf(doc, "\n", terrain_name_translation(pterrain->cultivate_result), pterrain->cultivate_time); } else { fprintf(doc, "\n", _("impossible")); } - if (pterrain->mining_time != 0) { + if (pterrain->mining_time != 0 + && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { fprintf(doc, "\n", pterrain->mining_shield_incr, pterrain->mining_time); } else { fprintf(doc, "\n", _("impossible")); } - if (pterrain->plant_result != NULL) { + if (pterrain->plant_result != NULL + && action_id_univs_not_blocking(ACTION_PLANT, + NULL, &for_terr)) { fprintf(doc, "\n", terrain_name_translation(pterrain->plant_result), pterrain->plant_time); @@ -535,7 +544,9 @@ static bool manual_command(struct tag_types *tag_info) fprintf(doc, "\n", _("impossible")); } - if (pterrain->transform_result) { + if (pterrain->transform_result + && action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN, + NULL, &for_terr)) { fprintf(doc, "\n", terrain_name_translation(pterrain->transform_result), pterrain->transform_time); -- 2.30.2
+%d F(%d)
%s
%s(%d)
%s
+%d P(%d)
%s
%s(%d)
%s
%s(%d)