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