From c22f09459a7de9a2f1dbda89e91bce41bac3d4a7 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.0/citydlg.c | 3 +-- client/gui-gtk-3.0/helpdlg.c | 3 +-- 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/experimental/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 +-- 20 files changed, 53 insertions(+), 39 deletions(-) diff --git a/client/gui-gtk-3.0/citydlg.c b/client/gui-gtk-3.0/citydlg.c index a0b24db349..f79ed20a09 100644 --- a/client/gui-gtk-3.0/citydlg.c +++ b/client/gui-gtk-3.0/citydlg.c @@ -2935,8 +2935,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.0/helpdlg.c b/client/gui-gtk-3.0/helpdlg.c index 741df8628e..55e7701974 100644 --- a/client/gui-gtk-3.0/helpdlg.c +++ b/client/gui-gtk-3.0/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-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 9a91465ebf..5822db79b0 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 68d40961e2..2527ee11c4 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 61bdb63a8a..75e94cf976 100644 --- a/common/actions.c +++ b/common/actions.c @@ -527,6 +527,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, @@ -4180,11 +4194,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 bc2cd5ec4e..905f7778f3 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 f7c77ee771..a7c617136c 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 a3c21632e0..8b5419221b 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 50b1cdd65b..8b071578ee 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 15579f4c74..fc03318db4 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/experimental/game.ruleset b/data/experimental/game.ruleset index 6aadf209f8..92644d0b1f 100644 --- a/data/experimental/game.ruleset +++ b/data/experimental/game.ruleset @@ -1335,8 +1335,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 e76b312f99..0c3cac0be9 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 a5925f7ec2..29e6568805 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -2396,8 +2396,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 b6c763c607..d7f6f8ad6c 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 ce9e977237..045372dea0 100644 --- a/doc/README.actions +++ b/doc/README.actions @@ -1109,7 +1109,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