Skip to content

Commit dd32554

Browse files
committed
Merge branch 'develop' of gh:dfhack/dfhack into develop
2 parents fb940b8 + c8cd2f4 commit dd32554

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

plugins/labormanager/labormanager.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,8 @@ class AutoLaborManager {
11751175

11761176
void collect_dwarf_list()
11771177
{
1178+
state_count.clear();
1179+
state_count.resize(NUM_STATE);
11781180

11791181
for (auto u = world->units.active.begin(); u != world->units.active.end(); ++u)
11801182
{
@@ -1373,6 +1375,8 @@ class AutoLaborManager {
13731375
if (print_debug)
13741376
out.print("Dwarf \"%s\": state %s %d\n", dwarf->dwarf->name.first_name.c_str(), state_names[dwarf->state], dwarf->clear_all);
13751377

1378+
state_count[dwarf->state]++;
1379+
13761380
// determine if dwarf has medical needs
13771381
if (dwarf->dwarf->health && !(
13781382
// on-duty military will not necessarily break to get minor injuries attended
@@ -1516,11 +1520,12 @@ class AutoLaborManager {
15161520

15171521
if (labor == df::unit_labor::CUTWOOD)
15181522
{
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+
}
15241529
}
15251530

15261531
score -= Units::computeMovementSpeed(d->dwarf);

0 commit comments

Comments
 (0)