From 19154b1dad490c50a23f0d942294f020fcce8cd8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 28 May 2023 00:56:47 +0300 Subject: [PATCH 32/32] Make base_time > 0 obligatory req for Build Base See osdn #48090 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/helpdlg.c | 16 ++++++++++------ client/gui-gtk-4.0/helpdlg.c | 3 +-- client/gui-qt/helpdlg.cpp | 17 ++++++++++------- client/helpdata.c | 3 +-- common/actions.c | 11 +++++++++++ data/alien/actions.ruleset | 4 ++++ data/civ1/actions.ruleset | 4 ++++ data/civ2/actions.ruleset | 4 ++++ data/civ2civ3/actions.ruleset | 4 ++++ data/classic/actions.ruleset | 4 ++++ data/goldkeep/actions.ruleset | 4 ++++ data/multiplayer/actions.ruleset | 4 ++++ data/sandbox/actions.ruleset | 4 ++++ data/webperimental/actions.ruleset | 4 ++++ doc/README.actions | 2 +- 15 files changed, 70 insertions(+), 18 deletions(-) diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 07e2e217ef..67b3623233 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -1370,18 +1370,22 @@ static void help_update_terrain(const struct help_item *pitem, } if (action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) { - help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation")); + help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, + _("Build as irrigation")); } if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { - help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine")); + help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, + _("Build as mine")); } if (action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { - help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); + help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, + _("Build as road")); } - if (pterrain->base_time != 0 - && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { - help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base")); + if (action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { + help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, + _("Build as base")); } + gtk_widget_show(help_vbox); } diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index b11ad2dd88..d0b9646758 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -1423,8 +1423,7 @@ static void help_update_terrain(const struct help_item *pitem, help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); } - if (pterrain->base_time != 0 - && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base")); } diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index 1cbfaa4a6b..13465eb010 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -1405,18 +1405,21 @@ void help_widget::set_topic_terrain(const help_item *topic, } if (action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) { - // TRANS: this and similar literal strings interpreted as (Qt) HTML - add_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation")); + // TRANS: This and similar literal strings interpreted as (Qt) HTML + add_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, + _("Build as irrigation")); } if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { - add_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine")); + add_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, + _("Build as mine")); } if (action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { - add_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); + add_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, + _("Build as road")); } - if (pterrain->base_time != 0 - && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { - add_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base")); + if (action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) { + add_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, + _("Build as base")); } info_panel_done(); diff --git a/client/helpdata.c b/client/helpdata.c index 3209b45660..b0e466c274 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -3443,8 +3443,7 @@ void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, } } extra_type_by_cause_iterate_end; } - if (pterrain->base_time == 0 - || !action_id_univs_not_blocking(ACTION_BASE, NULL, &source)) { + if (!action_id_univs_not_blocking(ACTION_BASE, NULL, &source)) { /* Can't build bases; only mention if ruleset has buildable bases */ extra_type_by_cause_iterate(EC_BASE, pextra) { if (pextra->buildable) { diff --git a/common/actions.c b/common/actions.c index 29f36821f3..f20097aa4f 100644 --- a/common/actions.c +++ b/common/actions.c @@ -560,6 +560,17 @@ static void hard_code_oblig_hard_reqs(void) " \"CanRoad\")"), ACTRES_ROAD, ACTRES_NONE); + oblig_hard_req_register(req_from_values(VUT_TERRAINALTER, REQ_RANGE_TILE, + FALSE, FALSE, FALSE, + TA_CAN_BASE), + TRUE, + N_("All action enablers for %s must require" + " that the target" + " tile's terrain's base_time" + " is above 0. (See \"TerrainAlter\"'s" + " \"CanBase\")"), + ACTRES_BASE, + ACTRES_NONE); /* Why this is a hard requirement: Preserve semantics of the NoCities * terrain flag. */ diff --git a/data/alien/actions.ruleset b/data/alien/actions.ruleset index 2381e510e7..a21a5c503e 100644 --- a/data/alien/actions.ruleset +++ b/data/alien/actions.ruleset @@ -787,6 +787,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/civ1/actions.ruleset b/data/civ1/actions.ruleset index f468a0390a..bbbf391d6a 100644 --- a/data/civ1/actions.ruleset +++ b/data/civ1/actions.ruleset @@ -668,6 +668,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/civ2/actions.ruleset b/data/civ2/actions.ruleset index d6a6276b8a..8804009d9d 100644 --- a/data/civ2/actions.ruleset +++ b/data/civ2/actions.ruleset @@ -984,6 +984,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/civ2civ3/actions.ruleset b/data/civ2civ3/actions.ruleset index e03f7d3aa0..393d3d7546 100644 --- a/data/civ2civ3/actions.ruleset +++ b/data/civ2civ3/actions.ruleset @@ -1156,6 +1156,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/classic/actions.ruleset b/data/classic/actions.ruleset index 61c44344bb..5004acd155 100644 --- a/data/classic/actions.ruleset +++ b/data/classic/actions.ruleset @@ -1102,6 +1102,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/goldkeep/actions.ruleset b/data/goldkeep/actions.ruleset index 1ead6b41b1..d4806fb164 100644 --- a/data/goldkeep/actions.ruleset +++ b/data/goldkeep/actions.ruleset @@ -1116,6 +1116,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/multiplayer/actions.ruleset b/data/multiplayer/actions.ruleset index ccc8979b82..f545b198bc 100644 --- a/data/multiplayer/actions.ruleset +++ b/data/multiplayer/actions.ruleset @@ -1090,6 +1090,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/sandbox/actions.ruleset b/data/sandbox/actions.ruleset index e7ed7055d5..2bb246e2f9 100644 --- a/data/sandbox/actions.ruleset +++ b/data/sandbox/actions.ruleset @@ -2259,6 +2259,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/data/webperimental/actions.ruleset b/data/webperimental/actions.ruleset index add801b9d4..d098031330 100644 --- a/data/webperimental/actions.ruleset +++ b/data/webperimental/actions.ruleset @@ -1402,6 +1402,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanBase", "Tile" + } [actionenabler_mining] action = "Build Mine" diff --git a/doc/README.actions b/doc/README.actions index 412e5a02a0..f8cb4d4869 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -1220,7 +1220,7 @@ Actions done by a unit against a tile * the target extra (the extra to be built) is an base * the target tile doesn't already have the target extra * the target extra is buildable (see extra type's buildable) - * the target tile's terrain's base_time isn't 0 + * the target tile's terrain's base_time is above 0 (!) * the target extra can't claim land (see base type's border_sq) if the target tile has a city * if the target extra is both a road and a base the target tile's terrain's -- 2.39.2