MCPcopy Create free account
hub / github.com/demoth/jake2 / ExecuteString

Method ExecuteString

qcommon/src/main/java/jake2/qcommon/exec/Cmd.java:286–328  ·  view source on GitHub ↗

Cmd_ExecuteString A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search?

(String text)

Source from the content-addressed store, hash-verified

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

Callers 5

HandleEventsMethod · 0.95
SVC_RemoteCommandMethod · 0.95
testSampleCommandMethod · 0.95
ExecuteMethod · 0.95

Calls 11

DPrintfMethod · 0.95
TokenizeStringMethod · 0.95
PrintfMethod · 0.95
InsertTextMethod · 0.95
getInstanceMethod · 0.95
sizeMethod · 0.80
getValueMethod · 0.80
printOrSetMethod · 0.80
executeMethod · 0.65
getNameMethod · 0.65
getMethod · 0.45

Tested by 2

testSampleCommandMethod · 0.76