From ba588d5e40e375fd84b8e342193b851adc5128f6 Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Wed, 28 Apr 2021 14:43:58 +0200 Subject: [PATCH] Make the mining_time > 0 hard req obligatory. See osdn #42107 --- client/gui-gtk-3.22/citydlg.c | 3 +-- client/gui-gtk-3.22/helpdlg.c | 3 +-- client/gui-gtk-4.0/citydlg.c | 3 +-- client/gui-gtk-4.0/helpdlg.c | 3 +-- client/gui-qt/citydlg.cpp | 4 +--- client/gui-qt/helpdlg.cpp | 3 +-- common/actions.c | 19 ++++++++++++++----- data/alien/game.ruleset | 5 +++-- data/civ1/game.ruleset | 4 ++++ data/civ2/game.ruleset | 4 ++++ data/civ2civ3/game.ruleset | 5 +++-- data/classic/game.ruleset | 5 +++-- data/goldkeep/game.ruleset | 5 +++-- data/multiplayer/game.ruleset | 5 +++-- data/sandbox/game.ruleset | 5 +++-- data/webperimental/game.ruleset | 5 +++-- doc/README.actions | 2 +- tools/civmanual.c | 3 +-- 18 files changed, 51 insertions(+), 35 deletions(-) diff --git a/client/gui-gtk-3.22/citydlg.c b/client/gui-gtk-3.22/citydlg.c index b73f75c628..71e00bd213 100644 --- a/client/gui-gtk-3.22/citydlg.c +++ b/client/gui-gtk-3.22/citydlg.c @@ -2952,8 +2952,7 @@ static void popup_workertask_dlg(struct city *pcity, struct tile *ptile) GINT_TO_POINTER(ACTIVITY_LAST), FALSE, NULL); } - if (pterr->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { choice_dialog_add(shl, _("Mine"), G_CALLBACK(set_city_workertask), GINT_TO_POINTER(ACTIVITY_MINE), FALSE, NULL); diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index 25f5d2c220..e821c29c45 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -1284,8 +1284,7 @@ static void help_update_terrain(const struct help_item *pitem, && action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation")); } - if (pterrain->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + 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) { diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index ed865ca549..530525c901 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -2967,8 +2967,7 @@ static void popup_workertask_dlg(struct city *pcity, struct tile *ptile) GINT_TO_POINTER(ACTIVITY_LAST), FALSE, NULL); } - if (pterr->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { choice_dialog_add(shl, _("Mine"), G_CALLBACK(set_city_workertask), GINT_TO_POINTER(ACTIVITY_MINE), FALSE, NULL); diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index df675f27fd..bd882b8e9c 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -1291,8 +1291,7 @@ static void help_update_terrain(const struct help_item *pitem, && action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) { help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation")); } - if (pterrain->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + 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) { diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index ec20a92e31..a3b26aa9dc 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -1383,9 +1383,7 @@ void city_map::context_menu(QPoint point) && action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) { con_plant = con_menu->addAction(_("Plant")); } - if (pterr->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, - NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { con_mine = con_menu->addAction(_("Mine")); } diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index 437f633523..97a2c0403f 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -1392,8 +1392,7 @@ void help_widget::set_topic_terrain(const help_item *topic, /* TRANS: this and similar literal strings interpreted as (Qt) HTML */ add_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation")); } - if (pterrain->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + 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) { diff --git a/common/actions.c b/common/actions.c index 4993d3148c..6914ce6b6c 100644 --- a/common/actions.c +++ b/common/actions.c @@ -528,6 +528,20 @@ static void hard_code_oblig_hard_reqs(void) ACTRES_CLEAN_FALLOUT, ACTRES_NONE); + /* Why this is a hard requirement: Preserve semantics of the rule that a + *_time of 0 disables the action. */ + oblig_hard_req_register(req_from_values(VUT_TERRAINALTER, REQ_RANGE_LOCAL, + FALSE, FALSE, FALSE, + TA_CAN_MINE), + TRUE, + N_("All action enablers for %s must require" + " that the target" + " tile's terrain's mining_time" + " is above 0. (See \"TerrainAlter\"'s" + " \"CanMine\")"), + ACTRES_MINE, + ACTRES_NONE); + /* Why this is a hard requirement: Preserve semantics of the NoCities * terrain flag. */ oblig_hard_req_register(req_from_values(VUT_TERRFLAG, REQ_RANGE_LOCAL, @@ -4204,11 +4218,6 @@ is_action_possible(const action_id wanted_action, return TRI_NO; } - pterrain = tile_terrain(target_tile); - if (pterrain->mining_time == 0) { - return TRI_NO; - } - if (!can_build_extra(target_extra, actor_unit, target_tile)) { return TRI_NO; } diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset index 7f6dfaa43e..ccaefa2339 100644 --- a/data/alien/game.ruleset +++ b/data/alien/game.ruleset @@ -1003,8 +1003,9 @@ actor_reqs = "UnitFlag", "Settlers", "Local" } target_reqs = - { "type", "name", "range", "present" - "Terrain", "Thick Mountains", "Local", FALSE + { "type", "name", "range", "present" + "Terrain", "Thick Mountains", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_mine_mountains] diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset index 597ed10f69..1d415773e9 100644 --- a/data/civ1/game.ruleset +++ b/data/civ1/game.ruleset @@ -878,6 +878,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanMine", "Local" + } [actionenabler_irrigate_src_ocean] action = "Build Irrigation" diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset index cd7d5e54d2..8299c67363 100644 --- a/data/civ2/game.ruleset +++ b/data/civ2/game.ruleset @@ -1200,6 +1200,10 @@ actor_reqs = { "type", "name", "range" "UnitFlag", "Settlers", "Local" } +target_reqs = + { "type", "name", "range" + "TerrainAlter", "CanMine", "Local" + } [actionenabler_irrigate_src_ocean] action = "Build Irrigation" diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset index d9644f12bf..4e103fdf17 100644 --- a/data/civ2civ3/game.ruleset +++ b/data/civ2civ3/game.ruleset @@ -1352,8 +1352,9 @@ actor_reqs = "UnitClass", "Sea", "Local", FALSE } target_reqs = - { "type", "name", "range", "present" - "Terrain", "Deep Ocean", "Local", FALSE + { "type", "name", "range", "present" + "Terrain", "Deep Ocean", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_mining_ocean] diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset index cbcd388d19..616a2b504e 100644 --- a/data/classic/game.ruleset +++ b/data/classic/game.ruleset @@ -1316,8 +1316,9 @@ actor_reqs = "UnitFlag", "Settlers", "Local" } target_reqs = - { "type", "name", "range", "present" - "TerrainFlag", "Oil", "Local", FALSE + { "type", "name", "range", "present" + "TerrainFlag", "Oil", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_desert_oil] diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset index e4857deba0..da7f22aea5 100644 --- a/data/goldkeep/game.ruleset +++ b/data/goldkeep/game.ruleset @@ -1330,8 +1330,9 @@ actor_reqs = "UnitFlag", "Settlers", "Local" } target_reqs = - { "type", "name", "range", "present" - "TerrainFlag", "Oil", "Local", FALSE + { "type", "name", "range", "present" + "TerrainFlag", "Oil", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_desert_oil] diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset index 915728c85e..cc629cd703 100644 --- a/data/multiplayer/game.ruleset +++ b/data/multiplayer/game.ruleset @@ -1307,8 +1307,9 @@ actor_reqs = "UnitFlag", "Settlers", "Local" } target_reqs = - { "type", "name", "range", "present" - "TerrainFlag", "Oil", "Local", FALSE + { "type", "name", "range", "present" + "TerrainFlag", "Oil", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_desert_oil] diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index dc5bd9febb..bd319a0902 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -2430,8 +2430,9 @@ actor_reqs = "UnitClass", "Sea", "Local", FALSE } target_reqs = - { "type", "name", "range", "present" - "Terrain", "Deep Ocean", "Local", FALSE + { "type", "name", "range", "present" + "Terrain", "Deep Ocean", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_mining_ocean] diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset index 1de1fd9dc1..21a9f4bc90 100644 --- a/data/webperimental/game.ruleset +++ b/data/webperimental/game.ruleset @@ -1602,8 +1602,9 @@ actor_reqs = "UnitFlag", "Settlers", "Local" } target_reqs = - { "type", "name", "range", "present" - "TerrainFlag", "Oil", "Local", FALSE + { "type", "name", "range", "present" + "TerrainFlag", "Oil", "Local", FALSE + "TerrainAlter", "CanMine", "Local", TRUE } [actionenabler_desert_oil] diff --git a/doc/README.actions b/doc/README.actions index fd35f5c3d8..c8001d5454 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -1135,7 +1135,7 @@ Actions done by a unit against a tile * the target extra (the extra to be built) is a mine * 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 mining_time isn't 0 + * the target tile's terrain's mining_time is above 0 (!) * if the target extra is both a mine and a base the target tile's terrain's base_time isn't 0 * if the target extra is both a mine and a base the target extra can't diff --git a/tools/civmanual.c b/tools/civmanual.c index 3ad42fb913..1203e40852 100644 --- a/tools/civmanual.c +++ b/tools/civmanual.c @@ -527,8 +527,7 @@ static bool manual_command(struct tag_types *tag_info) } else { fprintf(doc, "%s\n", _("impossible")); } - if (pterrain->mining_time != 0 - && action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { + if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) { fprintf(doc, "+%d P(%d)\n", pterrain->mining_shield_incr, pterrain->mining_time); } else { -- 2.30.2