cmd.c File Reference

Script command processing module Command text buffering. Any number of commands can be added in a frame, from several different sources. Most commands come from either keyBindings or console line input, but remote servers can also send across commands and entire text files can be accessed. More...

#include "common.h"
#include "msg.h"
#include "../shared/parse.h"
Include dependency graph for cmd.c:

Go to the source code of this file.

Data Structures

struct  cmd_alias_s
struct  cmd_function_s

Defines

#define ALIAS_HASH_SIZE   32
#define MAX_ALIAS_NAME   32
#define ALIAS_LOOP_COUNT   16
#define CMD_BUFFER_SIZE   8192
#define CMD_HASH_SIZE   32

Typedefs

typedef struct cmd_alias_s cmd_alias_t
typedef struct cmd_function_s cmd_function_t

Functions

void Cmd_ForwardToServer (void)
 adds the current command line as a clc_stringcmd to the client message. things like action, turn, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded.
static void Cmd_Open_f (void)
 Reopens the command buffer for writing.
static void Cmd_Close_f (void)
 Will no longer add any command to command buffer ...until cmd_close is qfalse again.
static void Cmd_Wait_f (void)
 Causes execution of the remainder of the command buffer to be delayed until next frame. This allows commands like: bind g "impulse 5; +attack; wait; -attack; impulse 2".
void Cbuf_Init (void)
 allocates an initial text buffer that will grow as needed
void Cbuf_AddText (const char *text)
 Adds command text at the end of the buffer.
void Cbuf_InsertText (const char *text)
 Adds command text immediately after the current command.
void Cbuf_CopyToDefer (void)
 Defers any outstanding commands.
void Cbuf_InsertFromDefer (void)
 Copies back any deferred commands.
void Cbuf_Execute (void)
 Pulls off
terminated lines of text from the command buffer and sends them through Cmd_ExecuteString. Stops when the buffer is empty. Normally called once per frame, but may be explicitly invoked. Do not call inside a command function!
void Cbuf_AddEarlyCommands (qboolean clear)
 Adds command line parameters as script statements Commands lead with a +, and continue until another + Set commands are added early, so they are guaranteed to be set before the client and server initialize for the first time. Other commands are added late, after all initialization is complete.
qboolean Cbuf_AddLateCommands (void)
 Adds command line parameters as script statements.
static void Cmd_Exec_f (void)
static void Cmd_Echo_f (void)
 Just prints the rest of the line to the console.
static void Cmd_Alias_f (void)
 Creates a new command that executes a command string (possibly ; separated).
void Cmd_WriteAliases (qFILE *f)
 Write lines containing "aliasa alias value" for all aliases with the archive flag set to true.
int Cmd_Argc (void)
 The functions that execute commands get their parameters with these functions. Cmd_Argv() will return an empty string, not a NULL if arg > argc, so string operations are always safe.
const char * Cmd_Argv (int arg)
 Returns a given argument.
const char * Cmd_Args (void)
 Returns a single string containing argv(1) to argv(argc()-1).
void * Cmd_Userdata (void)
 Return the userdata of the called command.
void Cmd_BufClear (void)
 Clears the argv vector and set argc to zero.
void Cmd_TokenizeString (const char *text, qboolean macroExpand)
 Parses the given string into command line tokens.
const char * Cmd_GetCommandDesc (const char *cmd_name)
 Returns the command description for a given command.
int Cmd_GenericCompleteFunction (size_t len, const char **match, int matches, const char **list)
void Cmd_AddParamCompleteFunction (const char *cmd_name, int(*function)(const char *partial, const char **match))
void * Cmd_GetUserdata (const char *cmd_name)
 Fetches the userdata for a console command.
void Cmd_AddUserdata (const char *cmd_name, void *userdata)
 Adds userdata to the console command.
void Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *desc)
 Add a new command to the script interface.
void Cmd_RemoveCommand (const char *cmd_name)
 Removes a command from script interface.
qboolean Cmd_Exists (const char *cmd_name)
 Checks whether a function exists already.
int Cmd_CompleteCommandParameters (const char *command, const char *partial, const char **match)
 Unix like tab completion for console commands parameters.
int Cmd_CompleteCommand (const char *partial, const char **match)
 Unix like tab completion for console commands.
void Cmd_ExecuteString (const char *text)
 A complete command line has been parsed, so try to execute it.
static void Cmd_List_f (void)
 List all available script interface functions.
static int Cmd_CompleteExecCommand (const char *partial, const char **match)
 Autocomplete function for exec command.
void Cmd_Dummy_f (void)
 Dummy binding if you don't want unknown commands forwarded to the server.
void Cmd_Init (void)
void Cmd_Shutdown (void)

Variables

static cmd_alias_tcmd_alias
static cmd_alias_tcmd_alias_hash [ALIAS_HASH_SIZE]
static qboolean cmdWait
static qboolean cmdClosed
static int alias_count
static sizebuf_t cmd_text
static byte cmd_text_buf [CMD_BUFFER_SIZE]
static char defer_text_buf [CMD_BUFFER_SIZE]
static int cmd_argc
static char * cmd_argv [MAX_STRING_TOKENS]
static char cmd_args [MAX_STRING_CHARS]
static void * cmd_userdata
static cmd_function_tcmd_functions
static cmd_function_tcmd_functions_hash [CMD_HASH_SIZE]

