Skip to content

Commit 0ac1aad

Browse files
authored
Merge pull request #5848 from ab9rf/autoclothing-commandparsing
`autoclothing`: correct command line parsing of material specification
2 parents 44fd108 + 6798e9b commit 0ac1aad

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Template for new versions:
5959
## New Features
6060

6161
## Fixes
62+
- `autoclothing`: correct defect in validating material specification on command line
6263
- `autolabor`: Fix running 1 tick less frequently than intended.
6364
- `buildingplan`: fixed non-clickable pressure plates's triggers (issue #5736)
6465
- `getplants`: added protective code to avoid misoperation when a plant has an invalid material (which should never happen, but...)

plugins/autoclothing.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,22 @@ struct ClothingRequirement {
145145
return std::nullopt;
146146
}
147147

148-
if (auto req = setItem(parameters[idx+1]); !req)
148+
auto req = setItem(parameters[idx + 1]);
149+
150+
if (!req)
149151
{
150152
out << "Unrecognized item name or token: " << parameters[idx+1] << endl;
151153
return std::nullopt;
152154
}
153155

154-
else if (!validateMaterialCategory(*req)) {
156+
req->material_category = material_category;
157+
158+
if (!validateMaterialCategory(*req)) {
155159
out << parameters[idx] << " is not a valid material category for " << parameters[idx+1] << endl;
156160
return std::nullopt;
157161
}
158162
else
159163
{
160-
req->material_category = material_category;
161164
return req;
162165
}
163166
}

0 commit comments

Comments
 (0)