Merge pull request #3893 from myk002/myk_tailor

[tailor] reuse existing orders if possible
develop
Myk 2023-10-16 09:43:51 -07:00 committed by GitHub
commit 06944ee0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 16 deletions

@ -81,6 +81,7 @@ Template for new versions:
- `zone`: animals trained for war or hunting are now labeled as such in animal assignment screens
- `buildingplan`: support filtering cages by whether they are occupied
- `buildingplan`: show how many items you need to make when planning buildings
- `tailor`: now adds to existing orders if possilbe instead of creating new ones
## Documentation
- unavailable tools are no longer listed in the tag indices in the online docs

@ -425,7 +425,6 @@ public:
int size = world->raws.creatures.all[race]->adultsize;
auto tt = jobTypeMap.find(o->job_type);
if (tt == jobTypeMap.end())
{
@ -441,6 +440,21 @@ public:
}
static df::manager_order * get_existing_order(df::job_type ty, int16_t sub, int32_t hfid, df::job_material_category mcat) {
for (auto order : world->manager_orders) {
if (order->job_type == ty &&
order->item_type == df::item_type::NONE &&
order->item_subtype == sub &&
order->mat_type == -1 &&
order->mat_index == -1 &&
order->hist_figure_id == hfid &&
order->material_category.whole == mcat.whole &&
order->frequency == df::manager_order::T_frequency::OneTime)
return order;
}
return NULL;
}
int place_orders()
{
int ordered = 0;
@ -532,7 +546,14 @@ public:
}
supply[m] -= c;
auto order = new df::manager_order;
auto order = get_existing_order(ty, sub, sizes[size], m.job_material);
if (order) {
if (order->amount_total > 0) {
order->amount_left += c;
order->amount_total += c;
}
} else {
order = new df::manager_order;
order->job_type = ty;
order->item_type = df::item_type::NONE;
order->item_subtype = sub;
@ -547,6 +568,7 @@ public:
order->material_category = m.job_material;
world->manager_orders.push_back(order);
}
INFO(cycle).print("tailor: added order #%d for %d %s %s, sized for %s\n",
order->id,