============ Cmd_ExecuteString A complete command line has been parsed, so try to execute it ============ */
| 700 | ============ |
| 701 | */ |
| 702 | void 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 | ============ |
no test coverage detected