Fix labormanager crash when a dwarf doesn't have a cultural identity

develop
Ben Lubar 2017-11-23 10:55:37 -06:00
parent 0ee421a9d4
commit e06644cdf4
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24
1 changed files with 10 additions and 5 deletions

@ -1175,6 +1175,8 @@ private:
void collect_dwarf_list()
{
state_count.clear();
state_count.resize(NUM_STATE);
for (auto u = world->units.active.begin(); u != world->units.active.end(); ++u)
{
@ -1373,6 +1375,8 @@ private:
if (print_debug)
out.print("Dwarf \"%s\": state %s %d\n", dwarf->dwarf->name.first_name.c_str(), state_names[dwarf->state], dwarf->clear_all);
state_count[dwarf->state]++;
// determine if dwarf has medical needs
if (dwarf->dwarf->health && !(
// on-duty military will not necessarily break to get minor injuries attended
@ -1516,12 +1520,13 @@ private:
if (labor == df::unit_labor::CUTWOOD)
{
auto c_id = d->dwarf->cultural_identity;
auto culture = world->cultural_identities.all[c_id];
if (auto culture = df::cultural_identity::find(d->dwarf->cultural_identity))
{
auto ethics = culture->ethic[df::ethic_type::KILL_PLANT];
if (ethics != df::ethic_response::NOT_APPLICABLE && ethics != df::ethic_response::REQUIRED)
score += 10000 * (df::ethic_response::ACCEPTABLE - ethics);
}
}
score -= Units::computeMovementSpeed(d->dwarf);