Skip to content

Commit ed9e6c8

Browse files
authored
Merge pull request #4031 from ab9rf/tailor-4023
exclude nonclothing from tailor's scan
2 parents bf128bd + de19efa commit ed9e6c8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Template for new versions:
8484
- `sort`: when filtering out already-established temples in the location assignment screen, also filter out the "No specific deity" option if a non-denominational temple has already been established
8585
- RemoteServer: continue to accept connections as long as the listening socket is valid instead of closing the socket after the first disconnect
8686
- `buildingplan`: overlay and filter editor gui now uses ctrl-d to delete the filter to avoid conflict with increasing the filter's minimum quality (shift-x)
87+
- `tailor`: fix crash on Linux where scanned unit is wearing damaged non-clothing (e.g. a crown)
8788

8889
## Misc Improvements
8990
- `buildingplan`: display how many items are available on the planner panel

plugins/tailor.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ class Tailor {
277277
{
278278
if (inv->mode != df::unit_inventory_item::Worn)
279279
continue;
280+
// skip non-clothing
281+
if (!inv->item->isClothing())
282+
continue;
280283
if (inv->item->getWear() > 0)
281284
worn.push_back(inv->item);
282285
else
@@ -288,9 +291,17 @@ class Tailor {
288291

289292
for (auto w : worn)
290293
{
294+
// skip armor
295+
if (w->getEffectiveArmorLevel() > 0)
296+
continue;
297+
291298
auto ty = w->getType();
292299

293-
int isize = world->raws.creatures.all[w->getMakerRace()]->adultsize;
300+
auto makerRace = w->getMakerRace();
301+
if (makerRace < 0 || makerRace >= (int16_t) world->raws.creatures.all.size())
302+
continue;
303+
304+
int isize = world->raws.creatures.all[makerRace]->adultsize;
294305
std::string description;
295306
w->getItemDescription(&description, 0);
296307

0 commit comments

Comments
 (0)