From 691c51ba357e1bcbd49d2ce3d3af406f0332742d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 24 May 2023 08:17:24 +0300 Subject: [PATCH 15/15] Makr road_time > 0 obligatory req for Build Road Based on patch by Sveinung Kvilhaugsvik See osdn #42510 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/helpdlg.c | 3 +-- client/gui-gtk-4.0/helpdlg.c | 3 +-- client/gui-qt/helpdlg.cpp | 3 +-- 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, 52 insertions(+), 9 deletions(-) diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 68e6afc415..07e2e217ef 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -1375,8 +1375,7 @@ static void help_update_terrain(const struct help_item *pitem, if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine")); } - if (pterrain->road_time != 0 - && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); } if (pterrain->base_time != 0 diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index 160edc49fb..b11ad2dd88 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -1419,8 +1419,7 @@ static void help_update_terrain(const struct help_item *pitem, help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine")); } - if (pterrain->road_time != 0 - && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); } diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index 7c1e941e87..1cbfaa4a6b 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -1411,8 +1411,7 @@ void help_widget::set_topic_terrain(const help_item *topic, if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { add_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine")); } - if (pterrain->road_time != 0 - && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) { add_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road")); } if (pterrain->base_time != 0 diff --git a/client/helpdata.c b/client/helpdata.c index f7c1f773dc..32920341d0 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -3431,8 +3431,7 @@ void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, _("%s You cannot build cities on this terrain.\n"), BULLET); } - if (pterrain->road_time == 0 - || !action_id_univs_not_blocking(ACTION_ROAD, NULL, &source)) { + if (!action_id_univs_not_blocking(ACTION_ROAD, NULL, &source)) { /* Can't build roads; only mention if ruleset has buildable roads */ extra_type_by_cause_iterate(EC_ROAD, pextra) { if (pextra->buildable) { diff --git a/common/actions.c b/common/actions.c index 8122e03a96..b563a4e314 100644 --- a/common/actions.c +++ b/common/actions.c @@ -543,6 +543,17 @@ static void hard_code_oblig_hard_reqs(void) " \"CanMine\")"), ACTRES_MINE, ACTRES_NONE); + oblig_hard_req_register(req_from_values(VUT_TERRAINALTER, REQ_RANGE_TILE, + FALSE, FALSE, FALSE, + TA_CAN_ROAD), + TRUE, + N_("All action enablers for %s must require" + " that the target" + " tile's terrain's road_time" + " is above 0. (See \"TerrainAlter\"'s" + " \"CanRoad\")"), + ACTRES_ROAD, + 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 df0574f0ef..b038a94069 100644 --- a/data/alien/actions.ruleset +++ b/data/alien/actions.ruleset @@ -796,6 +796,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ1/actions.ruleset b/data/civ1/actions.ruleset index 37da99288d..a351a0144c 100644 --- a/data/civ1/actions.ruleset +++ b/data/civ1/actions.ruleset @@ -667,6 +667,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ2/actions.ruleset b/data/civ2/actions.ruleset index f803d67794..7c39149ad3 100644 --- a/data/civ2/actions.ruleset +++ b/data/civ2/actions.ruleset @@ -983,6 +983,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ2civ3/actions.ruleset b/data/civ2civ3/actions.ruleset index 874aee7ec4..6da152b3f1 100644 --- a/data/civ2civ3/actions.ruleset +++ b/data/civ2civ3/actions.ruleset @@ -1165,6 +1165,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/classic/actions.ruleset b/data/classic/actions.ruleset index 35a0a5df69..f098f48247 100644 --- a/data/classic/actions.ruleset +++ b/data/classic/actions.ruleset @@ -1111,6 +1111,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/goldkeep/actions.ruleset b/data/goldkeep/actions.ruleset index 28d7a2e9b8..6a0395350f 100644 --- a/data/goldkeep/actions.ruleset +++ b/data/goldkeep/actions.ruleset @@ -1125,6 +1125,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/multiplayer/actions.ruleset b/data/multiplayer/actions.ruleset index d0f0a33d48..74e4ee7f9f 100644 --- a/data/multiplayer/actions.ruleset +++ b/data/multiplayer/actions.ruleset @@ -1099,6 +1099,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/sandbox/actions.ruleset b/data/sandbox/actions.ruleset index db7a3051b5..c650d5f6be 100644 --- a/data/sandbox/actions.ruleset +++ b/data/sandbox/actions.ruleset @@ -2268,6 +2268,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/data/webperimental/actions.ruleset b/data/webperimental/actions.ruleset index 10576c1205..c504436840 100644 --- a/data/webperimental/actions.ruleset +++ b/data/webperimental/actions.ruleset @@ -1411,6 +1411,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Tile" + } [actionenabler_base] action = "Build Base" diff --git a/doc/README.actions b/doc/README.actions index a407e64553..412e5a02a0 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -1200,7 +1200,7 @@ Actions done by a unit against a tile * the target extra (the extra to be built) is an road * 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 road_time isn't 0 + * the target tile's terrain's road_time is above 0 (!) * if the target extra is both a road and a base the target tile's terrain's base_time isn't 0 * if the target extra is both a road and a base the target extra can't -- 2.39.2