Faster stockflow mode, ignoring the bookkeeper.

develop
Eric Wald 2014-08-03 15:14:20 -06:00
parent 2ebebaf62f
commit 1aba6a6739
1 changed files with 19 additions and 5 deletions

@ -31,6 +31,7 @@ DFHACK_PLUGIN_IS_ENABLED(enabled);
bool enabled = false;
#endif
bool fast = false;
const char *tagline = "Allows the fortress bookkeeper to queue jobs through the manager.";
const char *usage = (
" stockflow enable\n"
@ -59,11 +60,19 @@ class LuaHelper {
public:
void cycle(color_ostream &out) {
bool found = false;
for (df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next) {
if (link->item == NULL) continue;
if (link->item->job_type == job_type::UpdateStockpileRecords) {
found = true;
break;
if (fast) {
// Ignore the bookkeeper; either gather or enqueue orders every cycle.
found = !bookkeeping;
} else {
// Gather orders when the bookkeeper starts updating stockpile records,
// and enqueue them when the job is done.
for (df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next) {
if (link->item == NULL) continue;
if (link->item->job_type == job_type::UpdateStockpileRecords) {
found = true;
break;
}
}
}
@ -307,8 +316,13 @@ static command_result stockflow_cmd(color_ostream &out, vector <string> & parame
if (parameters.size() == 1) {
if (parameters[0] == "enable" || parameters[0] == "on" || parameters[0] == "1") {
desired = true;
fast = false;
} else if (parameters[0] == "disable" || parameters[0] == "off" || parameters[0] == "0") {
desired = false;
fast = false;
} else if (parameters[0] == "fast" || parameters[0] == "always" || parameters[0] == "2") {
desired = true;
fast = true;
} else if (parameters[0] == "usage" || parameters[0] == "help" || parameters[0] == "?") {
out.print("%s: %s\nUsage:\n%s", name, tagline, usage);
return CR_OK;