There was one more place for autoclothing to crash.

develop
Rose 2023-01-29 17:51:10 -08:00
parent c79b95ec33
commit c9ddb4d943
1 changed files with 6 additions and 2 deletions

@ -520,7 +520,7 @@ static void find_needed_clothing_items()
int alreadyOwnedAmount = 0; int alreadyOwnedAmount = 0;
//looping through the items first, then clothing order might be a little faster, but this way is cleaner. //looping through the items first, then clothing order might be a little faster, but this way is cleaner.
for (auto& ownedItem : unit->owned_items) for (auto ownedItem : unit->owned_items)
{ {
auto item = findItemByID(ownedItem); auto item = findItemByID(ownedItem);
@ -782,8 +782,12 @@ static void generate_report(color_ostream& out)
int numArmor = 0, numShoes = 0, numHelms = 0, numGloves = 0, numPants = 0; int numArmor = 0, numShoes = 0, numHelms = 0, numGloves = 0, numPants = 0;
for (auto itemId : unit->owned_items) for (auto itemId : unit->owned_items)
{ {
auto item = Items::findItemByID(itemId); auto item = Items::findItemByID(itemId);
if (!item)
{
WARN(cycle).print("Invalid inventory item ID: %d\n", itemId);
continue;
}
if (item->getWear() >= 1) if (item->getWear() >= 1)
continue; continue;
switch (item->getType()) switch (item->getType())