Detailed Description

Script command processing module Command text buffering. Any number of commands can be added in a frame, from several different sources. Most commands come from either keyBindings or console line input, but remote servers can also send across commands and entire text files can be accessed.

The + command line options are also added to the command buffer.

Command execution takes a null terminated string, breaks it into tokens, then searches for a command or variable that matches the first token.

Definition in file cmd.c.


Define Documentation

#define ALIAS_HASH_SIZE   32

Definition at line 39 of file cmd.c.

Referenced by Cmd_Alias_f(), and Cmd_ExecuteString().

#define ALIAS_LOOP_COUNT   16

Definition at line 56 of file cmd.c.

Referenced by Cmd_ExecuteString().

#define CMD_BUFFER_SIZE   8192

Definition at line 97 of file cmd.c.

#define CMD_HASH_SIZE   32
#define MAX_ALIAS_NAME   32

Definition at line 41 of file cmd.c.

Referenced by Cmd_Alias_f().


Typedef Documentation

typedef struct cmd_alias_s cmd_alias_t

Function Documentation

void Cbuf_AddEarlyCommands ( qboolean  clear  ) 

Adds command line parameters as script statements Commands lead with a +, and continue until another + Set commands are added early, so they are guaranteed to be set before the client and server initialize for the first time. Other commands are added late, after all initialization is complete.

adds all the +set commands from the command line

See also:
Cbuf_AddLateCommands

Definition at line 260 of file cmd.c.

References Cbuf_AddText(), Com_Argc(), Com_Argv(), Com_ClearArgv(), i, and va().

Referenced by Qcommon_Init().

qboolean Cbuf_AddLateCommands ( void   ) 

Adds command line parameters as script statements.

adds all the remaining + commands from the command line

Note:
Commands lead with a + and continue until another + or -
Returns:
true if any late commands were added
See also:
Cbuf_AddEarlyCommands

Definition at line 284 of file cmd.c.

References argc, Cbuf_AddText(), Com_Argc(), Com_Argv(), i, Mem_Alloc, Mem_Free, Q_strcat(), and qfalse.

Referenced by Qcommon_Init().

void Cbuf_AddText ( const char *  text  ) 
void Cbuf_CopyToDefer ( void   ) 

Defers any outstanding commands.

These two functions are used to defer any pending commands while a map is being loaded.

Used when loading a map, for example. Copies then clears the command buffer to a temporary area.

Definition at line 176 of file cmd.c.

References cmd_text_buf, sizebuf_s::cursize, and defer_text_buf.

Referenced by SV_Map().

void Cbuf_Execute ( void   ) 

Pulls off
terminated lines of text from the command buffer and sends them through Cmd_ExecuteString. Stops when the buffer is empty. Normally called once per frame, but may be explicitly invoked. Do not call inside a command function!

See also:
Cmd_ExecuteString Pulls off
terminated lines of text from the command buffer and sends them through Cmd_ExecuteString, stopping when the buffer is empty. Normally called once per frame, but may be explicitly invoked.
Note:
Do not call inside a command function!

Definition at line 199 of file cmd.c.

References alias_count, Cmd_ExecuteString(), cmdWait, sizebuf_s::cursize, sizebuf_s::data, i, and qfalse.

Referenced by Cbuf_Execute_timer(), CL_ParseServerMessage(), CL_SendCommand(), Qcommon_Init(), SAV_GameContinue_f(), SAV_GameLoad_f(), and SAV_GameQuickLoad_f().

void Cbuf_Init ( void   ) 

allocates an initial text buffer that will grow as needed

Note:
The initial buffer will grow as needed.

Definition at line 105 of file cmd.c.

References cmd_text_buf, and SZ_Init().

Referenced by Qcommon_Init().

void Cbuf_InsertFromDefer ( void   ) 

Copies back any deferred commands.

Definition at line 186 of file cmd.c.

References Cbuf_InsertText(), and defer_text_buf.

Referenced by SV_Begin_f(), and SV_Spawn_f().

void Cbuf_InsertText ( const char *  text  ) 

Adds command text immediately after the current command.

when a command wants to issue other commands immediately, the text is

Note:
Adds a
to the text
Todo:
actually change the command buffer to do less copying

Definition at line 142 of file cmd.c.

References Cbuf_AddText(), sizebuf_s::cursize, sizebuf_s::data, Mem_Alloc, Mem_Free, SZ_Clear(), and SZ_Write().

Referenced by Cbuf_InsertFromDefer(), Cmd_Exec_f(), and Cmd_ExecuteString().

void Cmd_AddCommand ( const char *  cmd_name,
xcommand_t  function,
const char *  desc 
)

Add a new command to the script interface.

called by the init functions of other parts of the program to register commands and functions to call for them. The cmd_name is referenced later, so it should not be in temp memory if function is NULL, the command will be forwarded to the server as a clc_stringcmd instead of executed locally

Parameters:
[in] cmd_name The name the command is available via script interface
[in] function The function pointer
[in] desc A usually(?) one-line description of what the cmd does
See also:
Cmd_RemoveCommand

Definition at line 794 of file cmd.c.

