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

Function do_command

plugins/pet-uncapper.cpp:127–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127command_result do_command(color_ostream &out, vector<string> & parameters) {
128 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
129 out.printerr("Cannot run {} without a loaded fort.\n", plugin_name);
130 return CR_FAILURE;
131 }
132
133 if (parameters.size() == 0 || parameters[0] == "status") {
134 out.print("{} is {}\n\n", plugin_name, is_enabled ? "enabled" : "not enabled");
135 out.print("population cap per species: {}\n", config.get_int(CONFIG_POP_CAP));
136 out.print("updating pregnancies every {} ticks\n", config.get_int(CONFIG_FREQ));
137 out.print("pregancies last {} ticks\n", config.get_int(CONFIG_PREG_TIME));
138 } else if (parameters[0] == "now") {
139 impregnateMany(out, true);
140 } else {
141 if (parameters.size() < 2)
142 return CR_WRONG_USAGE;
143 string command = parameters[0];
144 int val = std::max(0, string_to_int(parameters[1]));
145 if (command == "cap")
146 config.set_int(CONFIG_POP_CAP, val);
147 else if (command == "every")
148 config.set_int(CONFIG_FREQ, val);
149 else if (command == "pregtime")
150 config.set_int(CONFIG_PREG_TIME, val);
151 else
152 return CR_WRONG_USAGE;
153 }
154
155 return CR_OK;
156}
157
158DFhackCExport command_result plugin_init(color_ostream &out, vector<PluginCommand> &commands) {
159 commands.push_back(PluginCommand(

Callers

nothing calls this directly

Calls 4

impregnateManyFunction · 0.85
string_to_intFunction · 0.85
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected