From 6e1ab8d67b2063bee595bbdc422c37c73c4ff368 Mon Sep 17 00:00:00 2001 From: gearsix Date: Thu, 26 Jan 2023 18:58:25 +0000 Subject: [PATCH 1/4] issue #1805 - made getplants input case-insensitive Now `toUpper` is called on user input when it's added to `plantNames` to ensure it matches the ID fields which are all in upper-case. --- plugins/getplants.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index 4fc82cb97..485dff967 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -7,6 +7,7 @@ #include "PluginManager.h" #include "DataDefs.h" #include "TileTypes.h" +#include "MiscUtils.h" #include "df/map_block.h" #include "df/map_block_column.h" @@ -395,7 +396,7 @@ command_result df_getplants (color_ostream &out, vector & parameters) } } else - plantNames.insert(parameters[i]); + plantNames.insert(toUpper(parameters[i])); } if (treesonly && shrubsonly) { From 6726b567a1224e22a9515fec5ec96b53c9b626ca Mon Sep 17 00:00:00 2001 From: gearsix Date: Fri, 27 Jan 2023 14:19:29 +0000 Subject: [PATCH 2/4] issue #2043 - `designate` now marks trees (regardless of if ripe). The `ripe` call was returning false on tree tiles, resulting in an inability to designate trees for chopping with `getplants`. This change adds a check to see if the tile is a tree or not and if it is, then the ripe check is ignored. --- plugins/getplants.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index 485dff967..565316fa6 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -322,9 +322,9 @@ bool designate(const df::plant *plant, bool farming) { } } - if ((!farming || seedSource) && - ripe(plant->pos.x, plant->pos.y, plant_raw->growths[i]->timing_1, plant_raw->growths[i]->timing_2) && - !picked(plant, i)) + bool istree = (tileMaterial(Maps::getTileBlock(plant->pos)->tiletype[plant->pos.x % 16][plant->pos.y % 16]) == tiletype_material::TREE); + bool isripe = ripe(plant->pos.x, plant->pos.y, plant_raw->growths[i]->timing_1, plant_raw->growths[i]->timing_2); + if ((!farming || seedSource) && (istree || isripe) && !picked(plant, i)) { return Designations::markPlant(plant); } @@ -429,7 +429,7 @@ command_result df_getplants (color_ostream &out, vector & parameters) // plantSelections[i] = selectablePlant(out, plant, farming); plantSelections[i] = selectablePlant(plant, farming); } - else if (plantNames.find(plant->id) != plantNames.end()) + else if (plantNames.find(plant->id) != plantNames.end()) { plantNames.erase(plant->id); // plantSelections[i] = selectablePlant(out, plant, farming); From 21ebd778b1774716b68022058f59375ce3a6e3ec Mon Sep 17 00:00:00 2001 From: gearsix Date: Sat, 28 Jan 2023 22:05:36 +0000 Subject: [PATCH 3/4] updated changelog --- docs/changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 8d84e3cff..3db740589 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,6 +37,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - Fix issues with clicks "passing through" some DFHack window elements, like scrollbars +- `plugin/getplants`: tree are now designated correctly ## Misc Improvements - A new cross-compile build script was added for building the Windows files from a Linux Docker builder (see the Compile instructions in the docs) @@ -46,6 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `gui/quickcmd`: now has it's own global keybinding for your convenience: Ctrl-Shift-A - Many DFHack windows can now be unfocused by clicking somewhere not over the tool window. This has the same effect as pinning previously did, but without the extra clicking. - `overlay`: overlay widgets can now specify a default enabled state if they are not already set in the player's overlay config file +- `plugin/getplants`: ID values will now be accepted regardless of case ## Documentation From 549ccfa3c0b9d25b05ecf4b9a81561af4591a344 Mon Sep 17 00:00:00 2001 From: Myk Date: Sun, 29 Jan 2023 10:53:05 -0800 Subject: [PATCH 4/4] Apply suggestions from code review --- docs/changelog.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 6db8e0616..f7fe08455 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,7 +37,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes -@ Fix issues with clicks "passing through" some DFHack window elements, like scrollbars -- `plugin/getplants`: tree are now designated correctly +- `getplants`: tree are now designated correctly ## Misc Improvements - A new cross-compile build script was added for building the Windows files from a Linux Docker builder (see the Compile instructions in the docs) @@ -47,7 +47,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `gui/quickcmd`: now has it's own global keybinding for your convenience: Ctrl-Shift-A - Many DFHack windows can now be unfocused by clicking somewhere not over the tool window. This has the same effect as pinning previously did, but without the extra clicking. - `overlay`: overlay widgets can now specify a default enabled state if they are not already set in the player's overlay config file -- `plugin/getplants`: ID values will now be accepted regardless of case +- `getplants`: ID values will now be accepted regardless of case -@ New borders for DFHack tool windows -- tell us what you think! ## Documentation