References CMD_HASH_SIZE, com_cmdSysPool, Com_DPrintf(), Com_HashKey(), Com_Printf(), cmd_function_s::completeParam, Cvar_GetString(), DEBUG_COMMANDS, cmd_function_s::description, cmd_function_s::function, hash(), HASH_Add, cmd_function_s::hash_next, Mem_PoolAlloc, cmd_function_s::name, and cmd_function_s::next.

Referenced by AB_InitStartup(), AC_InitCallbacks(), AC_InitStartup(), ACTOR_InitStartup(), AIM_InitCallbacks(), AIR_InitCallbacks(), AIRFIGHT_InitStartup(), B_InitCallbacks(), B_InitStartup(), BDEF_InitCallbacks(), BS_InitCallbacks(), CL_CameraInit(), CL_InitLocal(), CL_InitParticles(), CL_PopupInit(), CL_ServerEventsInit(), CLMN_InitStartup(), Cmd_Init(), Con_Init(), CP_AddCampaignCommands(), CP_InitStartup(), CP_MissionsInit(), CP_MissionTriggerFunctions(), CP_TEAM_InitCallbacks(), Cvar_Init(), E_InitCallbacks(), E_InitStartup(), GAME_CP_InitStartup(), GAME_InitStartup(), GAME_MP_InitStartup(), GAME_SK_InitStartup(), HOS_InitCallbacks(), HOS_InitStartup(), HUD_InitCallbacks(), HUD_InitStartup(), IN_Init(), INS_InitCallbacks(), INS_InitStartup(), INV_InitCallbacks(), INV_InitStartup(), Irc_Init(), Key_Init(), M_Init(), MAP_InitStartup(), Mem_Init(), MP_CallbacksInit(), MP_ServerListInit(), MSO_Init(), MSO_InitCallbacks(), NAT_InitStartup(), NET_Init(), PR_InitCallbacks(), Qcommon_Init(), R_RegisterSystemVars(), RS_InitCallbacks(), RS_InitStartup(), S_Init(), SAV_Init(), SCR_Init(), SEQ_InitStartup(), STATS_InitStartup(), SV_InitOperatorCommands(), SV_MapcycleInit(), TEAM_InitStartup(), TOTD_InitStartup(), TR_InitCallbacks(), TR_InitStartup(), TUT_InitStartup(), UFO_InitStartup(), UI_ConFuncNodeLoaded(), UI_Init(), UI_InitActions(), UI_InitData(), UI_InitWindows(), UI_RegisterAbstractNode(), UI_RegisterEditorNode(), UI_RegisterMaterialEditorNode(), UI_RegisterMessageListNode(), UI_RegisterModelNode(), UI_RegisterRadarNode(), UI_RegisterVScrollbarNode(), UP_InitStartup(), UR_InitCallbacks(), and VID_Init().

void Cmd_AddParamCompleteFunction ( const char *  cmd_name,
int(*)(const char *partial, const char **match)  function 
)
Parameters:
[in] cmd_name The name the command we want to add the complete function
[in] function The complete function pointer
See also:
Cmd_AddCommand
Cmd_CompleteCommandParameters

Definition at line 715 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), cmd_function_s::completeParam, cmd_function_s::function, hash(), cmd_function_s::hash_next, and cmd_function_s::name.

Referenced by Cmd_Init(), Key_Init(), M_Init(), MP_CallbacksInit(), S_Init(), SV_InitOperatorCommands(), UI_InitWindows(), and UI_RegisterEditorNode().

void Cmd_AddUserdata ( const char *  cmd_name,
void *  userdata 
)

Adds userdata to the console command.

Parameters:
[in] cmd_name The name the command we want to add edit
[in] userdata for this function
See also:
Cmd_AddCommand
Cmd_CompleteCommandParameters
Cmd_GetUserdata

Definition at line 770 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), hash(), cmd_function_s::hash_next, cmd_function_s::name, and cmd_function_s::userdata.

Referenced by UI_ConFuncNodeLoaded().

static void Cmd_Alias_f ( void   )  [static]
int Cmd_Argc ( void   ) 

The functions that execute commands get their parameters with these functions. Cmd_Argv() will return an empty string, not a NULL if arg > argc, so string operations are always safe.

Definition at line 507 of file cmd.c.

References cmd_argc.

