From e160fec2b964ea6e4b9478c5419a22e746d5437d Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 13 Feb 2016 17:17:28 -0700 Subject: [PATCH 1/2] Ignoring forbidden rough gems --- plugins/autogems.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/autogems.cpp b/plugins/autogems.cpp index 1079dff44..2ca99721f 100644 --- a/plugins/autogems.cpp +++ b/plugins/autogems.cpp @@ -107,6 +107,23 @@ void add_tasks(gem_map &gem_types, df::building_workshopst *workshop) { } } +bool valid_gem(df::item* item) { + if (item->getType() != item_type::ROUGH) return false; + if (item->getMaterial() != builtin_mats::INORGANIC) return false; + if (item->flags.bits.in_job) return false; + if (item->flags.bits.forbid) return false; + if (item->flags.bits.dump) return false; + if (item->flags.bits.owned) return false; + if (item->flags.bits.trader) return false; + if (item->flags.bits.hostile) return false; + if (item->flags.bits.removed) return false; + if (item->flags.bits.encased) return false; + if (item->flags.bits.construction) return false; + if (item->flags.bits.garbage_collect) return false; + if (item->flags.bits.in_building) return false; + return true; +} + void create_jobs() { // Creates jobs in Jeweler's Workshops as necessary. // Todo: Consider path availability? @@ -137,7 +154,7 @@ void create_jobs() { Buildings::StockpileIterator stored; for (stored.begin(stockpile); !stored.done(); ++stored) { auto item = *stored; - if (item->getType() == item_type::ROUGH && item->getMaterial() == builtin_mats::INORGANIC) { + if (valid_gem(item)) { stockpiled.insert(item->id); piled[item->getMaterialIndex()] += 1; } @@ -182,8 +199,7 @@ void create_jobs() { auto gems = world->items.other[items_other_id::ROUGH]; for (auto g = gems.begin(); g != gems.end(); ++g) { auto item = *g; - // ROUGH also includes raw glass; the INORGANIC check filters that out. - if (item->getMaterial() == builtin_mats::INORGANIC && !stockpiled.count(item->id)) { + if (valid_gem(item) && !stockpiled.count(item->id)) { available[item->getMaterialIndex()] += 1; } } From 224d29de88f0607244bad10ea9a1a2d0587c3b9d Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 13 Feb 2016 21:01:00 -0700 Subject: [PATCH 2/2] Reversing o-W-g autogems default setting Starter pack users have complained that it's too big a change from vanilla, particularly given that strange moods need rough gems. --- plugins/autogems.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/autogems.cpp b/plugins/autogems.cpp index 2ca99721f..9bdfcb02c 100644 --- a/plugins/autogems.cpp +++ b/plugins/autogems.cpp @@ -284,7 +284,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan if (enabled && World::isFortressMode()) { // Determine whether auto gem cutting has been disabled for this fort. auto config = World::GetPersistentData(CONFIG_KEY); - running = !(config.isValid() && config.ival(0)); + running = config.isValid() && !config.ival(0); last_frame_count = world->frame_counter; } } else if (event == DFHack::SC_MAP_UNLOADED) { @@ -302,9 +302,9 @@ DFhackCExport command_result plugin_enable(color_ostream& out, bool enable) { } enabled = enable; - running = enabled && World::isFortressMode(); } + running = enabled && World::isFortressMode(); return CR_OK; }