@@ -1175,6 +1175,8 @@ class AutoLaborManager {
1175
1175
1176
1176
void collect_dwarf_list ()
1177
1177
{
1178
+ state_count.clear ();
1179
+ state_count.resize (NUM_STATE);
1178
1180
1179
1181
for (auto u = world->units .active .begin (); u != world->units .active .end (); ++u)
1180
1182
{
@@ -1373,6 +1375,8 @@ class AutoLaborManager {
1373
1375
if (print_debug)
1374
1376
out.print (" Dwarf \" %s\" : state %s %d\n " , dwarf->dwarf ->name .first_name .c_str (), state_names[dwarf->state ], dwarf->clear_all );
1375
1377
1378
+ state_count[dwarf->state ]++;
1379
+
1376
1380
// determine if dwarf has medical needs
1377
1381
if (dwarf->dwarf ->health && !(
1378
1382
// on-duty military will not necessarily break to get minor injuries attended
@@ -1516,11 +1520,12 @@ class AutoLaborManager {
1516
1520
1517
1521
if (labor == df::unit_labor::CUTWOOD)
1518
1522
{
1519
- auto c_id = d->dwarf ->cultural_identity ;
1520
- auto culture = world->cultural_identities .all [c_id];
1521
- auto ethics = culture->ethic [df::ethic_type::KILL_PLANT];
1522
- if (ethics != df::ethic_response::NOT_APPLICABLE && ethics != df::ethic_response::REQUIRED)
1523
- score += 10000 * (df::ethic_response::ACCEPTABLE - ethics);
1523
+ if (auto culture = df::cultural_identity::find (d->dwarf ->cultural_identity ))
1524
+ {
1525
+ auto ethics = culture->ethic [df::ethic_type::KILL_PLANT];
1526
+ if (ethics != df::ethic_response::NOT_APPLICABLE && ethics != df::ethic_response::REQUIRED)
1527
+ score += 10000 * (df::ethic_response::ACCEPTABLE - ethics);
1528
+ }
1524
1529
}
1525
1530
1526
1531
score -= Units::computeMovementSpeed (d->dwarf );
0 commit comments