Referenced by AC_AlienClick_f(), AC_KillOne_f(), AIM_AircraftEquipMenuClick_f(), AIM_AircraftEquipMenuUpdate_f(), AIM_AircraftEquipSlotSelect_f(), AIM_AircraftEquipZoneSelect_f(), AIM_AircraftItemtypeByName_f(), AIM_SelectAircraft_f(), B_AssembleMap_f(), B_BuildingClick_f(), B_BuildingOnDestroy_f(), B_CheckBuildingStatusForMenu_f(), B_Destroy_AntimaterStorage_f(), B_SelectBase_f(), BaseSummary_SelectBase_f(), BDEF_AddBattery_f(), BDEF_AddItem_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_ChangeAutoFire(), BDEF_RemoveBattery_f(), BDEF_RemoveItem_f(), BDEF_SelectItem_f(), BS_Autosell_f(), BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuySellItem_f(), BS_BuyType_f(), BS_MarketClick_f(), BS_MarketScroll_f(), BS_SellAircraft_f(), BS_SellItem_f(), CL_ActorEquipmentSelect_f(), CL_ActorPilotSelect_f(), CL_ActorSelect_f(), CL_ActorTargetAlign_f(), CL_ActorTeamSelect_f(), CL_AssignPilot_f(), CL_AssignSoldier_f(), CL_BookmarkAdd_f(), CL_CamSetAngles_f(), CL_CamSetZoom_f(), CL_Connect_f(), CL_ConnectionlessPacket(), CL_Env_f(), CL_EventAddMail_f(), CL_ForwardToServer_f(), CL_GetTipOfTheDay_f(), CL_NationSelect_f(), CL_PingServers_f(), CL_PopupAircraftClick_f(), CL_PopupChangeHomebase_f(), CL_PopupInterceptBaseClick_f(), CL_PopupInterceptGetAircraft_f(), CL_Rcon_f(), CL_ResearchSelect_f(), CL_SequenceStart_f(), CL_ServerInfo_f(), CL_ServerListClick_f(), CL_SetGameTime_f(), CL_SetRatioFilter_f(), CL_UpdatePilotList_f(), CL_UpdateSoldierList_f(), Cmd_Alias_f(), Cmd_Echo_f(), Cmd_Exec_f(), Cmd_ExecuteString(), Cmd_ForwardToServer(), Cmd_List_f(), Com_DeveloperSet_f(), Com_WriteConfig_f(), CP_AddItemAsCollected_f(), CP_AddTechAsResearchable_f(), CP_ChangeNationHappiness_f(), CP_CheckBaseAttacks_f(), CP_NationStatsClick_f(), Cvar_Add_f(), Cvar_Command(), Cvar_Copy_f(), Cvar_Define_f(), Cvar_Del_f(), Cvar_List_f(), Cvar_Mod_f(), Cvar_Set_f(), Cvar_SetOld_f(), E_EmployeeDelete_f(), E_EmployeeHire_f(), E_EmployeeList_f(), E_EmployeeListScroll_f(), E_EmployeeSelect_f(), GAME_CP_CampaignListClick_f(), GAME_CP_Results_f(), GAME_SetMode_f(), GAME_SK_ChangeEquip_f(), HOS_ListClick_f(), HUD_ActorGetCvarData_f(), HUD_DisplayFiremodes_f(), HUD_FireWeapon_f(), HUD_PopupFiremodeReservation_f(), HUD_RemainingTUs_f(), HUD_SelectReactionFiremode_f(), HUD_ShotReserve_f(), HUD_SwitchFiremodeList_f(), INS_BuildInstallation_f(), INS_DestroyInstallation_f(), INS_SelectInstallation_f(), INV_UpdateObject_f(), Irc_Client_Join_f(), Irc_Client_Kick_f(), Irc_Client_Mode_f(), Irc_Client_Msg_f(), Irc_Client_Part_f(), Irc_Client_PrivMsg_f(), Irc_Client_Topic_f(), Irc_Client_Who_f(), Irc_Client_Whois_f(), Irc_Client_Whowas_f(), Irc_Connect_f(), Irc_UserClick_f(), Irc_UserRightClick_f(), Key_Bind_f(), Key_Unbind_f(), Key_WriteBindings_f(), M_Change_f(), M_Play_f(), MAP_DeactivateOverlay_f(), MAP_MultiSelectExecuteAction_f(), MAP_Scroll_f(), MAP_SelectObject_f(), MAP_SetOverlay_f(), MAP_Zoom_f(), MP_LoadTeamMultiplayer_f(), MP_SaveTeamMultiplayer_f(), MP_TeamSelect_f(), MP_ToggleActorForTeam_f(), MSO_Init_f(), MSO_Scroll_f(), MSO_Set_f(), MSO_SetAll_f(), MSO_Toggle_f(), PR_ProductionChange_f(), PR_ProductionDecrease_f(), PR_ProductionIncrease_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), PTL_DebugSpawnMarker_f(), R_ScreenShot(), R_ScreenShot_f(), RADAR_UpdateBaseRadarCoverage_f(), RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_RemoveScientist_f(), S_Play_f(), SAV_GameLoad_f(), SAV_GameReadGameComments_f(), SAV_GameSave_f(), SAV_GameSaveNameCleanup_f(), SCR_TimeRefresh_f(), SV_InitGameProgs(), SV_Kick_f(), SV_Map_f(), SV_MapcycleAdd_f(), SV_ServerCommand_f(), SV_UserInfo_f(), SVC_RemoteCommand(), TR_CargoListSelect_f(), TR_SelectBase_f(), TR_TransferAliensFromMission_f(), TR_TransferBaseListClick_f(), TR_TransferList_Scroll_f(), TR_TransferListSelect_f(), TR_TransferSelect_f(), TUT_ListClick_f(), UI_ActiveVScrollbarNode_f(), UI_AddListener_f(), UI_CloseWindow_f(), UI_DebugTree_f(), UI_EditorNodeExtract_f(), UI_FireInit_f(), UI_GetParamNumber(), UI_InitStack_f(), UI_MaterialEditorChangeValue_f(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorRemoveStage_f(), UI_MaterialEditorSelectStage_f(), UI_Modify_f(), UI_ModifyWrap_f(), UI_PopWindow_f(), UI_PushChildWindow_f(), UI_PushDropDownWindow_f(), UI_PushWindow_f(), UI_RemoveListener_f(), UI_ResetData_f(), UI_SelectMap_f(), UI_SetNewWindowPos_f(), UI_Translate_f(), UP_Click_f(), UP_FindEntry_f(), UP_MailClientClick_f(), UP_SetMailButtons_f(), UP_TechTreeClick_f(), UR_DialogInit_f(), UR_DialogSelectSellNation_f(), UR_DialogSortByColumn_f(), and UR_DialogStartStore_f().

const char* Cmd_Args ( void   ) 
const char* Cmd_Argv ( int  arg  ) 

Returns a given argument.

Parameters:
[in] arg The argument at position arg in cmd_argv. 0 will return the command name.
Returns:
the argument from cmd_argv
See also:
Cmd_Argc

Definition at line 518 of file cmd.c.

References cmd_argc, and cmd_argv.

Referenced by AC_AlienClick_f(), AC_KillOne_f(), AIM_AircraftEquipMenuClick_f(), AIM_AircraftEquipMenuUpdate_f(), AIM_AircraftEquipSlotSelect_f(), AIM_AircraftEquipZoneSelect_f(), AIM_AircraftItemtypeByName_f(), AIM_SelectAircraft_f(), B_AssembleMap_f(), B_BuildingClick_f(), B_BuildingOnDestroy_f(), B_CheckBuildingStatusForMenu_f(), B_Destroy_AntimaterStorage_f(), B_SelectBase_f(), BaseSummary_SelectBase_f(), BDEF_AddBattery_f(), BDEF_AddItem_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_ChangeAutoFire(), BDEF_RemoveBattery_f(), BDEF_RemoveItem_f(), BDEF_SelectItem_f(), BS_Autosell_f(), BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuySellItem_f(), BS_BuyType_f(), BS_MarketClick_f(), BS_MarketScroll_f(), BS_SellAircraft_f(), BS_SellItem_f(), CL_ActorEquipmentSelect_f(), CL_ActorPilotSelect_f(), CL_ActorSelect_f(), CL_ActorTargetAlign_f(), CL_ActorTeamSelect_f(), CL_AssignPilot_f(), CL_AssignSoldier_f(), CL_BookmarkAdd_f(), CL_CamSetAngles_f(), CL_CamSetZoom_f(), CL_Connect_f(), CL_ConnectionlessPacket(), CL_Env_f(), CL_EventAddMail_f(), CL_ForwardToServer_f(), CL_NationSelect_f(), CL_PingServers_f(), CL_PopupAircraftClick_f(), CL_PopupChangeHomebase_f(), CL_PopupInterceptBaseClick_f(), CL_PopupInterceptGetAircraft_f(), CL_Rcon_f(), CL_ResearchSelect_f(), CL_SequenceStart_f(), CL_ServerInfo_f(), CL_ServerListClick_f(), CL_SetGameTime_f(), CL_SetRatioFilter_f(), CL_TeamNum_f(), CL_UpdatePilotList_f(), CL_UpdateSoldierList_f(), Cmd_Alias_f(), Cmd_Echo_f(), Cmd_Exec_f(), Cmd_ExecuteString(), Cmd_ForwardToServer(), Cmd_List_f(), Com_DeveloperSet_f(), Com_WriteConfig_f(), CP_AddItemAsCollected_f(), CP_AddTechAsResearchable_f(), CP_ChangeNationHappiness_f(), CP_CheckBaseAttacks_f(), CP_NationStatsClick_f(), Cvar_Add_f(), Cvar_Command(), Cvar_Copy_f(), Cvar_Define_f(), Cvar_Del_f(), Cvar_List_f(), Cvar_Mod_f(), Cvar_Set_f(), Cvar_SetOld_f(), E_EmployeeDelete_f(), E_EmployeeHire_f(), E_EmployeeList_f(), E_EmployeeListScroll_f(), E_EmployeeSelect_f(), GAME_CP_CampaignListClick_f(), GAME_CP_Results_f(), GAME_MP_ChangeGametype_f(), GAME_SetMode_f(), GAME_SK_ChangeEquip_f(), HOS_ListClick_f(), HUD_ActorGetCvarData_f(), HUD_DisplayFiremodes_f(), HUD_FireWeapon_f(), HUD_RemainingTUs_f(), HUD_SelectReactionFiremode_f(), HUD_ShotReserve_f(), HUD_SwitchFiremodeList_f(), IN_KeyDown(), IN_KeyUp(), INS_BuildInstallation_f(), INS_DestroyInstallation_f(), INS_SelectInstallation_f(), INV_UpdateObject_f(), Irc_Client_Join_f(), Irc_Client_Kick_f(), Irc_Client_Mode_f(), Irc_Client_Part_f(), Irc_Client_PrivMsg_f(), Irc_Client_Topic_f(), Irc_Client_Who_f(), Irc_Client_Whois_f(), Irc_Client_Whowas_f(), Irc_Connect_f(), Irc_UserClick_f(), Irc_UserRightClick_f(), Key_Bind_f(), Key_Unbind_f(), Key_Unbindall_f(), Key_WriteBindings_f(), M_Change_f(), M_Play_f(), MAP_DeactivateOverlay_f(), MAP_MultiSelectExecuteAction_f(), MAP_Scroll_f(), MAP_SelectObject_f(), MAP_SetOverlay_f(), MAP_Zoom_f(), MP_LoadTeamMultiplayer_f(), MP_SaveTeamMultiplayer_f(), MP_TeamSelect_f(), MP_ToggleActorForTeam_f(), MSO_Init_f(), MSO_Scroll_f(), MSO_Set_f(), MSO_SetAll_f(), MSO_Toggle_f(), PR_ProductionChange_f(), PR_ProductionDecrease_f(), PR_ProductionIncrease_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), PTL_DebugSpawnMarker_f(), R_ScreenShot(), R_ScreenShot_f(), RADAR_UpdateBaseRadarCoverage_f(), RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_RemoveScientist_f(), S_Play_f(), SAV_GameLoad_f(), SAV_GameReadGameComments_f(), SAV_GameSave_f(), SAV_GameSaveNameCleanup_f(), SV_ConnectionlessPacket(), SV_ExecuteUserCommand(), SV_GetPlayerClientStructure(), SV_InitGameProgs(), SV_Kick_f(), SV_Map_f(), SV_MapcycleAdd_f(), SV_ServerCommand_f(), SV_UserInfo_f(), SVC_DirectConnect(), SVC_Info(), SVC_RemoteCommand(), TR_CargoListSelect_f(), TR_SelectBase_f(), TR_TransferAliensFromMission_f(), TR_TransferBaseListClick_f(), TR_TransferList_Scroll_f(), TR_TransferListSelect_f(), TR_TransferSelect_f(), TUT_ListClick_f(), UI_ActiveVScrollbarNode_f(), UI_AddListener_f(), UI_ChangeMap_f(), UI_CloseWindow_f(), UI_DebugTree_f(), UI_EditorNodeExtract_f(), UI_FireInit_f(), UI_GetParam(), UI_InitStack_f(), UI_MaterialEditorChangeValue_f(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorRemoveStage_f(), UI_MaterialEditorSelectStage_f(), UI_Modify_f(), UI_ModifyWrap_f(), UI_PopWindow_f(), UI_PushChildWindow_f(), UI_PushDropDownWindow_f(), UI_PushWindow_f(), UI_RemoveListener(), UI_RemoveListener_f(), UI_ResetData_f(), UI_SelectMap_f(), UI_SetNewWindowPos_f(), UI_TextScrollEnd(), UI_Translate_f(), UP_Click_f(), UP_FindEntry_f(), UP_MailClientClick_f(), UP_SetMailButtons_f(), UP_TechTreeClick_f(), UR_DialogInit_f(), UR_DialogSelectSellNation_f(), UR_DialogSortByColumn_f(), and UR_DialogStartStore_f().

void Cmd_BufClear ( void   ) 

Clears the argv vector and set argc to zero.

Clears the command execution buffer.

See also:
Cmd_TokenizeString

Definition at line 545 of file cmd.c.

References cmd_argc, cmd_args, cmd_argv, cmd_userdata, i, and Mem_Free.

Referenced by Cmd_TokenizeString().

static void Cmd_Close_f ( void   )  [static]

Will no longer add any command to command buffer ...until cmd_close is qfalse again.

See also:
Cmd_Open_f

Definition at line 75 of file cmd.c.

References cmdClosed, Com_DPrintf(), DEBUG_COMMANDS, and qtrue.

Referenced by Cmd_Init().

int Cmd_CompleteCommand ( const char *  partial,
const char **  match 
)

Unix like tab completion for console commands.

Parameters:
[in] partial The beginning of the command we try to complete
[out] match The found entry of the list we are searching, in case of more than one entry their common suffix is returned.
See also:
Cvar_CompleteVariable
Key_CompleteCommand

Definition at line 918 of file cmd.c.

References Cmd_GenericCompleteFunction(), COLORED_GREEN, Com_Printf(), cmd_function_s::description, len, MAX_COMPLETE, cmd_alias_s::name, cmd_function_s::name, cmd_alias_s::next, and cmd_function_s::next.

Referenced by Com_ConsoleCompleteCommand().

int Cmd_CompleteCommandParameters ( const char *  command,
const char *  partial,
const char **  match 
)

Unix like tab completion for console commands parameters.

attempts to match a partial command for automatic command line completion returns NULL if nothing fits

Parameters:
[in] command The command we try to complete the parameter for
[in] partial The beginning of the parameter we try to complete
[out] match The command we are writing back (if something was found)
See also:
Cvar_CompleteVariable
Key_CompleteCommand

Definition at line 894 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), cmd_function_s::completeParam, hash(), cmd_function_s::hash_next, cmd_function_s::name, and Q_strcasecmp.

