autolabor: add ConstructBuilding (Farm); change priority calculation

develop
Kelly Martin 2012-12-01 17:39:01 -06:00
parent bb2b97baa3
commit 15f7ffa0e2
1 changed files with 19 additions and 13 deletions

@ -727,16 +727,19 @@ private:
switch (bld->getType())
{
case df::building_type::Workshop:
df::building_workshopst* ws = (df::building_workshopst*) bld;
if (ws->type == df::workshop_type::Custom)
{
df::building_def* def = df::building_def::find(ws->custom_type);
return def->build_labors[0];
}
else
return workshop_build_labor[ws->type];
df::building_workshopst* ws = (df::building_workshopst*) bld;
if (ws->type == df::workshop_type::Custom)
{
df::building_def* def = df::building_def::find(ws->custom_type);
return def->build_labors[0];
}
else
return workshop_build_labor[ws->type];
}
break;
case df::building_type::FarmPlot:
return df::unit_labor::PLANT;
}
// FIXME
@ -1830,7 +1833,7 @@ public:
for (auto i = labor_needed.begin(); i != labor_needed.end(); i++)
{
if (i->second > 0)
pq.push(make_pair(i->second, i->first));
pq.push(make_pair(100, i->first));
}
if (print_debug)
@ -1839,11 +1842,11 @@ public:
while (!idle_dwarfs.empty() && !pq.empty())
{
df::unit_labor labor = pq.top().second;
int remaining = pq.top().first;
int priority = pq.top().first;
df::job_skill skill = labor_to_skill[labor];
if (print_debug)
out.print("labor %s skill %s remaining %d\n", ENUM_KEY_STR(unit_labor, labor).c_str(), ENUM_KEY_STR(job_skill, skill).c_str(), remaining);
out.print("labor %s skill %s priority %d\n", ENUM_KEY_STR(unit_labor, labor).c_str(), ENUM_KEY_STR(job_skill, skill).c_str(), priority);
std::list<dwarf_info_t*>::iterator bestdwarf = idle_dwarfs.begin();
@ -1870,8 +1873,11 @@ public:
idle_dwarfs.erase(bestdwarf);
pq.pop();
if (--remaining)
pq.push(make_pair(remaining, labor));
if (--labor_needed[labor] > 0)
{
priority /= 2;
pq.push(make_pair(priority, labor));
}
}
print_debug = 0;