From fb49b54a1695320268a41976286bfc4dafa12e4e Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Tue, 11 May 2021 12:25:15 +0200 Subject: [PATCH] Make the road_time > 0 hard req obligatory... ...for "Build Road". It can't be made obligatory for other extra building actions that may result in a road until the sub target extra can be checked. See osdn #42510 --- 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/game.ruleset | 4 ++++ data/civ1/game.ruleset | 4 ++++ data/civ2/game.ruleset | 4 ++++ data/civ2civ3/game.ruleset | 4 ++++ data/classic/game.ruleset | 4 ++++ data/goldkeep/game.ruleset | 4 ++++ data/granularity/game.ruleset | 4 ++++ data/multiplayer/game.ruleset | 4 ++++ data/sandbox/game.ruleset | 4 ++++ data/stub/game.ruleset | 4 ++++ data/webperimental/game.ruleset | 4 ++++ doc/README.actions | 2 +- 17 files changed, 60 insertions(+), 9 deletions(-) diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 1d99e20403..c4760a23e7 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -1286,8 +1286,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 48c89ff4f1..8c66ed2b1f 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -1293,8 +1293,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-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index 29bcc67ee3..329597f359 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -1394,8 +1394,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 fd0d10f651..c60f507ef4 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -3378,8 +3378,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 4e4b22b9ef..cb2241950e 100644 --- a/common/actions.c +++ b/common/actions.c @@ -553,6 +553,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_LOCAL, + 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/game.ruleset b/data/alien/game.ruleset index e135cfeb64..6fbae3890c 100644 --- a/data/alien/game.ruleset +++ b/data/alien/game.ruleset @@ -996,6 +996,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset index b5543970c3..33dd427436 100644 --- a/data/civ1/game.ruleset +++ b/data/civ1/game.ruleset @@ -872,6 +872,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset index c69d9b86d7..1856c67f4d 100644 --- a/data/civ2/game.ruleset +++ b/data/civ2/game.ruleset @@ -1194,6 +1194,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset index 08b994939e..de6fdfde6e 100644 --- a/data/civ2civ3/game.ruleset +++ b/data/civ2civ3/game.ruleset @@ -1344,6 +1344,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset index 52d37d2383..61be93728f 100644 --- a/data/classic/game.ruleset +++ b/data/classic/game.ruleset @@ -1309,6 +1309,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset index 38830352d5..26437de56e 100644 --- a/data/goldkeep/game.ruleset +++ b/data/goldkeep/game.ruleset @@ -1323,6 +1323,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset index 68722ddca0..ef5d65ff4d 100644 --- a/data/granularity/game.ruleset +++ b/data/granularity/game.ruleset @@ -826,6 +826,10 @@ colorlist = { "r", "g", "b" 255, 0, 0 } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [teams] ; freeciv optional team names definition. diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset index 07795d7250..1d752231b5 100644 --- a/data/multiplayer/game.ruleset +++ b/data/multiplayer/game.ruleset @@ -1300,6 +1300,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index 74c2cabefa..d648d9710c 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -2422,6 +2422,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset index 9f6ca6bdc3..5275ca7787 100644 --- a/data/stub/game.ruleset +++ b/data/stub/game.ruleset @@ -687,6 +687,10 @@ colorlist = { "r", "g", "b" 255, 0, 0 } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [teams] ; freeciv optional team names definition. diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset index 91f229dd87..9cdb51aeb2 100644 --- a/data/webperimental/game.ruleset +++ b/data/webperimental/game.ruleset @@ -1595,6 +1595,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanRoad", "Local" + } [actionenabler_base] action = "Build Base" diff --git a/doc/README.actions b/doc/README.actions index b9d5630c33..c520e89f9b 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -1118,7 +1118,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.30.2