MCPcopy Create free account
hub / github.com/DFHack/dfhack / print_constraint

Function print_constraint

plugins/workflow.cpp:1558–1639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1556}
1557
1558static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job = false, std::string prefix = "")
1559{
1560 Console::color_value color;
1561 if (cv->request_resume)
1562 color = COLOR_GREEN;
1563 else if (cv->request_suspend)
1564 color = COLOR_CYAN;
1565 else
1566 color = COLOR_DARKGREY;
1567
1568 out.color(color);
1569 out << prefix << "Constraint " << flush;
1570 out.color(COLOR_GREY);
1571 out << cv->config.val() << " " << flush;
1572 out.color(color);
1573 out << (cv->goalByCount() ? "count " : "amount ")
1574 << cv->goalCount() << " (gap " << cv->goalGap() << ")" << endl;
1575 out.reset_color();
1576
1577 if (cv->item_count || cv->item_inuse_count)
1578 out << prefix << " items: amount " << cv->item_amount << "; "
1579 << cv->item_count << " stacks available, "
1580 << cv->item_inuse_count << " in use." << endl;
1581
1582 if (no_job) return;
1583
1584 if (cv->jobs.empty())
1585 out.printerr(" (no jobs)\n");
1586
1587 std::vector<ProtectedJob*> unique_jobs;
1588 std::vector<int> unique_counts;
1589
1590 for (size_t i = 0; i < cv->jobs.size(); i++)
1591 {
1592 ProtectedJob *pj = cv->jobs[i];
1593 for (size_t j = 0; j < unique_jobs.size(); j++)
1594 {
1595 if (unique_jobs[j]->building_id == pj->building_id &&
1596 *unique_jobs[j]->actual_job == *pj->actual_job)
1597 {
1598 unique_counts[j]++;
1599 goto next_job;
1600 }
1601 }
1602
1603 unique_jobs.push_back(pj);
1604 unique_counts.push_back(1);
1605 next_job:;
1606 }
1607
1608 for (size_t i = 0; i < unique_jobs.size(); i++)
1609 {
1610 ProtectedJob *pj = unique_jobs[i];
1611 df::job *job = pj->actual_job;
1612
1613 std::string start = prefix + " " + shortJobDescription(job);
1614
1615 if (!pj->isActuallyResumed())

Callers 2

print_jobFunction · 0.85
workflow_cmdFunction · 0.85

Calls 9

shortJobDescriptionFunction · 0.85
goalByCountMethod · 0.80
goalCountMethod · 0.80
goalGapMethod · 0.80
isActuallyResumedMethod · 0.80
colorMethod · 0.45
reset_colorMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected