Autolabor: adjust idle clawback to deal with "pickup equipment" for miners.

develop
Kelly Martin 2013-01-01 17:53:24 -06:00
parent d50aa24ebf
commit 41615d0446
1 changed files with 18 additions and 11 deletions

@ -1809,14 +1809,6 @@ private:
} }
else else
{ {
FOR_ENUM_ITEMS(unit_labor, l)
{
if (l == df::unit_labor::NONE)
continue;
if (dwarf->dwarf->status.labors[l])
labor_infos[l].idle_dwarfs++;
}
state = IDLE; state = IDLE;
} }
} }
@ -1836,7 +1828,6 @@ private:
if (labor != df::unit_labor::NONE) if (labor != df::unit_labor::NONE)
{ {
dwarf->using_labor = labor; dwarf->using_labor = labor;
labor_infos[labor].busy_dwarfs++;
if (!dwarf->dwarf->status.labors[labor] && print_debug) if (!dwarf->dwarf->status.labors[labor] && print_debug)
{ {
@ -1850,6 +1841,18 @@ private:
dwarf->state = state; dwarf->state = state;
FOR_ENUM_ITEMS(unit_labor, l)
{
if (l == df::unit_labor::NONE)
continue;
if (dwarf->dwarf->status.labors[l])
if (state == IDLE)
labor_infos[l].idle_dwarfs++;
else if (state == BUSY)
labor_infos[l].busy_dwarfs++;
}
if (print_debug) 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); out.print("Dwarf \"%s\": state %s %d\n", dwarf->dwarf->name.first_name.c_str(), state_names[dwarf->state], dwarf->clear_all);
@ -2058,11 +2061,15 @@ public:
continue; continue;
if (labor_infos[l].idle_dwarfs > 0 && labor_needed[l] > labor_infos[l].busy_dwarfs) if (labor_infos[l].idle_dwarfs > 0 && labor_needed[l] > labor_infos[l].busy_dwarfs)
{ {
int clawback = labor_infos[l].busy_dwarfs;
if (clawback == 0 && labor_needed[l] > 0)
clawback = 1;
if (print_debug) if (print_debug)
out.print("reducing labor %s to %d (%d needed, %d busy, %d idle)\n", ENUM_KEY_STR(unit_labor, l).c_str(), out.print("reducing labor %s to %d (%d needed, %d busy, %d idle)\n", ENUM_KEY_STR(unit_labor, l).c_str(),
labor_infos[l].busy_dwarfs, clawback,
labor_needed[l], labor_infos[l].busy_dwarfs, labor_infos[l].idle_dwarfs); labor_needed[l], labor_infos[l].busy_dwarfs, labor_infos[l].idle_dwarfs);
labor_needed[l] = labor_infos[l].busy_dwarfs; labor_needed[l] = clawback;
} }
} }