Referenced by Com_ConsoleCompleteCommand().

static int Cmd_CompleteExecCommand ( const char *  partial,
const char **  match 
) [static]

Autocomplete function for exec command.

Note:
This function only lists all cfg files - but doesn't perform any autocomplete step when hitting tab after "exec "
See also:
Cmd_AddParamCompleteFunction

Definition at line 1060 of file cmd.c.

References Com_Printf(), FS_BuildFileList(), FS_NextFileFromFileList(), and len.

Referenced by Cmd_Init().

void Cmd_Dummy_f ( void   ) 

Dummy binding if you don't want unknown commands forwarded to the server.

Definition at line 1081 of file cmd.c.

Referenced by Key_Init(), and S_Init().

static void Cmd_Echo_f ( void   )  [static]

Just prints the rest of the line to the console.

Definition at line 381 of file cmd.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and i.

Referenced by Cmd_Init().

static void Cmd_Exec_f ( void   )  [static]

Definition at line 346 of file cmd.c.

References byte, Cbuf_InsertText(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), f, FS_FreeFile(), FS_LoadFile(), len, Mem_Alloc, and Mem_Free.

Referenced by Cmd_Init().

void Cmd_ExecuteString ( const char *  text  ) 

A complete command line has been parsed, so try to execute it.

