| 174 | // |
| 175 | |
| 176 | static command_result do_command(color_ostream &out, vector <string> & parameters) |
| 177 | { |
| 178 | if (!Core::getInstance().isMapLoaded() || !World::IsSiteLoaded()) { |
| 179 | out.printerr("Cannot run {} without a loaded fort.\n", plugin_name); |
| 180 | return CR_FAILURE; |
| 181 | } |
| 182 | |
| 183 | const size_t num_params = parameters.size(); |
| 184 | |
| 185 | if (num_params > 2 || (num_params > 1 && parameters[0] == "help")) |
| 186 | return CR_WRONG_USAGE; |
| 187 | |
| 188 | if (num_params == 0 || parameters[0] == "status") { |
| 189 | out.print("Current state: fast = {}, teleport = {}.\n", |
| 190 | config.get_int(CONFIG_FAST), |
| 191 | config.get_int(CONFIG_TELE)); |
| 192 | return CR_OK; |
| 193 | } |
| 194 | |
| 195 | int fast = string_to_int(parameters[0]); |
| 196 | int tele = num_params >= 2 ? string_to_int(parameters[1]) : 0; |
| 197 | |
| 198 | if (fast < 0 || fast > 2) { |
| 199 | out.printerr("Invalid value for fast: '{}'", parameters[0]); |
| 200 | return CR_WRONG_USAGE; |
| 201 | } |
| 202 | if (tele < 0 || tele > 1) { |
| 203 | out.printerr("Invalid value for tele: '{}'", parameters[1]); |
| 204 | return CR_WRONG_USAGE; |
| 205 | } |
| 206 | |
| 207 | set_state(out, fast, tele); |
| 208 | |
| 209 | return CR_OK; |
| 210 | } |
nothing calls this directly
no test coverage detected