Implement a low stock level announcement as suggested by falconne.

develop
Alexander Gavrilov 2012-12-02 15:31:43 +04:00
parent 9703d3fd8f
commit dc7f9f56cd
2 changed files with 20 additions and 2 deletions

@ -43,6 +43,7 @@ DFHack future
- logic fix: collecting webs produces silk, and ungathered webs are not thread.
- items assigned to squads are considered busy, even if not in inventory.
- shearing and milking jobs are supported, but only with generic MILK or YARN outputs.
- workflow announces when the stock level gets very low once a season.
New Fix Armory plugin:
Together with a couple of binary patches and the gui/assign-rack script,
this plugin makes weapon racks, armor stands, chests and cabinets in

@ -322,6 +322,7 @@ struct ItemConstraint {
bool request_suspend, request_resume;
bool is_active, cant_resume_reported;
int low_stock_reported;
TMaterialCache material_cache;
@ -329,7 +330,7 @@ public:
ItemConstraint()
: is_craft(false), min_quality(item_quality::Ordinary), is_local(false),
weight(0), item_amount(0), item_count(0), item_inuse_amount(0), item_inuse_count(0),
is_active(false), cant_resume_reported(false)
is_active(false), cant_resume_reported(false), low_stock_reported(-1)
{}
int goalCount() { return config.ival(0); }
@ -349,6 +350,8 @@ public:
config.ival(2) &= ~1;
}
int curItemStock() { return goalByCount() ? item_count : item_amount; }
void init(const std::string &str)
{
config.val() = str;
@ -358,7 +361,7 @@ public:
void computeRequest()
{
int size = goalByCount() ? item_count : item_amount;
int size = curItemStock();
request_resume = (size <= goalCount()-goalGap());
request_suspend = (size >= goalCount());
}
@ -1323,6 +1326,20 @@ static void update_jobs_by_constraints(color_ostream &out)
else if (ct->mat_mask.whole)
info = bitfield_to_string(ct->mat_mask) + " " + info;
if (ct->low_stock_reported != DF_GLOBAL_VALUE(cur_season,-1))
{
int count = ct->goalCount(), gap = ct->goalGap();
if (count >= gap*3 && ct->curItemStock() < std::min(gap*2, (count-gap)/2))
{
ct->low_stock_reported = DF_GLOBAL_VALUE(cur_season,-1);
Gui::showAnnouncement("Stock level is low: " + info, COLOR_BROWN, true);
}
else
ct->low_stock_reported = -1;
}
if (is_running != ct->is_active)
{
if (is_running && ct->request_resume)