Parses a single line of text into arguments and tries to execute it as if it was typed at the console.

Todo:
lookupnoadd the token to speed search?

Definition at line 962 of file cmd.c.

References alias_count, ALIAS_HASH_SIZE, ALIAS_LOOP_COUNT, Cbuf_InsertText(), Cmd_Argc(), Cmd_Argv(), Cmd_ExecuteString(), Cmd_ForwardToServer(), CMD_HASH_SIZE, Cmd_TokenizeString(), cmd_userdata, Com_DPrintf(), Com_HashKey(), Com_Printf(), Cvar_Command(), DEBUG_COMMANDS, cmd_function_s::function, hash(), cmd_alias_s::hash_next, cmd_function_s::hash_next, cmd_alias_s::name, cmd_function_s::name, Q_strcasecmp, qtrue, cmd_function_s::userdata, va(), and cmd_alias_s::value.

Referenced by _LE_NotFoundError(), AIM_AircraftItemtypeByName_f(), AIR_DeleteAircraft(), AIR_NewAircraft(), AL_AddAliens(), B_AddBuildingToBasePos(), B_BuildingDestroy(), B_CheckBuildingConstruction(), B_ConstructBuilding(), B_MakeBaseMapShot_f(), B_SetBuildingByClick(), B_UpdateOneBaseBuildingStatusOnDisable(), B_UpdateOneBaseBuildingStatusOnEnable(), BDEF_AddItem_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_RemoveItem_f(), BS_BuyAircraft_f(), Cbuf_Execute(), CL_AssignPilot_f(), CL_CampaignRun(), Cmd_ExecuteString(), CP_CampaignInit(), CP_EndCampaign(), CP_ExecuteMissionTrigger(), CP_MissionEnd(), CP_SpawnAlienBaseMission(), GAME_CP_GetCampaigns_f(), GAME_MP_StartServer_f(), IN_Frame(), MAP_MapClick(), MP_TeamSelect_f(), MSO_ParseSettings(), RS_ResearchFinish(), SAV_GameContinue_f(), SAV_GameLoad_f(), SAV_GameQuickLoad_f(), SV_ShutdownGameProgs(), SVC_RemoteCommand(), TR_Init_f(), TUT_ListClick_f(), UI_ExecuteConfunc(), UI_GenAllRadarMap(), and UP_OpenCopyWith().

