implement tameable property filtering

develop
Myk Taylor 2023-05-28 05:37:29 -07:00
parent 0c5339982a
commit 760cd0cbcb
No known key found for this signature in database
3 changed files with 32 additions and 8 deletions

Binary file not shown.

@ -134,12 +134,14 @@ entire category, or with a filter, any matchable subset thereof::
cat_weapons
cat_wood
There is also an ``everything`` file that includes all the above categories,
including refuse and corpses.
In addition, there are files for ``all``, which includes all categories except
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
you can match with filters and convenient pre-made settings files that
manipulate interesting category subsets.
For many of the categories, there are also flags, subcategory prefixes, and
item properties that you can match with filters. In addition, there are
normally at least a few convenient pre-made settings files that manipulate
interesting category subsets.
Ammo stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -172,6 +174,10 @@ Flags::
cages
traps
Properties::
tameable
Settings files::
cages
@ -274,6 +280,13 @@ Notes:
* ``thread`` and ``cloth`` settings files set all materials that are not
adamantine.
Corpse stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Properties::
tameable
Finished goods stockpile adjustments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -295,7 +308,7 @@ Settings files::
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
Food stockpile adjustments
@ -404,6 +417,10 @@ Flags and subcategory prefixes::
teeth/
horns/
Properties::
tameable
Settings files::
rawhides

@ -11,6 +11,7 @@
// df
#include "df/building_stockpilest.h"
#include "df/creature_raw.h"
#include "df/caste_raw.h"
#include "df/inorganic_raw.h"
#include "df/item_quality.h"
#include <df/itemdef_ammost.h>
@ -611,6 +612,12 @@ static bool serialize_list_creature(FuncWriteExport add_value, const vector<char
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,
FuncReadImport read_value, int32_t list_size, vector<char>& pile_list) {
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) {
for (size_t idx = 0; idx < num_elems; ++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;
}
@ -631,7 +638,7 @@ static void unserialize_list_creature(const char* subcat, bool all, char val, co
continue;
}
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));
}
}