Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search?
(String text)
| 284 | * FIXME: lookupnoadd the token to speed search? |
| 285 | */ |
| 286 | public static void ExecuteString(String text) { |
| 287 | Com.DPrintf("Executing command: " + text + "\n"); |
| 288 | |
| 289 | if (text.trim().startsWith("//")) |
| 290 | return; |
| 291 | |
| 292 | List<String> args = TokenizeString(text, true); |
| 293 | |
| 294 | // execute the command line |
| 295 | if (args.size() == 0) |
| 296 | return; // no tokens |
| 297 | |
| 298 | // check functions |
| 299 | cmd_function_t cmd = cmd_functions.get(args.get(0)); |
| 300 | if (cmd != null) { |
| 301 | cmd.function.execute(args); |
| 302 | return; |
| 303 | } |
| 304 | |
| 305 | // check alias |
| 306 | for (cmdalias_t alias : cmd_alias.values()) { |
| 307 | if (args.get(0).equalsIgnoreCase(alias.getName())) { |
| 308 | if (++Globals.alias_count == ALIAS_LOOP_COUNT) { |
| 309 | Com.Printf("ALIAS_LOOP_COUNT\n"); |
| 310 | return; |
| 311 | } |
| 312 | Cbuf.InsertText(alias.getValue()); |
| 313 | return; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | // check cvars |
| 318 | if (Cvar.getInstance().printOrSet(args)) |
| 319 | return; |
| 320 | |
| 321 | // send it as a server command if we are connected |
| 322 | // fixme: do not send if we are the server |
| 323 | if (text.startsWith("cmd")) { |
| 324 | Com.Printf("did not execute " + text + "\n"); |
| 325 | } else { |
| 326 | Cmd.ExecuteString("cmd " + text); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Find commands or aliases by prefix |