| 546 | } |
| 547 | |
| 548 | static void do_cycle(color_ostream& out, |
| 549 | int32_t& melt_count, int32_t& trade_count, |
| 550 | int32_t& dump_count, int32_t& train_count, |
| 551 | int32_t& forbid_count, int32_t& claim_count) { |
| 552 | DEBUG(cycle,out).print("running {} cycle\n", plugin_name); |
| 553 | cycle_timestamp = world->frame_counter; |
| 554 | |
| 555 | ProcessorStats melt_stats, trade_stats, dump_stats, train_stats, forbid_stats, claim_stats; |
| 556 | unordered_map<df::building_stockpilest *, PersistentDataItem> cache; |
| 557 | validate_stockpile_configs(out, cache); |
| 558 | |
| 559 | for (auto &entry : cache) { |
| 560 | df::building_stockpilest *bld = entry.first; |
| 561 | PersistentDataItem &c = entry.second; |
| 562 | int32_t stockpile_number = bld->stockpile_number; |
| 563 | |
| 564 | bool melt = c.get_bool(STOCKPILE_CONFIG_MELT); |
| 565 | bool melt_masterworks = c.get_bool(STOCKPILE_CONFIG_MELT_MASTERWORKS); |
| 566 | bool trade = c.get_bool(STOCKPILE_CONFIG_TRADE); |
| 567 | bool dump = c.get_bool(STOCKPILE_CONFIG_DUMP); |
| 568 | bool train = c.get_bool(STOCKPILE_CONFIG_TRAIN); |
| 569 | bool forbid = STOCKPILE_CONFIG_FORBID_FORBID == c.get_int(STOCKPILE_CONFIG_FORBID); |
| 570 | bool claim = STOCKPILE_CONFIG_FORBID_CLAIM == c.get_int(STOCKPILE_CONFIG_FORBID); |
| 571 | |
| 572 | MeltStockProcessor melt_stock_processor(stockpile_number, melt, melt_stats, melt_masterworks); |
| 573 | TradeStockProcessor trade_stock_processor(stockpile_number, trade, trade_stats); |
| 574 | DumpStockProcessor dump_stock_processor(stockpile_number, dump, dump_stats); |
| 575 | TrainStockProcessor train_stock_processor(stockpile_number, train, train_stats); |
| 576 | ForbidStockProcessor forbid_stock_processor(stockpile_number, forbid, forbid_stats); |
| 577 | ClaimStockProcessor claim_stock_processor(stockpile_number, claim, claim_stats); |
| 578 | |
| 579 | scan_stockpile(out, bld, |
| 580 | melt_stock_processor, trade_stock_processor, |
| 581 | dump_stock_processor, train_stock_processor, |
| 582 | forbid_stock_processor, claim_stock_processor); |
| 583 | } |
| 584 | |
| 585 | melt_count = melt_stats.newly_designated; |
| 586 | trade_count = trade_stats.newly_designated; |
| 587 | dump_count = dump_stats.newly_designated; |
| 588 | train_count = train_stats.newly_designated; |
| 589 | forbid_count = forbid_stats.newly_designated; |
| 590 | claim_count = claim_stats.newly_designated; |
| 591 | |
| 592 | if (config.get_bool(CONFIG_TRAIN_PARTIAL)) { |
| 593 | train_partials(out, train_count); |
| 594 | } |
| 595 | |
| 596 | TRACE(cycle,out).print("exit {} do_cycle\n", plugin_name); |
| 597 | } |
| 598 | |
| 599 | ///////////////////////////////////////////////////// |
| 600 | // Lua API |
no test coverage detected