Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protecting assigned wheelbarrows in autodump-enabled stockpiles (logistics plugin?) #3430

Closed
wsfsbvchr opened this issue May 29, 2023 · 1 comment

Comments

@wsfsbvchr
Copy link

So, (in 0.47.05) I started using autodump for certain stockpiles, but occasionally the wheelbarrows assigned for those stockpiles get marked for dumping as well. It might be because of interrupted hauling jobs, after which the wheelbarrows have to be hauled back, or it might be because of something else.

Looks like the logic handling that is this: https://github.com/DFHack/dfhack/blob/develop/plugins/autodump.cpp#L56C2-L61

One way to do it would be to check the id of the item that's possibly being marked for dumping against what's listed under building.container_item_id, which seems to contain the ids of the wheelbarrows, and building.container_type can be used to determine whether the container item is actually a wheelbarrow or not.

Dunno what it should do for bins or barrels assigned for the stockpile. Dump or not dump, or empty and dump, or dump and empty? That could vary, but it's pretty clear that the wheelbarrows shouldn't be dumped.

@myk002
Copy link
Member

myk002 commented Jun 19, 2023

I believe this is fixed in the new logistics plugin with the new scanning logic:

static void scan_stockpile(color_ostream &out, df::building_stockpilest *bld,
        MeltStockProcessor &melt_stock_processor,
        TradeStockProcessor &trade_stock_processor,
        DumpStockProcessor &dump_stock_processor,
        TrainStockProcessor &train_stock_processor) {
    auto id = bld->id;
    Buildings::StockpileIterator items;
    for (items.begin(bld); !items.done(); ++items) {
        df::item *item = *items;
        scan_item(out, item, trade_stock_processor);
        if (0 == (item->flags.whole & bad_flags.whole) &&
                item->isAssignedToThisStockpile(id)) {
            TRACE(cycle,out).print("assignedToStockpile\n");
            vector<df::item *> contents;
            Items::getContainedItems(item, &contents);
            for (df::item *contained_item : contents) {
                scan_item(out, contained_item, melt_stock_processor);
                scan_item(out, contained_item, dump_stock_processor);
            }
            continue;
        }
        scan_item(out, item, melt_stock_processor);
        scan_item(out, item, dump_stock_processor);
        scan_item(out, item, train_stock_processor);
    }
}

note the check for item->isAssignedToThisStockpile(id) in the if clause

@myk002 myk002 closed this as completed Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants