Merge pull request #3429 from myk002/myk_route_settings

[stockpiles] implement tameable property filtering
develop
Myk 2023-05-29 12:33:52 -07:00 committed by GitHub
commit 6be59de0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 8 deletions

Binary file not shown.

@ -63,6 +63,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- Window behavior: non-resizable windows now allow dragging by their frame edges by default - Window behavior: non-resizable windows now allow dragging by their frame edges by default
- `gui/autodump`: fort-mode keybinding: Ctrl-H - `gui/autodump`: fort-mode keybinding: Ctrl-H
- Window behavior: if you have multiple DFHack tool windows open, scrolling the mouse wheel while over an unfocused window will focus it and raise it to the top - Window behavior: if you have multiple DFHack tool windows open, scrolling the mouse wheel while over an unfocused window will focus it and raise it to the top
- `stockpiles`: allow filtering creatures by tameability
## Documentation ## Documentation

@ -134,12 +134,14 @@ entire category, or with a filter, any matchable subset thereof::
cat_weapons cat_weapons
cat_wood cat_wood
There is also an ``everything`` file that includes all the above categories, In addition, there are files for ``all``, which includes all categories except
including refuse and corpses. refuse and corpses (mirroring the "all" configuration in-game), and
``everything``, which really includes all categories.
For many of the categories, there are also flags and subcategory prefixes that For many of the categories, there are also flags, subcategory prefixes, and
you can match with filters and convenient pre-made settings files that item properties that you can match with filters. In addition, there are
manipulate interesting category subsets. normally at least a few convenient pre-made settings files that manipulate
interesting category subsets.
Ammo stockpile adjustments Ammo stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -172,6 +174,10 @@ Flags::
cages cages
traps traps
Properties::
tameable
Settings files:: Settings files::
cages cages
@ -274,6 +280,13 @@ Notes:
* ``thread`` and ``cloth`` settings files set all materials that are not * ``thread`` and ``cloth`` settings files set all materials that are not
adamantine. adamantine.
Corpse stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Properties::
tameable
Finished goods stockpile adjustments Finished goods stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -295,7 +308,7 @@ Settings files::
Example commands for a toy stockpile:: Example commands for a toy stockpile::
stockpiles import cat_furniture -f mats/,other/,core/,total/ stockpiles import cat_finished_goods -f mats/,other/,core/,total/
stockpiles import -m enable toys stockpiles import -m enable toys
Food stockpile adjustments Food stockpile adjustments
@ -404,6 +417,10 @@ Flags and subcategory prefixes::
teeth/ teeth/
horns/ horns/
Properties::
tameable
Settings files:: Settings files::
rawhides rawhides

@ -11,6 +11,7 @@
// df // df
#include "df/building_stockpilest.h" #include "df/building_stockpilest.h"
#include "df/creature_raw.h" #include "df/creature_raw.h"
#include "df/caste_raw.h"
#include "df/inorganic_raw.h" #include "df/inorganic_raw.h"
#include "df/item_quality.h" #include "df/item_quality.h"
#include <df/itemdef_ammost.h> #include <df/itemdef_ammost.h>
@ -611,6 +612,12 @@ static bool serialize_list_creature(FuncWriteExport add_value, const vector<char
return all; return all;
} }
static string get_filter_string(df::creature_raw *r) {
if (!r->caste.size() || !r->caste[0]->flags.is_set(df::enums::caste_raw_flags::PET))
return r->name[0];
return r->name[0] + "/tameable";
}
static void unserialize_list_creature(const char* subcat, bool all, char val, const vector<string>& filters, static void unserialize_list_creature(const char* subcat, bool all, char val, const vector<string>& filters,
FuncReadImport read_value, int32_t list_size, vector<char>& pile_list) { FuncReadImport read_value, int32_t list_size, vector<char>& pile_list) {
size_t num_elems = world->raws.creatures.all.size(); size_t num_elems = world->raws.creatures.all.size();
@ -618,7 +625,7 @@ static void unserialize_list_creature(const char* subcat, bool all, char val, co
if (all) { if (all) {
for (size_t idx = 0; idx < num_elems; ++idx) { for (size_t idx = 0; idx < num_elems; ++idx) {
auto r = find_creature(idx); auto r = find_creature(idx);
set_filter_elem(subcat, filters, val, r->name[0], r->creature_id, pile_list.at(idx)); set_filter_elem(subcat, filters, val, get_filter_string(r), r->creature_id, pile_list.at(idx));
} }
return; return;
} }
@ -631,7 +638,7 @@ static void unserialize_list_creature(const char* subcat, bool all, char val, co
continue; continue;
} }
auto r = find_creature(idx); auto r = find_creature(idx);
set_filter_elem(subcat, filters, val, r->name[0], r->creature_id, pile_list.at(idx)); set_filter_elem(subcat, filters, val, get_filter_string(r), r->creature_id, pile_list.at(idx));
} }
} }