qboolean Cmd_Exists ( const char *  cmd_name  ) 

Checks whether a function exists already.

used by the cvar code to check for cvar / command name overlap

Parameters:
[in] cmd_name The script interface function name to search for

Definition at line 872 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), hash(), cmd_function_s::hash_next, cmd_function_s::name, qfalse, and qtrue.

Referenced by M_Init(), UI_ConFuncNodeLoaded(), and UI_Shutdown().

void Cmd_ForwardToServer ( void   ) 

adds the current command line as a clc_stringcmd to the client message. things like action, turn, etc, are commands directed to the server, so when they are typed in at the console, they will need to be forwarded.

Definition at line 102 of file cl_main.c.

int Cmd_GenericCompleteFunction ( size_t  len,
const char **  match,
int  matches,
const char **  list 
)
See also:
Cmd_AddParamCompleteFunction
Parameters:
[out] match The found entry of the list we are searching, in case of more than one entry their common suffix is returned.
[in] len The length of the already typed string (where you are searching entries for in the list)
[in] matches The amount of entries in the list parameter
[in] list The list of entries to search for possible matches
Returns:
the amount of matches

Definition at line 667 of file cmd.c.

References i, MAX_QPATH, Q_strncpyz(), and qtrue.

Referenced by CL_CompleteNetworkAddress(), Cmd_CompleteCommand(), Cvar_CompleteVariable(), Key_CompleteKeyName(), M_CompleteMusic(), S_CompleteSounds(), SV_CompleteMapCommand(), SV_CompleteServerCommand(), and UI_CompleteWithWindow().

const char* Cmd_GetCommandDesc ( const char *  cmd_name  ) 

Returns the command description for a given command.

Searches for the description of a given command.

Parameters:
[in] cmd_name Command id in global command array
Note:
never returns a NULL pointer
Todo:
  • search alias, too

Definition at line 633 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), cmd_function_s::description, hash(), cmd_function_s::hash_next, MAX_VAR, cmd_function_s::name, and Q_strncpyz().

Referenced by CLMN_AddBindings(), and UI_KeyBindingNodeDraw().

void* Cmd_GetUserdata ( const char *  cmd_name  ) 

Fetches the userdata for a console command.

Parameters:
[in] cmd_name The name the command we want to add edit
Returns:
NULL if no userdata was set or the command wasn't found, the userdata pointer if it was found and set
See also:
Cmd_AddCommand
Cmd_CompleteCommandParameters
Cmd_AddUserdata

Definition at line 741 of file cmd.c.

References CMD_HASH_SIZE, Com_HashKey(), Com_Printf(), hash(), cmd_function_s::hash_next, cmd_function_s::name, and cmd_function_s::userdata.

