diff options
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_consolecmds.c | 34 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 6 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 276 | ||||
-rw-r--r-- | src/cgame/cg_syscalls.c | 2 |
4 files changed, 161 insertions, 157 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 697b0e98..47aadece 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -188,14 +188,14 @@ static void CG_TellAttacker_f( void ) trap_SendClientCommand( command ); } -typedef struct +static void CG_UIMenu_f( void ) { - char *cmd; - void (*function)( void ); -} consoleCommand_t; + trap_SendConsoleCommand( va( "menu %s\n", CG_Argv( 1 ) ) ); +} static consoleCommand_t commands[ ] = { + { "ui_menu", CG_UIMenu_f }, { "testgun", CG_TestGun_f }, { "testmodel", CG_TestModel_f }, { "nextframe", CG_TestModelNextFrame_f }, @@ -233,19 +233,10 @@ Cmd_Argc() / Cmd_Argv() qboolean CG_ConsoleCommand( void ) { const char *cmd; - const char *arg1; int i; cmd = CG_Argv( 0 ); - // ugly hacky special case - if( !Q_stricmp( cmd, "ui_menu" ) ) - { - arg1 = CG_Argv( 1 ); - trap_SendConsoleCommand( va( "menu %s\n", arg1 ) ); - return qtrue; - } - for( i = 0; i < sizeof( commands ) / sizeof( commands[ 0 ] ); i++ ) { if( !Q_stricmp( cmd, commands[ i ].cmd ) ) @@ -285,6 +276,11 @@ void CG_InitConsoleCommands( void ) trap_AddCommand( "ui_messagemode4" ); trap_AddCommand( "say" ); trap_AddCommand( "say_team" ); + trap_AddCommand( "vsay" ); + trap_AddCommand( "vsay_team" ); + trap_AddCommand( "vsay_local" ); + trap_AddCommand( "m" ); + trap_AddCommand( "mt" ); trap_AddCommand( "tell" ); trap_AddCommand( "give" ); trap_AddCommand( "god" ); @@ -293,28 +289,22 @@ void CG_InitConsoleCommands( void ) trap_AddCommand( "team" ); trap_AddCommand( "follow" ); trap_AddCommand( "levelshot" ); - trap_AddCommand( "addbot" ); trap_AddCommand( "setviewpos" ); trap_AddCommand( "callvote" ); trap_AddCommand( "vote" ); trap_AddCommand( "callteamvote" ); trap_AddCommand( "teamvote" ); - trap_AddCommand( "stats" ); trap_AddCommand( "class" ); trap_AddCommand( "build" ); trap_AddCommand( "buy" ); trap_AddCommand( "sell" ); trap_AddCommand( "reload" ); + trap_AddCommand( "boost" ); trap_AddCommand( "itemact" ); trap_AddCommand( "itemdeact" ); trap_AddCommand( "itemtoggle" ); trap_AddCommand( "destroy" ); trap_AddCommand( "deconstruct" ); - trap_AddCommand( "menu" ); - trap_AddCommand( "ui_menu" ); - trap_AddCommand( "mapRotation" ); - trap_AddCommand( "stopMapRotation" ); - trap_AddCommand( "advanceMapRotation" ); - trap_AddCommand( "alienWin" ); - trap_AddCommand( "humanWin" ); + trap_AddCommand( "ignore" ); + trap_AddCommand( "unignore" ); } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 764d8183..e4a19844 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1422,6 +1422,12 @@ typedef struct clientList_t ignoreList; } cgs_t; +typedef struct +{ + char *cmd; + void ( *function )( void ); +} consoleCommand_t; + //============================================================================== extern cgs_t cgs; diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index e9de4646..c358133f 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -1105,172 +1105,180 @@ static void CG_ParseVoice( void ) /* ================= -CG_ServerCommand +CG_CenterPrint_f +================= +*/ +static void CG_CenterPrint_f( void ) +{ + CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); +} -The string has been tokenized and can be retrieved with -Cmd_Argc() / Cmd_Argv() +/* +================= +CG_Print_f ================= */ -static void CG_ServerCommand( void ) +static void CG_Print_f( void ) { - const char *cmd; - char text[ MAX_SAY_TEXT ]; + CG_Printf( "%s", CG_Argv( 1 ) ); +} - cmd = CG_Argv( 0 ); +/* +================= +CG_Chat_f +================= +*/ +static void CG_Chat_f( void ) +{ + char cmd[ 6 ], text[ MAX_SAY_TEXT ]; + qboolean team; - if( !cmd[ 0 ] ) - { - // server claimed the command - return; - } + trap_Argv( 0, cmd, sizeof( cmd ) ); + team = Q_stricmp( cmd, "chat" ); - if( !strcmp( cmd, "cp" ) ) - { - CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); + if( team && cg_teamChatsOnly.integer ) return; - } - if( !strcmp( cmd, "cs" ) ) - { - CG_ConfigStringModified( ); - return; - } + Q_strncpyz( text, CG_Argv( 1 ), sizeof( text ) ); - if( !strcmp( cmd, "print" ) ) + if( Q_stricmpn( text, "[skipnotify]", 12 ) ) { - CG_Printf( "%s", CG_Argv( 1 ) ); - return; + if( team && cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) + trap_S_StartLocalSound( cgs.media.alienTalkSound, CHAN_LOCAL_SOUND ); + else if( team && cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) + trap_S_StartLocalSound( cgs.media.humanTalkSound, CHAN_LOCAL_SOUND ); + else + trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); } - if( !strcmp( cmd, "chat" ) ) - { - if( !cg_teamChatsOnly.integer ) - { - Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT ); - if( Q_stricmpn( text, "[skipnotify]", 12 ) ) - trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); - CG_RemoveChatEscapeChar( text ); - CG_Printf( "%s\n", text ); - } - - return; - } + CG_RemoveChatEscapeChar( text ); + CG_Printf( "%s\n", text ); +} - if( !strcmp( cmd, "tchat" ) ) - { - Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT ); - if( Q_stricmpn( text, "[skipnotify]", 12 ) ) - { - if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) - trap_S_StartLocalSound( cgs.media.alienTalkSound, CHAN_LOCAL_SOUND ); - else if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) - trap_S_StartLocalSound( cgs.media.humanTalkSound, CHAN_LOCAL_SOUND ); - else - trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); - } - CG_RemoveChatEscapeChar( text ); - CG_Printf( "%s\n", text ); - return; - } - - if( !strcmp( cmd, "voice" ) ) - { - CG_ParseVoice( ); - return; - } +/* +================= +CG_ClientLevelShot_f +================= +*/ +static void CG_ClientLevelShot_f( void ) +{ + cg.levelShot = qtrue; +} - if( !strcmp( cmd, "scores" ) ) - { - CG_ParseScores( ); - return; - } +/* +================= +CG_ServerMenu_f +================= +*/ +static void CG_ServerMenu_f( void ) +{ + if( trap_Argc( ) == 2 && !cg.demoPlayback ) + CG_Menu( atoi( CG_Argv( 1 ) ), 0 ); - if( !strcmp( cmd, "tinfo" ) ) - { - CG_ParseTeamInfo( ); - return; - } + if( trap_Argc( ) == 3 && !cg.demoPlayback ) + CG_Menu( atoi( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ) ); +} - if( !strcmp( cmd, "map_restart" ) ) - { - CG_MapRestart( ); - return; - } +/* +================= +CG_ServerCloseMenus_f +================= +*/ +static void CG_ServerCloseMenus_f( void ) +{ + trap_SendConsoleCommand( "closemenus\n" ); +} - if( Q_stricmp( cmd, "remapShader" ) == 0 ) - { - if( trap_Argc( ) == 4 ) - trap_R_RemapShader( CG_Argv( 1 ), CG_Argv( 2 ), CG_Argv( 3 ) ); - } +/* +================= +CG_PoisonCloud_f +================= +*/ +static void CG_PoisonCloud_f( void ) +{ + cg.poisonedTime = cg.time; - // clientLevelShot is sent before taking a special screenshot for - // the menu system during development - if( !strcmp( cmd, "clientLevelShot" ) ) + if( CG_IsParticleSystemValid( &cg.poisonCloudPS ) ) { - cg.levelShot = qtrue; - return; + cg.poisonCloudPS = CG_SpawnNewParticleSystem( cgs.media.poisonCloudPS ); + CG_SetAttachmentCent( &cg.poisonCloudPS->attachment, &cg.predictedPlayerEntity ); + CG_AttachToCent( &cg.poisonCloudPS->attachment ); } +} - //the server has triggered a menu - if( !strcmp( cmd, "servermenu" ) ) - { - if( trap_Argc( ) == 2 && !cg.demoPlayback ) - CG_Menu( atoi( CG_Argv( 1 ) ), 0 ); - if( trap_Argc( ) == 3 && !cg.demoPlayback ) - CG_Menu( atoi( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ) ); - return; - } +/* +================= +CG_PTRRequest_f +================= +*/ +static void CG_PTRRequest_f( void ) +{ + trap_SendClientCommand( va( "ptrcverify %d", CG_ReadPTRCode( ) ) ); +} - //the server thinks this client should close all menus - if( !strcmp( cmd, "serverclosemenus" ) ) - { - trap_SendConsoleCommand( "closemenus\n" ); - return; - } +/* +================= +CG_PTRIssue_f +================= +*/ +static void CG_PTRIssue_f( void ) +{ + if( trap_Argc( ) == 2 ) + CG_WritePTRCode( atoi( CG_Argv( 1 ) ) ); +} - //poison cloud effect needs to be reliable - if( !strcmp( cmd, "poisoncloud" ) ) - { - cg.poisonedTime = cg.time; +/* +================= +CG_PTRConfirm_f +================= +*/ +static void CG_PTRConfirm_f( void ) +{ + trap_SendConsoleCommand( "menu ptrc_popmenu\n" ); +} - if( CG_IsParticleSystemValid( &cg.poisonCloudPS ) ) - { - cg.poisonCloudPS = CG_SpawnNewParticleSystem( cgs.media.poisonCloudPS ); - CG_SetAttachmentCent( &cg.poisonCloudPS->attachment, &cg.predictedPlayerEntity ); - CG_AttachToCent( &cg.poisonCloudPS->attachment ); - } +static consoleCommand_t svcommands[ ] = +{ + { "cp", CG_CenterPrint_f }, + { "cs", CG_ConfigStringModified }, + { "print", CG_Print_f }, + { "chat", CG_Chat_f }, + { "tchat", CG_Chat_f }, + { "scores", CG_ParseScores }, + { "tinfo", CG_ParseTeamInfo }, + { "map_restart", CG_MapRestart }, + { "clientLevelShot", CG_ClientLevelShot_f }, + { "servermenu", CG_ServerMenu_f }, + { "serverclosemenus", CG_ServerCloseMenus_f }, + { "poisoncloud", CG_PoisonCloud_f }, + { "voice", CG_ParseVoice }, + { "ptrcrequest", CG_PTRRequest_f }, + { "ptrcissue", CG_PTRIssue_f }, + { "ptrcconfirm", CG_PTRConfirm_f } +}; - return; - } +/* +================= +CG_ServerCommand - // server requests a ptrc - if( !strcmp( cmd, "ptrcrequest" ) ) - { - int code = CG_ReadPTRCode( ); +The string has been tokenized and can be retrieved with +Cmd_Argc() / Cmd_Argv() +================= +*/ +static void CG_ServerCommand( void ) +{ + const char *cmd; + int i; - trap_SendClientCommand( va( "ptrcverify %d", code ) ); - return; - } + cmd = CG_Argv( 0 ); - // server issues a ptrc - if( !strcmp( cmd, "ptrcissue" ) ) + for( i = 0; i < sizeof( svcommands ) / sizeof( svcommands[ 0 ] ); i++ ) { - if( trap_Argc( ) == 2 ) + if( !Q_stricmp( cmd, svcommands[ i ].cmd ) ) { - int code = atoi( CG_Argv( 1 ) ); - - CG_WritePTRCode( code ); + svcommands[ i ].function( ); + return; } - - return; - } - - // reply to ptrcverify - if( !strcmp( cmd, "ptrcconfirm" ) ) - { - trap_SendConsoleCommand( "menu ptrc_popmenu\n" ); - - return; } CG_Printf( "Unknown client game command: %s\n", cmd ); diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c index b990ab8e..aa28d45d 100644 --- a/src/cgame/cg_syscalls.c +++ b/src/cgame/cg_syscalls.c @@ -347,7 +347,7 @@ void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t * qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 ) { - syscall( CG_R_INPVS, p1, p2 ); + return syscall( CG_R_INPVS, p1, p2 ); } void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ) |