MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Cmd_ExecuteString

Function Cmd_ExecuteString

code/qcommon/cmd.cpp:702–755  ·  view source on GitHub ↗

============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it ============ */

Source from the content-addressed store, hash-verified

700============
701*/
702void Cmd_ExecuteString( const char *text ) {
703 cmd_function_t *cmd, **prev;
704
705 // execute the command line
706 Cmd_TokenizeString( text );
707 if ( !Cmd_Argc() ) {
708 return; // no tokens
709 }
710
711 // check registered command functions
712 for ( prev = &cmd_functions ; *prev ; prev = &cmd->next ) {
713 cmd = *prev;
714 if ( !Q_stricmp( Cmd_Argv(0), cmd->name ) ) {
715 // rearrange the links so that the command will be
716 // near the head of the list next time it is used
717 *prev = cmd->next;
718 cmd->next = cmd_functions;
719 cmd_functions = cmd;
720
721 // perform the action
722 if ( !cmd->function ) {
723 // let the cgame or game handle it
724 break;
725 } else {
726 cmd->function ();
727 }
728 return;
729 }
730 }
731
732 // check cvars
733 if ( Cvar_Command() ) {
734 return;
735 }
736
737 // check client game commands
738 if ( com_cl_running && com_cl_running->integer && CL_GameCommand() ) {
739 return;
740 }
741
742 // check server game commands
743 if ( com_sv_running && com_sv_running->integer && SV_GameCommand() ) {
744 return;
745 }
746
747 // check ui commands
748 if ( com_cl_running && com_cl_running->integer && UI_GameCommand() ) {
749 return;
750 }
751
752 // send it as a server command if we are connected
753 // this will usually result in a chat message
754 CL_ForwardCommandToServer ();
755}
756
757/*
758============

Callers 2

Cbuf_ExecuteTextFunction · 0.70
Cbuf_ExecuteFunction · 0.70

Calls 9

Q_stricmpFunction · 0.85
Cmd_TokenizeStringFunction · 0.70
Cmd_ArgcFunction · 0.70
Cmd_ArgvFunction · 0.70
Cvar_CommandFunction · 0.70
CL_GameCommandFunction · 0.50
SV_GameCommandFunction · 0.50
UI_GameCommandFunction · 0.50

Tested by

no test coverage detected