summaryrefslogtreecommitdiff
path: root/plugins/workflow.cpp
diff options
context:
space:
mode:
authorTimothy Collett2012-09-10 11:54:56 -0400
committerTimothy Collett2012-09-10 11:54:56 -0400
commit96abc903abb93b7bf7418f2da3455ee6da5ad942 (patch)
treea5326ef1dbd492086b319c888854e707c59d2a56 /plugins/workflow.cpp
parent274d6038adce5797b58cee78a330eb5d639bf59e (diff)
parent21904fd607d0f2037782e28ff7284300663931ab (diff)
downloaddfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.gz
dfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.bz2
dfhack-96abc903abb93b7bf7418f2da3455ee6da5ad942.tar.xz
Merge branch 'master' of http://github.com/peterix/dfhack
Diffstat (limited to 'plugins/workflow.cpp')
-rw-r--r--plugins/workflow.cpp60
1 files changed, 42 insertions, 18 deletions
diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp
index 9e0e4529..98258682 100644
--- a/plugins/workflow.cpp
+++ b/plugins/workflow.cpp
@@ -20,6 +20,7 @@
#include "df/job_list_link.h"
#include "df/dfhack_material_category.h"
#include "df/item.h"
+#include "df/item_quality.h"
#include "df/items_other_id.h"
#include "df/tool_uses.h"
#include "df/general_ref.h"
@@ -283,6 +284,8 @@ struct ItemConstraint {
int weight;
std::vector<ProtectedJob*> jobs;
+ item_quality::item_quality min_quality;
+
int item_amount, item_count, item_inuse;
bool request_suspend, request_resume;
@@ -292,8 +295,8 @@ struct ItemConstraint {
public:
ItemConstraint()
- : is_craft(false), weight(0), item_amount(0), item_count(0), item_inuse(0)
- , is_active(false), cant_resume_reported(false)
+ : is_craft(false), weight(0), min_quality(item_quality::Ordinary),item_amount(0),
+ item_count(0), item_inuse(0), is_active(false), cant_resume_reported(false)
{}
int goalCount() { return config.ival(0); }
@@ -646,7 +649,7 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
std::vector<std::string> tokens;
split_string(&tokens, str, "/");
- if (tokens.size() > 3)
+ if (tokens.size() > 4)
return NULL;
int weight = 0;
@@ -670,10 +673,10 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
out.printerr("Cannot decode material mask: %s\n", maskstr.c_str());
return NULL;
}
-
+
if (mat_mask.whole != 0)
weight += 100;
-
+
MaterialInfo material;
std::string matstr = vector_get(tokens,2);
if (!matstr.empty() && (!material.find(matstr) || !material.isValid())) {
@@ -681,6 +684,21 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
return NULL;
}
+ item_quality::item_quality minqual = item_quality::Ordinary;
+ std::string qualstr = vector_get(tokens, 3);
+ if(!qualstr.empty()) {
+ if(qualstr == "ordinary") minqual = item_quality::Ordinary;
+ else if(qualstr == "wellcrafted") minqual = item_quality::WellCrafted;
+ else if(qualstr == "finelycrafted") minqual = item_quality::FinelyCrafted;
+ else if(qualstr == "superior") minqual = item_quality::Superior;
+ else if(qualstr == "exceptional") minqual = item_quality::Exceptional;
+ else if(qualstr == "masterful") minqual = item_quality::Masterful;
+ else {
+ out.printerr("Cannot find quality: %s\nKnown qualities: ordinary, wellcrafted, finelycrafted, superior, exceptional, masterful\n", qualstr.c_str());
+ return NULL;
+ }
+ }
+
if (material.type >= 0)
weight += (material.index >= 0 ? 5000 : 1000);
@@ -694,7 +712,8 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
ItemConstraint *ct = constraints[i];
if (ct->is_craft == is_craft &&
ct->item == item && ct->material == material &&
- ct->mat_mask.whole == mat_mask.whole)
+ ct->mat_mask.whole == mat_mask.whole &&
+ ct->min_quality == minqual)
return ct;
}
@@ -703,6 +722,7 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
nct->item = item;
nct->material = material;
nct->mat_mask = mat_mask;
+ nct->min_quality = minqual;
nct->weight = weight;
if (cfg)
@@ -1179,6 +1199,9 @@ static void map_job_items(color_ostream &out)
(cv->item.subtype != -1 && cv->item.subtype != isubtype))
continue;
}
+ if(item->getQuality() < cv->min_quality) {
+ continue;
+ }
TMaterialCache::iterator it = cv->material_cache.find(matkey);
@@ -1357,15 +1380,15 @@ static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job
{
Console::color_value color;
if (cv->request_resume)
- color = Console::COLOR_GREEN;
+ color = COLOR_GREEN;
else if (cv->request_suspend)
- color = Console::COLOR_CYAN;
+ color = COLOR_CYAN;
else
- color = Console::COLOR_DARKGREY;
+ color = COLOR_DARKGREY;
out.color(color);
out << prefix << "Constraint " << flush;
- out.color(Console::COLOR_GREY);
+ out.color(COLOR_GREY);
out << cv->config.val() << " " << flush;
out.color(color);
out << (cv->goalByCount() ? "count " : "amount ")
@@ -1414,18 +1437,18 @@ static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job
{
if (pj->want_resumed)
{
- out.color(Console::COLOR_YELLOW);
+ out.color(COLOR_YELLOW);
out << start << " (delayed)" << endl;
}
else
{
- out.color(Console::COLOR_BLUE);
+ out.color(COLOR_BLUE);
out << start << " (suspended)" << endl;
}
}
else
{
- out.color(Console::COLOR_GREEN);
+ out.color(COLOR_GREEN);
out << start << endl;
}
@@ -1449,11 +1472,11 @@ static void print_job(color_ostream &out, ProtectedJob *pj)
isOptionEnabled(CF_AUTOMELT))
{
if (meltable_count <= 0)
- out.color(Console::COLOR_CYAN);
+ out.color(COLOR_CYAN);
else if (pj->want_resumed && !pj->isActuallyResumed())
- out.color(Console::COLOR_YELLOW);
+ out.color(COLOR_YELLOW);
else
- out.color(Console::COLOR_GREEN);
+ out.color(COLOR_GREEN);
out << " Meltable: " << meltable_count << " objects." << endl;
out.reset_color();
}
@@ -1480,13 +1503,14 @@ static command_result workflow_cmd(color_ostream &out, vector <string> & paramet
}
df::building *workshop = NULL;
- df::job *job = NULL;
+ //FIXME: unused variable!
+ //df::job *job = NULL;
if (Gui::dwarfmode_hotkey(Core::getTopViewscreen()) &&
ui->main.mode == ui_sidebar_mode::QueryBuilding)
{
workshop = world->selected_building;
- job = Gui::getSelectedWorkshopJob(out, true);
+ //job = Gui::getSelectedWorkshopJob(out, true);
}
std::string cmd = parameters.empty() ? "list" : parameters[0];