Merge pull request #2706 from ab9rf/5005-alpha3-tailor

tailor: avoid bad key exception in std::map
develop
Myk 2023-01-23 23:51:36 -08:00 committed by GitHub
commit e1fd88b195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}
}
}