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

Function labormanager

plugins/autolabor/labormanager.cpp:1977–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1975}
1976
1977command_result labormanager(color_ostream &out, std::vector <std::string> & parameters)
1978{
1979 if (!Core::getInstance().isWorldLoaded()) {
1980 out.printerr("World is not loaded: please load a game first.\n");
1981 return CR_FAILURE;
1982 }
1983
1984 if (parameters.size() == 1 &&
1985 (parameters[0] == "enable" || parameters[0] == "disable"))
1986 {
1987 bool enable = (parameters[0] == "enable");
1988 return plugin_enable(out, enable);
1989 }
1990 else if (parameters.size() == 3 &&
1991 (parameters[0] == "max" || parameters[0] == "priority"))
1992 {
1993 if (!enable_labormanager)
1994 {
1995 out << "Error: The plugin is not enabled." << endl;
1996 return CR_FAILURE;
1997 }
1998
1999 df::unit_labor labor = lookup_labor_by_name(parameters[1]);
2000
2001 if (labor == df::unit_labor::NONE)
2002 {
2003 out.printerr("Could not find labor %s.\n", parameters[0].c_str());
2004 return CR_WRONG_USAGE;
2005 }
2006
2007 int v;
2008
2009 if (parameters[2] == "none")
2010 v = MAX_DWARFS_NONE;
2011 else if (parameters[2] == "disable" || parameters[2] == "unmanaged")
2012 v = MAX_DWARFS_UNMANAGED;
2013 else
2014 v = atoi(parameters[2].c_str());
2015
2016 if (parameters[0] == "max")
2017 labor_infos[labor].set_maximum_dwarfs(v);
2018 else if (parameters[0] == "priority")
2019 labor_infos[labor].set_priority(v);
2020
2021 print_labor(labor, out);
2022 return CR_OK;
2023 }
2024 else if (parameters.size() == 2 && parameters[0] == "reset")
2025 {
2026 if (!enable_labormanager)
2027 {
2028 out << "Error: The plugin is not enabled." << endl;
2029 return CR_FAILURE;
2030 }
2031
2032 df::unit_labor labor = lookup_labor_by_name(parameters[1]);
2033
2034 if (labor == df::unit_labor::NONE)

Callers

nothing calls this directly

Calls 9

lookup_labor_by_nameFunction · 0.85
c_strMethod · 0.80
set_priorityMethod · 0.80
print_laborFunction · 0.70
reset_laborFunction · 0.70
setOptionEnabledFunction · 0.70
sizeMethod · 0.45
set_maximum_dwarfsMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected