From 41615d044616b0f0790f8b950d1f7e18674deb2c Mon Sep 17 00:00:00 2001 From: Kelly Martin Date: Tue, 1 Jan 2013 17:53:24 -0600 Subject: [PATCH] Autolabor: adjust idle clawback to deal with "pickup equipment" for miners. --- plugins/autolabor.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 5157bda61..7068ad5fb 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -1809,14 +1809,6 @@ private: } 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; } } @@ -1836,7 +1828,6 @@ private: if (labor != df::unit_labor::NONE) { dwarf->using_labor = labor; - labor_infos[labor].busy_dwarfs++; if (!dwarf->dwarf->status.labors[labor] && print_debug) { @@ -1850,6 +1841,18 @@ private: 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) 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; 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) 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_needed[l] = clawback; } }