Referenced by UI_ConFuncIsVirtual(), UI_ConFuncNodeClose(), and UI_ConFuncNodeInit().

void Cmd_Init ( void   ) 
static void Cmd_List_f ( void   )  [static]

List all available script interface functions.

Definition at line 1018 of file cmd.c.

References Cmd_Argc(), Cmd_Argv(), COLORED_GREEN, Com_Printf(), cmd_function_s::description, i, cmd_alias_s::name, cmd_function_s::name, cmd_alias_s::next, and cmd_function_s::next.

Referenced by Cmd_Init().

static void Cmd_Open_f ( void   )  [static]

Reopens the command buffer for writing.

See also:
Cmd_Close_f

Definition at line 64 of file cmd.c.

References cmdClosed, Com_DPrintf(), DEBUG_COMMANDS, and qfalse.

Referenced by Cmd_Init().

void Cmd_RemoveCommand ( const char *  cmd_name  ) 
void Cmd_Shutdown ( void   ) 

Definition at line 1145 of file cmd.c.

References cmd_argc.

Referenced by Qcommon_Shutdown(), and TEST_Shutdown().

void Cmd_TokenizeString ( const char *  text,
qboolean  macroExpand 
)

Parses the given string into command line tokens.

Takes a null terminated string. Does not need to be /n terminated. breaks the string up into arg tokens.

Note:
cmd_argv and cmd_argv are filled and set here
*cvars will be expanded unless they are in a quoted token
See also:
Com_MacroExpandString
Parameters:
[in] text The text to parse and tokenize
[in] macroExpand expand cvar string with their values

Definition at line 568 of file cmd.c.

References cmd_argc, cmd_args, cmd_argv, Cmd_BufClear(), com_cmdSysPool, Com_MacroExpandString(), Com_Parse(), com_token, Cvar_GetString(), MAX_STRING_TOKENS, Mem_PoolStrDup, and Q_strncpyz().

Referenced by CL_ConnectionlessPacket(), Cmd_ExecuteString(), SV_ConnectionlessPacket(), and SV_ExecuteUserCommand().

void* Cmd_Userdata ( void   ) 

Return the userdata of the called command.

Definition at line 536 of file cmd.c.

References cmd_userdata.

Referenced by UI_ConfuncCommand_f().

static void Cmd_Wait_f ( void   )  [static]

Causes execution of the remainder of the command buffer to be delayed until next frame. This allows commands like: bind g "impulse 5; +attack; wait; -attack; impulse 2".

Definition at line 86 of file cmd.c.

References cmdWait, and qtrue.

Referenced by Cmd_Init().

void Cmd_WriteAliases ( qFILE f  ) 

Write lines containing "aliasa alias value" for all aliases with the archive flag set to true.

Writes the persistent aliases to the given filehandle.

Parameters:
f Filehandle to write the aliases to

Definition at line 458 of file cmd.c.

References cmd_alias_s::archive, FS_Printf(), i, cmd_alias_s::name, cmd_alias_s::next, and cmd_alias_s::value.

Referenced by Com_WriteConfigToFile().


Variable Documentation

int alias_count [static]

Definition at line 57 of file cmd.c.

Referenced by Cbuf_Execute(), and Cmd_ExecuteString().

Definition at line 51 of file cmd.c.

cmd_alias_t* cmd_alias_hash[ALIAS_HASH_SIZE] [static]

Definition at line 52 of file cmd.c.

int cmd_argc [static]

Definition at line 494 of file cmd.c.

Referenced by Cmd_Argc(), Cmd_Argv(), Cmd_BufClear(), Cmd_Shutdown(), and Cmd_TokenizeString().

char cmd_args[MAX_STRING_CHARS] [static]

Definition at line 496 of file cmd.c.

Referenced by Cmd_Args(), Cmd_BufClear(), and Cmd_TokenizeString().

char* cmd_argv[MAX_STRING_TOKENS] [static]

Definition at line 495 of file cmd.c.

Referenced by Cmd_Argv(), Cmd_BufClear(), and Cmd_TokenizeString().

Definition at line 499 of file cmd.c.

cmd_function_t* cmd_functions_hash[CMD_HASH_SIZE] [static]

Definition at line 500 of file cmd.c.

sizebuf_t cmd_text [static]

Definition at line 98 of file cmd.c.

byte cmd_text_buf[CMD_BUFFER_SIZE] [static]

Definition at line 99 of file cmd.c.

Referenced by Cbuf_AddText(), Cbuf_CopyToDefer(), and Cbuf_Init().

void* cmd_userdata [static]

Definition at line 497 of file cmd.c.

Referenced by Cmd_BufClear(), Cmd_ExecuteString(), and Cmd_Userdata().

qboolean cmdClosed [static]

Definition at line 54 of file cmd.c.

Referenced by Cbuf_AddText(), Cmd_Close_f(), and Cmd_Open_f().

qboolean cmdWait [static]

Definition at line 53 of file cmd.c.

Referenced by Cbuf_Execute(), and Cmd_Wait_f().

char defer_text_buf[CMD_BUFFER_SIZE] [static]

Definition at line 100 of file cmd.c.

Referenced by Cbuf_CopyToDefer(), and Cbuf_InsertFromDefer().


Generated by  doxygen 1.6.2