tailor: avoid bad key exception in std::map

develop
Kelly Kinkade 2023-01-23 22:24:45 -06:00
parent 5ad6ce16e8
commit f640d15355
1 changed files with 13 additions and 4 deletions

@ -249,7 +249,12 @@ private:
for (auto w : worn)
{
auto ty = w->getType();
auto o = itemTypeMap.at(ty);
auto oo = itemTypeMap.find(ty);
if (oo == itemTypeMap.end())
{
continue;
}
const df::job_type o = oo->second;
int size = world->raws.creatures.all[w->getMakerRace()]->adultsize;
std::string description;
@ -330,9 +335,13 @@ private:
}
}
const df::job_type j = itemTypeMap.at(ty);
orders[std::make_tuple(j, sub, size)] += count;
DEBUG(cycle).print("tailor: %s times %d of size %d ordered\n", ENUM_KEY_STR(job_type, j).c_str(), count, size);
auto jj = itemTypeMap.find(ty);
if (jj != itemTypeMap.end())
{
const df::job_type j = jj->second;
orders[std::make_tuple(j, sub, size)] += count;
DEBUG(cycle).print("tailor: %s times %d of size %d ordered\n", ENUM_KEY_STR(job_type, j).c_str(), count, size);
}
}
}