diff --git a/docs/changelog.txt b/docs/changelog.txt index 3956615ec5..5d1e6d8e4f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -59,6 +59,7 @@ Template for new versions: ## New Features ## Fixes +- `autoclothing`: correct defect in validating material specification on command line - `getplants`: added protective code to avoid misoperation when a plant has an invalid material (which should never happen, but...) ## Misc Improvements diff --git a/plugins/autoclothing.cpp b/plugins/autoclothing.cpp index 01b6290aff..d9b718f0ba 100644 --- a/plugins/autoclothing.cpp +++ b/plugins/autoclothing.cpp @@ -145,19 +145,22 @@ struct ClothingRequirement { return std::nullopt; } - if (auto req = setItem(parameters[idx+1]); !req) + auto req = setItem(parameters[idx + 1]); + + if (!req) { out << "Unrecognized item name or token: " << parameters[idx+1] << endl; return std::nullopt; } - else if (!validateMaterialCategory(*req)) { + req->material_category = material_category; + + if (!validateMaterialCategory(*req)) { out << parameters[idx] << " is not a valid material category for " << parameters[idx+1] << endl; return std::nullopt; } else { - req->material_category = material_category; return req; } }