| 601 | // |
| 602 | |
| 603 | static int logistics_getStockpileData(lua_State *L) { |
| 604 | color_ostream *out = Lua::GetOutput(L); |
| 605 | if (!out) |
| 606 | out = &Core::getInstance().getConsole(); |
| 607 | DEBUG(control,*out).print("entering logistics_getStockpileData\n"); |
| 608 | |
| 609 | unordered_map<df::building_stockpilest *, PersistentDataItem> cache; |
| 610 | validate_stockpile_configs(*out, cache); |
| 611 | |
| 612 | ProcessorStats melt_stats, trade_stats, dump_stats, train_stats, forbid_stats, claim_stats; |
| 613 | |
| 614 | for (auto bld : world->buildings.other.STOCKPILE) { |
| 615 | int32_t stockpile_number = bld->stockpile_number; |
| 616 | MeltStockProcessor melt_stock_processor(stockpile_number, false, melt_stats, false); |
| 617 | TradeStockProcessor trade_stock_processor(stockpile_number, false, trade_stats); |
| 618 | DumpStockProcessor dump_stock_processor(stockpile_number, false, dump_stats); |
| 619 | TrainStockProcessor train_stock_processor(stockpile_number, false, train_stats); |
| 620 | ForbidStockProcessor forbid_stock_processor(stockpile_number, false, forbid_stats); |
| 621 | ClaimStockProcessor claim_stock_processor(stockpile_number, false, claim_stats); |
| 622 | |
| 623 | scan_stockpile(*out, bld, |
| 624 | melt_stock_processor, trade_stock_processor, |
| 625 | dump_stock_processor, train_stock_processor, |
| 626 | forbid_stock_processor, claim_stock_processor); |
| 627 | } |
| 628 | |
| 629 | unordered_map<string, StatMap> stats; |
| 630 | stats.emplace("melt_designated", melt_stats.designated_counts); |
| 631 | stats.emplace("melt_can_designate", melt_stats.can_designate_counts); |
| 632 | stats.emplace("trade_designated", trade_stats.designated_counts); |
| 633 | stats.emplace("trade_can_designate", trade_stats.can_designate_counts); |
| 634 | stats.emplace("dump_designated", dump_stats.designated_counts); |
| 635 | stats.emplace("dump_can_designate", dump_stats.can_designate_counts); |
| 636 | stats.emplace("train_designated", train_stats.designated_counts); |
| 637 | stats.emplace("train_can_designate", train_stats.can_designate_counts); |
| 638 | stats.emplace("forbid_designated", forbid_stats.designated_counts); |
| 639 | stats.emplace("forbid_can_designate", forbid_stats.can_designate_counts); |
| 640 | stats.emplace("claim_designated", claim_stats.designated_counts); |
| 641 | stats.emplace("claim_can_designate", claim_stats.can_designate_counts); |
| 642 | Lua::Push(L, stats); |
| 643 | |
| 644 | unordered_map<int32_t, unordered_map<string, string>> configs; |
| 645 | for (auto &entry : cache) { |
| 646 | df::building_stockpilest *bld = entry.first; |
| 647 | PersistentDataItem &c = entry.second; |
| 648 | |
| 649 | bool melt = c.get_bool(STOCKPILE_CONFIG_MELT); |
| 650 | bool melt_masterworks = c.get_bool(STOCKPILE_CONFIG_MELT_MASTERWORKS); |
| 651 | bool trade = c.get_bool(STOCKPILE_CONFIG_TRADE); |
| 652 | bool dump = c.get_bool(STOCKPILE_CONFIG_DUMP); |
| 653 | bool train = c.get_bool(STOCKPILE_CONFIG_TRAIN); |
| 654 | bool forbid = STOCKPILE_CONFIG_FORBID_FORBID == c.get_int(STOCKPILE_CONFIG_FORBID); |
| 655 | bool claim = STOCKPILE_CONFIG_FORBID_CLAIM == c.get_int(STOCKPILE_CONFIG_FORBID); |
| 656 | |
| 657 | unordered_map<string, string> sconfig; |
| 658 | sconfig.emplace("melt", melt ? "true" : "false"); |
| 659 | sconfig.emplace("melt_masterworks", melt_masterworks ? "true" : "false"); |
| 660 | sconfig.emplace("trade", trade ? "true" : "false"); |
nothing calls this directly
no test coverage detected