diff --git a/source/cgame/cg_cmds.cpp b/source/cgame/cg_cmds.cpp index e70160cc50..a0b70b63c3 100644 --- a/source/cgame/cg_cmds.cpp +++ b/source/cgame/cg_cmds.cpp @@ -39,7 +39,7 @@ SERVER COMMANDS */ static void CG_SC_Print( void ) { - CG_LocalPrint( "%s", trap_Cmd_Argv( 1 ) ); + CG_LocalPrint( "%s", Cmd_Argv( 1 ) ); } /* @@ -47,10 +47,10 @@ static void CG_SC_Print( void ) */ static void CG_SC_ChatPrint( void ) { - const bool teamonly = (!Q_stricmp( trap_Cmd_Argv( 0 ), "tch" ) ? true : false); - const int who = atoi( trap_Cmd_Argv( 1 ) ); + const bool teamonly = (!Q_stricmp( Cmd_Argv( 0 ), "tch" ) ? true : false); + const int who = atoi( Cmd_Argv( 1 ) ); const char *name = (who && who == bound(1, who, MAX_CLIENTS) ? cgs.clientInfo[who-1].name : NULL); - const char *text = trap_Cmd_Argv( 2 ); + const char *text = Cmd_Argv( 2 ); const cvar_t *filter = (cgs.tv ? cg_chatFilterTV : cg_chatFilter); if( filter->integer & (teamonly ? 2 : 1) ) @@ -83,8 +83,8 @@ static void CG_SC_ChatPrint( void ) */ static void CG_SC_TVChatPrint( void ) { - const char *name = trap_Cmd_Argv( 1 ); - const char *text = trap_Cmd_Argv( 2 ); + const char *name = Cmd_Argv( 1 ); + const char *text = Cmd_Argv( 2 ); const cvar_t *filter = (cgs.tv ? cg_chatFilterTV : cg_chatFilter); if( filter->integer & 4 ) @@ -100,7 +100,7 @@ static void CG_SC_TVChatPrint( void ) */ static void CG_SC_CenterPrint( void ) { - CG_CenterPrint( trap_Cmd_Argv( 1 ) ); + CG_CenterPrint( Cmd_Argv( 1 ) ); } /* @@ -108,24 +108,24 @@ static void CG_SC_CenterPrint( void ) */ static void CG_SC_CenterPrintFormat( void ) { - if( trap_Cmd_Argc() == 8 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ), trap_Cmd_Argv( 3 ), - trap_Cmd_Argv( 4 ), trap_Cmd_Argv( 5 ), trap_Cmd_Argv( 6 ), trap_Cmd_Argv( 7 ) ) ); - } else if( trap_Cmd_Argc() == 7 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ), trap_Cmd_Argv( 3 ), - trap_Cmd_Argv( 4 ), trap_Cmd_Argv( 5 ), trap_Cmd_Argv( 6 ) ) ); - } else if( trap_Cmd_Argc() == 6 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ), trap_Cmd_Argv( 3 ), - trap_Cmd_Argv( 4 ), trap_Cmd_Argv( 5 ) ) ); - } else if( trap_Cmd_Argc() == 5 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ), trap_Cmd_Argv( 3 ), - trap_Cmd_Argv( 4 ) ) ); - } else if( trap_Cmd_Argc() == 4 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ), trap_Cmd_Argv( 3 ) ) ); - } else if( trap_Cmd_Argc() == 3 ) { - CG_CenterPrint( va( CG_TranslateString( trap_Cmd_Argv( 1 ) ), trap_Cmd_Argv( 2 ) ) ); - } else if( trap_Cmd_Argc() == 2 ) { - CG_CenterPrint( CG_TranslateString( trap_Cmd_Argv( 1 ) ) ); // theoretically, shouldn't happen + if( Cmd_Argc() == 8 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ), Cmd_Argv( 3 ), + Cmd_Argv( 4 ), Cmd_Argv( 5 ), Cmd_Argv( 6 ), Cmd_Argv( 7 ) ) ); + } else if( Cmd_Argc() == 7 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ), Cmd_Argv( 3 ), + Cmd_Argv( 4 ), Cmd_Argv( 5 ), Cmd_Argv( 6 ) ) ); + } else if( Cmd_Argc() == 6 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ), Cmd_Argv( 3 ), + Cmd_Argv( 4 ), Cmd_Argv( 5 ) ) ); + } else if( Cmd_Argc() == 5 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ), Cmd_Argv( 3 ), + Cmd_Argv( 4 ) ) ); + } else if( Cmd_Argc() == 4 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ), Cmd_Argv( 3 ) ) ); + } else if( Cmd_Argc() == 3 ) { + CG_CenterPrint( va( CG_TranslateString( Cmd_Argv( 1 ) ), Cmd_Argv( 2 ) ) ); + } else if( Cmd_Argc() == 2 ) { + CG_CenterPrint( CG_TranslateString( Cmd_Argv( 1 ) ) ); // theoretically, shouldn't happen } } @@ -202,7 +202,7 @@ void CG_ConfigString( int i, const char *s ) { if( !cgs.demoPlaying ) { - trap_Cmd_AddCommand( cgs.configStrings[i], NULL ); + Cmd_AddCommand( cgs.configStrings[i], NULL ); if( !Q_stricmp( cgs.configStrings[i], "gametypemenu" ) ) { cgs.hasGametypeMenu = true; } @@ -219,7 +219,7 @@ void CG_ConfigString( int i, const char *s ) */ static void CG_SC_Scoreboard( void ) { - SCR_UpdateScoreboardMessage( trap_Cmd_Argv( 1 ) ); + SCR_UpdateScoreboardMessage( Cmd_Argv( 1 ) ); } /* @@ -333,8 +333,8 @@ static void CG_SC_PlayerStats( void ) const char *s; int print; - print = atoi( trap_Cmd_Argv( 1 ) ); - s = trap_Cmd_Argv( 2 ); + print = atoi( Cmd_Argv( 1 ) ); + s = Cmd_Argv( 2 ); if( !print ) { // scoreboard message update @@ -467,7 +467,7 @@ void CG_SC_AutoRecordAction( const char *action ) if( cg_autoaction_stats->integer && ( !spectator || cg_autoaction_spectator->integer ) ) { const char *filename = va( "stats/%s/%s.txt", gs.gametypeName, name ); - CG_SC_DumpPlayerStats( filename, trap_Cmd_Argv( 2 ) ); + CG_SC_DumpPlayerStats( filename, Cmd_Argv( 2 ) ); } } else if( developer->integer ) @@ -483,7 +483,7 @@ static void CG_SC_ChannelAdd( void ) { char menuparms[MAX_STRING_CHARS]; - Q_snprintfz( menuparms, sizeof( menuparms ), "menu_tvchannel_add %s\n", trap_Cmd_Args() ); + Q_snprintfz( menuparms, sizeof( menuparms ), "menu_tvchannel_add %s\n", Cmd_Args() ); trap_Cmd_ExecuteText( EXEC_NOW, menuparms ); } @@ -494,9 +494,9 @@ static void CG_SC_ChannelRemove( void ) { int i, id; - for( i = 1; i < trap_Cmd_Argc(); i++ ) + for( i = 1; i < Cmd_Argc(); i++ ) { - id = atoi( trap_Cmd_Argv( i ) ); + id = atoi( Cmd_Argv( i ) ); if( id <= 0 ) continue; trap_Cmd_ExecuteText( EXEC_NOW, va( "menu_tvchannel_remove %i\n", id ) ); @@ -581,7 +581,7 @@ static void CG_SC_MatchMessage( void ) cg.matchmessage = NULL; - mm = (matchmessage_t)atoi( trap_Cmd_Argv( 1 ) ); + mm = (matchmessage_t)atoi( Cmd_Argv( 1 ) ); matchmessage = CG_MatchMessageString( mm ); if( !matchmessage || !matchmessage[0] ) return; @@ -602,7 +602,7 @@ static void CG_SC_HelpMessage( void ) cg.helpmessage[0] = '\0'; - index = atoi( trap_Cmd_Argv( 1 ) ); + index = atoi( Cmd_Argv( 1 ) ); if( !index || index > MAX_HELPMESSAGES ) { return; } @@ -667,7 +667,7 @@ static void CG_CS_UpdateTeamInfo( void ) { char *ti; - ti = trap_Cmd_Argv( 1 ); + ti = Cmd_Argv( 1 ); if( !ti[0] ) { cg.teaminfo_size = 0; @@ -699,7 +699,7 @@ static void CG_Cmd_DemoGet_f( void ) return; } - if( trap_Cmd_Argc() != 2 || ( atoi( trap_Cmd_Argv( 1 ) ) <= 0 && trap_Cmd_Argv( 1 )[0] != '.' ) ) + if( Cmd_Argc() != 2 || ( atoi( Cmd_Argv( 1 ) ) <= 0 && Cmd_Argv( 1 )[0] != '.' ) ) { CG_Printf( "Usage: demoget \n" ); CG_Printf( "Downloads a demo from the server\n" ); @@ -707,7 +707,7 @@ static void CG_Cmd_DemoGet_f( void ) return; } - trap_Cmd_ExecuteText( EXEC_NOW, va( "cmd demoget %s", trap_Cmd_Argv( 1 ) ) ); + trap_Cmd_ExecuteText( EXEC_NOW, va( "cmd demoget %s", Cmd_Argv( 1 ) ) ); demo_requested = true; } @@ -733,13 +733,13 @@ static void CG_SC_DemoGet( void ) demo_requested = false; - if( trap_Cmd_Argc() < 2 ) + if( Cmd_Argc() < 2 ) { CG_Printf( "No such demo found\n" ); return; } - filename = trap_Cmd_Argv( 1 ); + filename = Cmd_Argv( 1 ); extension = COM_FileExtension( filename ); if( !COM_ValidateRelativeFilename( filename ) || !extension || Q_stricmp( extension, cgs.demoExtension ) ) @@ -762,11 +762,11 @@ static void CG_SC_MOTD( void ) CG_Free( cg.motd ); cg.motd = NULL; - motd = trap_Cmd_Argv( 2 ); + motd = Cmd_Argv( 2 ); if( !motd[0] ) return; - if( !strcmp( trap_Cmd_Argv( 1 ), "1" ) ) + if( !strcmp( Cmd_Argv( 1 ), "1" ) ) { cg.motd = CG_CopyString( motd ); cg.motd_time = cg.time + 50 *strlen( motd ); @@ -788,15 +788,15 @@ static void CG_SC_MenuCustom( void ) if( cgs.demoPlaying || cgs.tv ) return; - if( trap_Cmd_Argc() < 2 ) + if( Cmd_Argc() < 2 ) return; - Q_strncpyz( request, va( "menu_open custom title \"%s\" ", trap_Cmd_Argv( 1 ) ), sizeof( request ) ); + Q_strncpyz( request, va( "menu_open custom title \"%s\" ", Cmd_Argv( 1 ) ), sizeof( request ) ); - for( i = 2, c = 1; i < trap_Cmd_Argc() - 1; i += 2, c++ ) + for( i = 2, c = 1; i < Cmd_Argc() - 1; i += 2, c++ ) { - const char *label = trap_Cmd_Argv( i ); - const char *cmd = trap_Cmd_Argv( i + 1 ); + const char *label = Cmd_Argv( i ); + const char *cmd = Cmd_Argv( i + 1 ); Q_strncatz( request, va( "btn%i \"%s\" ", c, label ), sizeof( request ) ); Q_strncatz( request, va( "cmd%i \"%s%s\" ", c, *cmd ? "cmd " : "", cmd ), sizeof( request ) ); @@ -817,12 +817,12 @@ static void CG_SC_MenuQuick( void ) cg.quickmenu[0] = '\0'; - if( trap_Cmd_Argc() >= 2 ) + if( Cmd_Argc() >= 2 ) { - for( i = 1, c = 1; i < trap_Cmd_Argc() - 1; i += 2, c++ ) + for( i = 1, c = 1; i < Cmd_Argc() - 1; i += 2, c++ ) { - const char *label = trap_Cmd_Argv( i ); - const char *cmd = trap_Cmd_Argv( i + 1 ); + const char *label = Cmd_Argv( i ); + const char *cmd = Cmd_Argv( i + 1 ); Q_strncatz( cg.quickmenu, va( "btn%i \"%s\" ", c, label ), sizeof( cg.quickmenu ) ); Q_strncatz( cg.quickmenu, va( "cmd%i \"%s%s\" ", c, *cmd ? "cmd " : "", cmd ), sizeof( cg.quickmenu ) ); @@ -843,12 +843,12 @@ static void CG_SC_MenuOpen_( bool modal ) if( cgs.demoPlaying || cgs.tv ) return; - if( trap_Cmd_Argc() < 2 ) + if( Cmd_Argc() < 2 ) return; - Q_strncpyz( request, va( "%s \"%s\"", modal ? "menu_modal" : "menu_open", trap_Cmd_Argv( 1 ) ), sizeof( request ) ); - for( i = 2, c = 1; i < trap_Cmd_Argc(); i++, c++ ) - Q_strncatz( request, va( " param%i \"%s\"", c, trap_Cmd_Argv( i ) ), sizeof( request ) ); + Q_strncpyz( request, va( "%s \"%s\"", modal ? "menu_modal" : "menu_open", Cmd_Argv( 1 ) ), sizeof( request ) ); + for( i = 2, c = 1; i < Cmd_Argc(); i++, c++ ) + Q_strncatz( request, va( " param%i \"%s\"", c, Cmd_Argv( i ) ), sizeof( request ) ); trap_Cmd_ExecuteText( EXEC_APPEND, va( "%s\n", request ) ); } @@ -887,7 +887,7 @@ void CG_AddAward( const char *str ) */ static void CG_SC_AddAward( void ) { - CG_AddAward( trap_Cmd_Argv( 1 ) ); + CG_AddAward( Cmd_Argv( 1 ) ); } typedef struct @@ -931,9 +931,9 @@ void CG_GameCommand( const char *command ) char *s; const svcmd_t *cmd; - trap_Cmd_TokenizeString( command ); + Cmd_TokenizeString( command ); - s = trap_Cmd_Argv( 0 ); + s = Cmd_Argv( 0 ); for( cmd = cg_svcmds; cmd->name; cmd++ ) { if( !strcmp( s, cmd->name ) ) @@ -1009,31 +1009,31 @@ static void CG_WriteBlockList( void ) static void CG_Cmd_Block_f( void ) { - if( trap_Cmd_Argc() < 2 ) + if( Cmd_Argc() < 2 ) { CG_Printf( "Usage: 'block '\n" ); return; } - if (blocklist.find(atoll(trap_Cmd_Argv( 2 ))) != blocklist.end()) + if (blocklist.find(atoll(Cmd_Argv( 2 ))) != blocklist.end()) { CG_Printf( "Player already blocked\n" ); return; } - blocklist[atoll(trap_Cmd_Argv( 2 ))] = std::string(trap_Cmd_Argv( 1 )); + blocklist[atoll(Cmd_Argv( 2 ))] = std::string(Cmd_Argv( 1 )); CG_WriteBlockList(); } static void CG_Cmd_Unblock_f( void ) { - if( trap_Cmd_Argc() < 1 ) + if( Cmd_Argc() < 1 ) { CG_Printf( "Usage: 'unblock '\n" ); return; } - blocklist.erase( atoll(trap_Cmd_Argv( 1 )) ); + blocklist.erase( atoll(Cmd_Argv( 1 )) ); CG_WriteBlockList(); } @@ -1084,13 +1084,13 @@ void CG_UseItem( const char *name ) */ static void CG_Cmd_UseItem_f( void ) { - if( !trap_Cmd_Argc() ) + if( !Cmd_Argc() ) { CG_Printf( "Usage: 'use ' or 'use '\n" ); return; } - CG_UseItem( trap_Cmd_Args() ); + CG_UseItem( Cmd_Args() ); } /* @@ -1180,12 +1180,12 @@ static void CG_Cmd_WeaponCross_f( void ) if( !cg.frame.valid ) return; - if( trap_Cmd_Argc() > 1 ) - quarter = atoi( trap_Cmd_Argv( 1 ) ); + if( Cmd_Argc() > 1 ) + quarter = atoi( Cmd_Argv( 1 ) ); if( ( quarter < 0 ) || ( quarter > 4 ) ) { - CG_Printf( "Usage: '%s <0-4>' (0 - just show, 1 - GB/MG, 2 - RG/GL, 3 - RL/PG, 4 - LG/EB)\n", trap_Cmd_Argv( 0 ) ); + CG_Printf( "Usage: '%s <0-4>' (0 - just show, 1 - GB/MG, 2 - RG/GL, 3 - RL/PG, 4 - LG/EB)\n", Cmd_Argv( 0 ) ); return; } @@ -1341,7 +1341,7 @@ static char **CG_TeamPlayerNamesCompletion_f( const char *partial ) */ static void CG_SayCmdAdd_f( void ) { - trap_Cmd_SetCompletionFunc( "say", &CG_PlayerNamesCompletion_f ); + Cmd_SetCompletionFunc( "say", &CG_PlayerNamesCompletion_f ); } /* @@ -1349,7 +1349,7 @@ static void CG_SayCmdAdd_f( void ) */ static void CG_SayTeamCmdAdd_f( void ) { - trap_Cmd_SetCompletionFunc( "say_team", &CG_TeamPlayerNamesCompletion_f ); + Cmd_SetCompletionFunc( "say_team", &CG_TeamPlayerNamesCompletion_f ); } /* @@ -1357,7 +1357,7 @@ static void CG_SayTeamCmdAdd_f( void ) */ static void CG_StatsCmdAdd_f( void ) { - trap_Cmd_SetCompletionFunc( "stats", &CG_PlayerNamesCompletion_f ); + Cmd_SetCompletionFunc( "stats", &CG_PlayerNamesCompletion_f ); } /* @@ -1365,7 +1365,7 @@ static void CG_StatsCmdAdd_f( void ) */ static void CG_WhoisCmdAdd_f( void ) { - trap_Cmd_SetCompletionFunc( "whois", &CG_PlayerNamesCompletion_f ); + Cmd_SetCompletionFunc( "whois", &CG_PlayerNamesCompletion_f ); } // server commands @@ -1438,7 +1438,7 @@ void CG_RegisterCGameCommands( void ) if( cmd->name ) continue; - trap_Cmd_AddCommand( name, NULL ); + Cmd_AddCommand( name, NULL ); // check for server commands we might want to do some special things for.. for( svcmd = cg_consvcmds; svcmd->name; svcmd++ ) @@ -1458,7 +1458,7 @@ void CG_RegisterCGameCommands( void ) { if( cgs.demoPlaying && !cmd->allowdemo ) continue; - trap_Cmd_AddCommand( cmd->name, cmd->func ); + Cmd_AddCommand( cmd->name, cmd->func ); } } @@ -1490,7 +1490,7 @@ void CG_UnregisterCGameCommands( void ) if( cmd->name ) continue; - trap_Cmd_RemoveCommand( name ); + Cmd_RemoveCommand( name ); } cgs.hasGametypeMenu = false; @@ -1501,6 +1501,6 @@ void CG_UnregisterCGameCommands( void ) { if( cgs.demoPlaying && !cmd->allowdemo ) continue; - trap_Cmd_RemoveCommand( cmd->name ); + Cmd_RemoveCommand( cmd->name ); } } diff --git a/source/cgame/cg_democams.cpp b/source/cgame/cg_democams.cpp index 9a166701a0..4a773270bc 100644 --- a/source/cgame/cg_democams.cpp +++ b/source/cgame/cg_democams.cpp @@ -1317,11 +1317,11 @@ bool CG_DemoCam_IsFree( void ) */ static void CG_DemoFreeFly_Cmd_f( void ) { - if( trap_Cmd_Argc() > 1 ) + if( Cmd_Argc() > 1 ) { - if( !Q_stricmp( trap_Cmd_Argv( 1 ), "on" ) ) + if( !Q_stricmp( Cmd_Argv( 1 ), "on" ) ) CamIsFree = true; - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "off" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "off" ) ) CamIsFree = false; } else @@ -1353,16 +1353,16 @@ static void CG_AddSub_Cmd_f( void ) return; } - if( trap_Cmd_Argc() > 1 ) + if( Cmd_Argc() > 1 ) { char str[MAX_STRING_CHARS]; // one line of the console can't handle more than this int i; str[0] = 0; - for( i = 1; i < trap_Cmd_Argc(); i++ ) + for( i = 1; i < Cmd_Argc(); i++ ) { - Q_strncatz( str, trap_Cmd_Argv( i ), sizeof( str ) ); - if( i < trap_Cmd_Argc() - 1 ) + Q_strncatz( str, Cmd_Argv( i ), sizeof( str ) ); + if( i < Cmd_Argc() - 1 ) Q_strncatz( str, " ", sizeof( str ) ); } @@ -1386,16 +1386,16 @@ static void CG_AddPrint_Cmd_f( void ) return; } - if( trap_Cmd_Argc() > 1 ) + if( Cmd_Argc() > 1 ) { char str[MAX_STRING_CHARS]; // one line of the console can't handle more than this int i; str[0] = 0; - for( i = 1; i < trap_Cmd_Argc(); i++ ) + for( i = 1; i < Cmd_Argc(); i++ ) { - Q_strncatz( str, trap_Cmd_Argv( i ), sizeof( str ) ); - if( i < trap_Cmd_Argc() - 1 ) + Q_strncatz( str, Cmd_Argv( i ), sizeof( str ) ); + if( i < Cmd_Argc() - 1 ) Q_strncatz( str, " ", sizeof( str ) ); } @@ -1416,13 +1416,13 @@ static void CG_AddCam_Cmd_f( void ) CG_DemoCam_UpdateDemoTime(); - if( trap_Cmd_Argc() == 2 ) + if( Cmd_Argc() == 2 ) { // type type = -1; for( i = 0; cam_TypeNames[i] != NULL; i++ ) { - if( !Q_stricmp( cam_TypeNames[i], trap_Cmd_Argv( 1 ) ) ) + if( !Q_stricmp( cam_TypeNames[i], Cmd_Argv( 1 ) ) ) { type = i; break; @@ -1489,12 +1489,12 @@ static void CG_EditCam_Cmd_f( void ) return; } - if( trap_Cmd_Argc() >= 2 && Q_stricmp( trap_Cmd_Argv( 1 ), "help" ) ) + if( Cmd_Argc() >= 2 && Q_stricmp( Cmd_Argv( 1 ), "help" ) ) { - if( !Q_stricmp( trap_Cmd_Argv( 1 ), "type" ) ) + if( !Q_stricmp( Cmd_Argv( 1 ), "type" ) ) { int type, i; - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam type \n" ); return; @@ -1503,7 +1503,7 @@ static void CG_EditCam_Cmd_f( void ) type = -1; for( i = 0; cam_TypeNames[i] != NULL; i++ ) { - if( !Q_stricmp( cam_TypeNames[i], trap_Cmd_Argv( 2 ) ) ) + if( !Q_stricmp( cam_TypeNames[i], Cmd_Argv( 2 ) ) ) { type = i; break; @@ -1523,42 +1523,42 @@ static void CG_EditCam_Cmd_f( void ) CG_Printf( "invalid type name\n" ); } } - if( !Q_stricmp( trap_Cmd_Argv( 1 ), "track" ) ) + if( !Q_stricmp( Cmd_Argv( 1 ), "track" ) ) { - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam track ( 0 for no tracking )\n" ); return; } - currentcam->trackEnt = atoi( trap_Cmd_Argv( 2 ) ); + currentcam->trackEnt = atoi( Cmd_Argv( 2 ) ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "fov" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "fov" ) ) { - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam fov \n" ); return; } - currentcam->fov = atoi( trap_Cmd_Argv( 2 ) ); + currentcam->fov = atoi( Cmd_Argv( 2 ) ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "timeOffset" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "timeOffset" ) ) { unsigned int newtimestamp; - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam timeOffset \n" ); return; } - newtimestamp = currentcam->timeStamp += atoi( trap_Cmd_Argv( 2 ) ); + newtimestamp = currentcam->timeStamp += atoi( Cmd_Argv( 2 ) ); if( newtimestamp + cg.time <= demo_initial_timestamp ) newtimestamp = 1; currentcam->timeStamp = newtimestamp; @@ -1568,7 +1568,7 @@ static void CG_EditCam_Cmd_f( void ) CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "origin" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "origin" ) ) { VectorCopy( cg.view.origin, currentcam->origin ); cam_orbital_radius = 0; @@ -1576,48 +1576,48 @@ static void CG_EditCam_Cmd_f( void ) CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "angles" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "angles" ) ) { VectorCopy( cg.view.angles, currentcam->angles ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "pitch" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "pitch" ) ) { - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam pitch \n" ); return; } - currentcam->angles[PITCH] = atof( trap_Cmd_Argv( 2 ) ); + currentcam->angles[PITCH] = atof( Cmd_Argv( 2 ) ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "yaw" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "yaw" ) ) { - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam yaw \n" ); return; } - currentcam->angles[YAW] = atof( trap_Cmd_Argv( 2 ) ); + currentcam->angles[YAW] = atof( Cmd_Argv( 2 ) ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; } - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "roll" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "roll" ) ) { - if( trap_Cmd_Argc() < 3 ) + if( Cmd_Argc() < 3 ) { // not enough parameters, print help CG_Printf( "Usage: EditCam roll \n" ); return; } - currentcam->angles[ROLL] = atof( trap_Cmd_Argv( 2 ) ); + currentcam->angles[ROLL] = atof( Cmd_Argv( 2 ) ); CG_Printf( "cam edited\n" ); CG_Democam_ExecutePathAnalysis(); return; @@ -1645,14 +1645,14 @@ void CG_SaveCam_Cmd_f( void ) { if( !cgs.demoPlaying ) return; - if( trap_Cmd_Argc() > 1 ) + if( Cmd_Argc() > 1 ) { char *customName; int custom_name_size; - custom_name_size = sizeof( char ) * ( strlen( "demos/" ) + strlen( trap_Cmd_Argv( 1 ) ) + strlen( ".cam" ) + 1 ); + custom_name_size = sizeof( char ) * ( strlen( "demos/" ) + strlen( Cmd_Argv( 1 ) ) + strlen( ".cam" ) + 1 ); customName = ( char * )CG_Malloc( custom_name_size ); - Q_snprintfz( customName, custom_name_size, "demos/%s", trap_Cmd_Argv( 1 ) ); + Q_snprintfz( customName, custom_name_size, "demos/%s", Cmd_Argv( 1 ) ); COM_ReplaceExtension( customName, ".cam", custom_name_size ); CG_SaveRecamScriptFile( customName ); CG_Free( customName ); @@ -1670,16 +1670,16 @@ void CG_Democam_ImportCams_f( void ) int name_size; char *customName; - if( trap_Cmd_Argc() < 2 ) + if( Cmd_Argc() < 2 ) { CG_Printf( "Usage: importcams (relative to demos directory)\n" ); return; } // see if there is any script for this demo, and load it - name_size = sizeof( char ) * ( strlen( "demos/" ) + strlen( trap_Cmd_Argv( 1 ) ) + strlen( ".cam" ) + 1 ); + name_size = sizeof( char ) * ( strlen( "demos/" ) + strlen( Cmd_Argv( 1 ) ) + strlen( ".cam" ) + 1 ); customName = ( char * )CG_Malloc( name_size ); - Q_snprintfz( customName, name_size, "demos/%s", trap_Cmd_Argv( 1 ) ); + Q_snprintfz( customName, name_size, "demos/%s", Cmd_Argv( 1 ) ); COM_ReplaceExtension( customName, ".cam", name_size ); if( CG_LoadRecamScriptFile( customName ) ) { @@ -1696,14 +1696,14 @@ void CG_Democam_ImportCams_f( void ) */ void CG_DemoEditMode_RemoveCmds( void ) { - trap_Cmd_RemoveCommand( "addcam" ); - trap_Cmd_RemoveCommand( "deletecam" ); - trap_Cmd_RemoveCommand( "editcam" ); - trap_Cmd_RemoveCommand( "saverecam" ); - trap_Cmd_RemoveCommand( "clearcams" ); - trap_Cmd_RemoveCommand( "importcams" ); - trap_Cmd_RemoveCommand( "subtitle" ); - trap_Cmd_RemoveCommand( "addprint" ); + Cmd_RemoveCommand( "addcam" ); + Cmd_RemoveCommand( "deletecam" ); + Cmd_RemoveCommand( "editcam" ); + Cmd_RemoveCommand( "saverecam" ); + Cmd_RemoveCommand( "clearcams" ); + Cmd_RemoveCommand( "importcams" ); + Cmd_RemoveCommand( "subtitle" ); + Cmd_RemoveCommand( "addprint" ); } /* @@ -1714,11 +1714,11 @@ static void CG_DemoEditMode_Cmd_f( void ) if( !cgs.demoPlaying ) return; - if( trap_Cmd_Argc() > 1 ) + if( Cmd_Argc() > 1 ) { - if( !Q_stricmp( trap_Cmd_Argv( 1 ), "on" ) ) + if( !Q_stricmp( Cmd_Argv( 1 ), "on" ) ) democam_editing_mode = true; - else if( !Q_stricmp( trap_Cmd_Argv( 1 ), "off" ) ) + else if( !Q_stricmp( Cmd_Argv( 1 ), "off" ) ) democam_editing_mode = false; } else @@ -1727,14 +1727,14 @@ static void CG_DemoEditMode_Cmd_f( void ) CG_Printf( "demo cam editing mode %s\n", democam_editing_mode ? "on" : "off" ); if( democam_editing_mode ) { - trap_Cmd_AddCommand( "addcam", CG_AddCam_Cmd_f ); - trap_Cmd_AddCommand( "deletecam", CG_DeleteCam_Cmd_f ); - trap_Cmd_AddCommand( "editcam", CG_EditCam_Cmd_f ); - trap_Cmd_AddCommand( "saverecam", CG_SaveCam_Cmd_f ); - trap_Cmd_AddCommand( "clearcams", CG_Democam_FreeCams ); - trap_Cmd_AddCommand( "importcams", CG_Democam_ImportCams_f ); - trap_Cmd_AddCommand( "subtitle", CG_AddSub_Cmd_f ); - trap_Cmd_AddCommand( "addprint", CG_AddPrint_Cmd_f ); + Cmd_AddCommand( "addcam", CG_AddCam_Cmd_f ); + Cmd_AddCommand( "deletecam", CG_DeleteCam_Cmd_f ); + Cmd_AddCommand( "editcam", CG_EditCam_Cmd_f ); + Cmd_AddCommand( "saverecam", CG_SaveCam_Cmd_f ); + Cmd_AddCommand( "clearcams", CG_Democam_FreeCams ); + Cmd_AddCommand( "importcams", CG_Democam_ImportCams_f ); + Cmd_AddCommand( "subtitle", CG_AddSub_Cmd_f ); + Cmd_AddCommand( "addprint", CG_AddPrint_Cmd_f ); } else { @@ -1769,9 +1769,9 @@ void CG_DemocamInit( void ) CG_Printf( "cam: %s\n", demoscriptname ); // add console commands - trap_Cmd_AddCommand( "demoEditMode", CG_DemoEditMode_Cmd_f ); - trap_Cmd_AddCommand( "demoFreeFly", CG_DemoFreeFly_Cmd_f ); - trap_Cmd_AddCommand( "camswitch", CG_CamSwitch_Cmd_f ); + Cmd_AddCommand( "demoEditMode", CG_DemoEditMode_Cmd_f ); + Cmd_AddCommand( "demoFreeFly", CG_DemoFreeFly_Cmd_f ); + Cmd_AddCommand( "camswitch", CG_CamSwitch_Cmd_f ); if( CG_LoadRecamScriptFile( demoscriptname ) ) { @@ -1811,9 +1811,9 @@ void CG_DemocamShutdown( void ) return; // remove console commands - trap_Cmd_RemoveCommand( "demoEditMode" ); - trap_Cmd_RemoveCommand( "demoFreeFly" ); - trap_Cmd_RemoveCommand( "camswitch" ); + Cmd_RemoveCommand( "demoEditMode" ); + Cmd_RemoveCommand( "demoFreeFly" ); + Cmd_RemoveCommand( "camswitch" ); if( democam_editing_mode ) { CG_DemoEditMode_RemoveCmds(); diff --git a/source/cgame/cg_hud.cpp b/source/cgame/cg_hud.cpp index 100f37d840..42b4a4f466 100644 --- a/source/cgame/cg_hud.cpp +++ b/source/cgame/cg_hud.cpp @@ -873,9 +873,9 @@ void CG_SC_Obituary( void ) char message[128]; char message2[128]; cg_clientInfo_t *victim, *attacker; - int victimNum = atoi( trap_Cmd_Argv( 1 ) ); - int attackerNum = atoi( trap_Cmd_Argv( 2 ) ); - int mod = atoi( trap_Cmd_Argv( 3 ) ); + int victimNum = atoi( Cmd_Argv( 1 ) ); + int attackerNum = atoi( Cmd_Argv( 2 ) ); + int mod = atoi( Cmd_Argv( 3 ) ); int victim_gender = GENDER_MALE; obituary_t *current; diff --git a/source/cgame/cg_public.h b/source/cgame/cg_public.h index a7fe0d60b5..39652d53c0 100644 --- a/source/cgame/cg_public.h +++ b/source/cgame/cg_public.h @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../ref_base/ref_mod.h" #include "../steamshim/src/mod_steam.h" #include "../qcommon/mod_fs.h" +#include "../qcommon/mod_cmd.h" struct orientation_s; struct bonepose_s; @@ -85,7 +86,6 @@ typedef struct snapshot_s // typedef struct { - const struct fs_import_s* fsImport; // drops to console a client game error void ( *Error )( const char *msg ); @@ -94,7 +94,6 @@ typedef struct void ( *Print )( const char *msg ); void ( *PrintToLog )( const char *msg ); - struct ref_import_s ref_import; // dynvars dynvar_t *( *Dynvar_Create )( const char *name, bool console, dynvar_getter_f getter, dynvar_setter_f setter ); @@ -113,18 +112,10 @@ typedef struct cvar_t *( *Cvar_ForceSet )( const char *name, const char *value ); // will return 0 0 if not found float ( *Cvar_Value )( const char *name ); const char *( *Cvar_String )( const char *name ); - - void ( *Cmd_TokenizeString )( const char *text ); - int ( *Cmd_Argc )( void ); - char *( *Cmd_Argv )( int arg ); - char *( *Cmd_Args )( void ); // concatenation of all argv >= 1 - - void ( *Cmd_AddCommand )( const char *name, void ( *cmd )( void ) ); - void ( *Cmd_RemoveCommand )( const char *cmd_name ); void ( *Cmd_ExecuteText )( int exec_when, const char *text ); void ( *Cmd_Execute )( void ); - void ( *Cmd_SetCompletionFunc )( const char *cmd_name, char **( *completion_func )( const char *partial ) ); + // key bindings const char *( *Key_GetBindingBuf )( int binding ); const char *( *Key_KeynumToString )( int keynum ); @@ -222,7 +213,10 @@ typedef struct int *selected, int *firstKey ); unsigned int ( *IN_SupportedDevices )( void ); + struct cmd_import_s cmdImport; struct steam_import_s steam_import; + const struct fs_import_s* fsImport; + struct ref_import_s ref_import; } cgame_import_t; // diff --git a/source/cgame/cg_screen.cpp b/source/cgame/cg_screen.cpp index fe48cb9fc4..8e4b1ac891 100644 --- a/source/cgame/cg_screen.cpp +++ b/source/cgame/cg_screen.cpp @@ -360,13 +360,13 @@ void CG_ScreenInit( void ) // // register our commands // - trap_Cmd_AddCommand( "sizeup", CG_SizeUp_f ); - trap_Cmd_AddCommand( "sizedown", CG_SizeDown_f ); - trap_Cmd_AddCommand( "help_hud", Cmd_CG_PrintHudHelp_f ); - trap_Cmd_AddCommand( "gamemenu", CG_GameMenu_f ); + Cmd_AddCommand( "sizeup", CG_SizeUp_f ); + Cmd_AddCommand( "sizedown", CG_SizeDown_f ); + Cmd_AddCommand( "help_hud", Cmd_CG_PrintHudHelp_f ); + Cmd_AddCommand( "gamemenu", CG_GameMenu_f ); - trap_Cmd_AddCommand( "+quickmenu", &CG_QuickMenuOn_f ); - trap_Cmd_AddCommand( "-quickmenu", &CG_QuickMenuOff_f ); + Cmd_AddCommand( "+quickmenu", &CG_QuickMenuOn_f ); + Cmd_AddCommand( "-quickmenu", &CG_QuickMenuOff_f ); int i; for( i = 0; i < TOUCHPAD_COUNT; ++i ) @@ -378,13 +378,13 @@ void CG_ScreenInit( void ) */ void CG_ScreenShutdown( void ) { - trap_Cmd_RemoveCommand( "gamemenu" ); - trap_Cmd_RemoveCommand( "sizeup" ); - trap_Cmd_RemoveCommand( "sizedown" ); - trap_Cmd_RemoveCommand( "help_hud" ); + Cmd_RemoveCommand( "gamemenu" ); + Cmd_RemoveCommand( "sizeup" ); + Cmd_RemoveCommand( "sizedown" ); + Cmd_RemoveCommand( "help_hud" ); - trap_Cmd_RemoveCommand( "+quickmenu" ); - trap_Cmd_RemoveCommand( "-quickmenu" ); + Cmd_RemoveCommand( "+quickmenu" ); + Cmd_RemoveCommand( "-quickmenu" ); } diff --git a/source/cgame/cg_syscalls.cpp b/source/cgame/cg_syscalls.cpp index 58707ae6d1..43aa2be34a 100644 --- a/source/cgame/cg_syscalls.cpp +++ b/source/cgame/cg_syscalls.cpp @@ -24,7 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../ref_base/ref_mod.h" #define FS_DEFINE_INTERFACE_IMPL 1 #include "../qcommon/mod_fs.h" - +#define CMD_DEFINE_INTERFACE_IMPL 1 +#include "../qcommon/mod_cmd.h" #include "cg_local.h" @@ -43,6 +44,7 @@ extern "C" QF_DLL_EXPORT cgame_export_t *GetCGameAPI( cgame_import_t *import ) Q_ImportRefModule(&import->ref_import); CGAME_IMPORT = *import; Q_ImportSteamModule( &import->steam_import ); + Q_ImportCmdModule(&import->cmdImport); fs_import = *import->fsImport; globals.API = CG_API; diff --git a/source/cgame/cg_syscalls.h b/source/cgame/cg_syscalls.h index 70cb892440..4772f4b9af 100644 --- a/source/cgame/cg_syscalls.h +++ b/source/cgame/cg_syscalls.h @@ -107,36 +107,6 @@ static inline const char *trap_Cvar_String( const char *name ) return CGAME_IMPORT.Cvar_String( name ); } -static inline void trap_Cmd_TokenizeString( const char *text ) -{ - CGAME_IMPORT.Cmd_TokenizeString( text ); -} - -static inline int trap_Cmd_Argc( void ) -{ - return CGAME_IMPORT.Cmd_Argc(); -} - -static inline char *trap_Cmd_Argv( int arg ) -{ - return CGAME_IMPORT.Cmd_Argv( arg ); -} - -static inline char *trap_Cmd_Args( void ) -{ - return CGAME_IMPORT.Cmd_Args(); -} - -static inline void trap_Cmd_AddCommand( const char *name, void ( *cmd )(void) ) -{ - CGAME_IMPORT.Cmd_AddCommand( name, cmd ); -} - -static inline void trap_Cmd_RemoveCommand( const char *cmd_name ) -{ - CGAME_IMPORT.Cmd_RemoveCommand( cmd_name ); -} - static inline void trap_Cmd_ExecuteText( int exec_when, const char *text ) { CGAME_IMPORT.Cmd_ExecuteText( exec_when, text ); @@ -147,11 +117,6 @@ static inline void trap_Cmd_Execute( void ) CGAME_IMPORT.Cmd_Execute(); } -static inline void trap_Cmd_SetCompletionFunc( const char *cmd_name, char **( *completion_func )( const char *partial ) ) -{ - CGAME_IMPORT.Cmd_SetCompletionFunc( cmd_name, completion_func ); -} - static inline const char *trap_Key_GetBindingBuf( int binding ) { return CGAME_IMPORT.Key_GetBindingBuf( binding ); diff --git a/source/client/cl_game.c b/source/client/cl_game.c index 96a7fc89bd..b3f006b43b 100644 --- a/source/client/cl_game.c +++ b/source/client/cl_game.c @@ -393,7 +393,6 @@ void CL_GameModule_Init( void ) cl_gamemodulepool = _Mem_AllocPool( NULL, "Client Game Progs", MEMPOOL_CLIENTGAME, __FILE__, __LINE__ ); - import.fsImport = &default_fs_imports_s; import.Error = CL_GameModule_Error; import.Print = CL_GameModule_Print; import.PrintToLog = CL_GameModule_PrintToLog; @@ -414,16 +413,8 @@ void CL_GameModule_Init( void ) import.Cvar_String = Cvar_String; import.Cvar_Value = Cvar_Value; - import.Cmd_TokenizeString = Cmd_TokenizeString; - import.Cmd_Argc = Cmd_Argc; - import.Cmd_Argv = Cmd_Argv; - import.Cmd_Args = Cmd_Args; - - import.Cmd_AddCommand = Cmd_AddCommand; - import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteText = Cbuf_ExecuteText; import.Cmd_Execute = Cbuf_Execute; - import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc; import.Key_GetBindingBuf = Key_GetBindingBuf; import.Key_KeynumToString = Key_KeynumToString; @@ -506,6 +497,8 @@ void CL_GameModule_Init( void ) import.IN_IME_GetCandidates = IN_IME_GetCandidates; import.IN_SupportedDevices = IN_SupportedDevices; + import.fsImport = &default_fs_imports_s; + import.cmdImport = (struct cmd_import_s)DECLARE_CMD_STRUCT(); import.steam_import = (struct steam_import_s)DECLARE_STEAM_STRUCT(); if( builtinAPIfunc ) {