From 242fee748aea55f45cbb048376b2228e7c111224 Mon Sep 17 00:00:00 2001 From: LightHardt Date: Wed, 23 Jul 2025 23:27:27 -0500 Subject: [PATCH 1/5] Add clear option to autoclothing that will unset a previosly set order --- docs/plugins/autoclothing.rst | 4 ++++ plugins/autoclothing.cpp | 32 +++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/docs/plugins/autoclothing.rst b/docs/plugins/autoclothing.rst index 1ea1a9094f..02d13c83a7 100644 --- a/docs/plugins/autoclothing.rst +++ b/docs/plugins/autoclothing.rst @@ -22,6 +22,7 @@ Usage autoclothing autoclothing autoclothing + autoclothing clear ```` can be "cloth", "silk", "yarn", or "leather". The ```` can be anything your civilization can produce, such as "dress" or "mitten". @@ -43,6 +44,9 @@ Examples long as there is cloth available to make them out of). ``autoclothing cloth dress`` Displays the currently set number of cloth dresses chosen per citizen. +``autoclothing clear cloth "short skirt"`` + Unsets cloth short skirts from being made if previously enabled such as + in the first example Which should I enable: autoclothing or tailor? ---------------------------------------------- diff --git a/plugins/autoclothing.cpp b/plugins/autoclothing.cpp index fac721a5c5..96f81ecd2e 100644 --- a/plugins/autoclothing.cpp +++ b/plugins/autoclothing.cpp @@ -129,6 +129,15 @@ struct ClothingRequirement { bool SetFromParameters(color_ostream &out, vector ¶meters) { + if (parameters[0] == "clear") { // handle the clear case + if (!set_bitfield_field(&material_category, parameters[1], 1)) + out << "Unrecognized material type: " << parameters[1] << endl; + if (!setItem(parameters[2], this)) { + out << "Unrecognized item name or token: " << parameters[2] << endl; + return false; + } + return true; + } if (!set_bitfield_field(&material_category, parameters[0], 1)) out << "Unrecognized material type: " << parameters[0] << endl; if (!setItem(parameters[1], this)) { @@ -442,14 +451,20 @@ command_result autoclothing(color_ostream &out, vector ¶meters) bool settingSize = false; bool matchedExisting = false; if (parameters.size() > 2) { - try { - newRequirement.needed_per_citizen = std::stoi(parameters[2]); + if (parameters[0] == "clear") { + newRequirement.needed_per_citizen = 0; + settingSize = true; } - catch (const std::exception&) { - out << parameters[2] << " is not a valid number." << endl; - return CR_WRONG_USAGE; + else { + try { + newRequirement.needed_per_citizen = std::stoi(parameters[2]); + } + catch (const std::exception&) { + out << parameters[2] << " is not a valid number." << endl; + return CR_WRONG_USAGE; + } + settingSize = true; } - settingSize = true; } for (size_t i = clothingOrders.size(); i-- > 0;) { @@ -459,7 +474,10 @@ command_result autoclothing(color_ostream &out, vector ¶meters) if (settingSize) { if (newRequirement.needed_per_citizen == 0) { clothingOrders.erase(clothingOrders.begin() + i); - out << "Unset " << parameters[0] << " " << parameters[1] << endl; + if (parameters[0] == "clear") + out << "Unset " << parameters[1] << " " << parameters[2] << endl; + else + out << "Unset " << parameters[0] << " " << parameters[1] << endl; } else { clothingOrders[i] = newRequirement; From 8f745d58d69c379998f9ecab8af0f68d79b7895e Mon Sep 17 00:00:00 2001 From: LightHardt Date: Thu, 24 Jul 2025 12:14:24 -0500 Subject: [PATCH 2/5] Add missing function `validateMaterialCategory` to the `clear` case for parameters --- plugins/autoclothing.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/autoclothing.cpp b/plugins/autoclothing.cpp index 96f81ecd2e..a4516f4dce 100644 --- a/plugins/autoclothing.cpp +++ b/plugins/autoclothing.cpp @@ -136,6 +136,10 @@ struct ClothingRequirement { out << "Unrecognized item name or token: " << parameters[2] << endl; return false; } + else if (!validateMaterialCategory(this)) { + out << parameters[1] << " is not a valid material category for " << parameters[2] << endl; + return false; + } return true; } if (!set_bitfield_field(&material_category, parameters[0], 1)) From 30aa982b31ce465af8b5b18ab6790b945d8b0076 Mon Sep 17 00:00:00 2001 From: LightHardt Date: Thu, 24 Jul 2025 12:35:36 -0500 Subject: [PATCH 3/5] Update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 0fe8c6e9f4..f9b4d82f9b 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: ## Fixes ## Misc Improvements +- `autoclothing`: Added a `clear` option to unset previously set orders ## Documentation From 83f7b908613a6adcf51ea0445d1e2eecf7b8cb7f Mon Sep 17 00:00:00 2001 From: LightHardt Date: Thu, 24 Jul 2025 12:38:38 -0500 Subject: [PATCH 4/5] Update changelog --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index f9b4d82f9b..ae86e46667 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,7 +58,7 @@ Template for new versions: ## Fixes ## Misc Improvements -- `autoclothing`: Added a `clear` option to unset previously set orders +- `autoclothing`: Added a ``clear`` option to unset previously set orders ## Documentation From 1f31ec73e135a8179d3905453330ad95b3563697 Mon Sep 17 00:00:00 2001 From: LightHardt Date: Thu, 24 Jul 2025 12:43:41 -0500 Subject: [PATCH 5/5] realized all others start lowercase changing to conform --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index ae86e46667..2acfe5c922 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,7 +58,7 @@ Template for new versions: ## Fixes ## Misc Improvements -- `autoclothing`: Added a ``clear`` option to unset previously set orders +- `autoclothing`: added a ``clear`` option to unset previously set orders ## Documentation