示例#1
0
/*
==================
CG_EventHandling
==================
*/
void CG_EventHandling( int type, qboolean fForced )
{
//	CG_Printf("EventHandling: %d\n", type);

	if( cg.demoPlayback && type == CGAME_EVENT_NONE && !fForced ) {
		type = CGAME_EVENT_DEMO;
	}

	if( type != CGAME_EVENT_NONE ) {
		trap_Cvar_Set( "cl_bypassMouseInput", 0 );
	}

	switch( type ) {
		// OSP - Demo support
		case CGAME_EVENT_DEMO:
			cgs.fResize = qfalse;
			cgs.fSelect = qfalse;
			cgs.cursorUpdate = cg.time + 10000;
			cgs.timescaleUpdate = cg.time + 4000;
			CG_ScoresUp_f();
			break;

		case CGAME_EVENT_SPEAKEREDITOR:
		case CGAME_EVENT_GAMEVIEW:
		case CGAME_EVENT_NONE:
		case CGAME_EVENT_CAMPAIGNBREIFING:
		case CGAME_EVENT_FIRETEAMMSG:
		case CGAME_EVENT_MULTIVIEW:
		default:
			// default handling (cleanup mostly)
			if( cgs.eventHandling == CGAME_EVENT_HUDEDITOR) {
				// forty - visual hud editor
				cg.hudEditor.showHudEditor = qfalse;
			} else if(cgs.eventHandling == CGAME_EVENT_MULTIVIEW) {
				if( type == -CGAME_EVENT_MULTIVIEW) {
					type = CGAME_EVENT_NONE;
				} else {
					trap_Key_SetCatcher( KEYCATCH_CGAME );
					return;
				}
			} else if( cgs.eventHandling == CGAME_EVENT_GAMEVIEW ) {
				cg.showGameView = qfalse;
				trap_S_FadeBackgroundTrack( 0.0f, 500, 0 );

				trap_S_StopStreamingSound( -1 );
				cg.limboEndCinematicTime = 0;

				if( fForced ) {
					if( cgs.limboLoadoutModified ) {
						trap_SendClientCommand( "rs" );

						cgs.limboLoadoutSelected = qfalse;
					}
				}
			} else if( cgs.eventHandling == CGAME_EVENT_SPEAKEREDITOR ) {
				if( type == -CGAME_EVENT_SPEAKEREDITOR ) {
					type = CGAME_EVENT_NONE;
				} else {
					trap_Key_SetCatcher( KEYCATCH_CGAME );
					return;
				}
			} else if( cgs.eventHandling == CGAME_EVENT_CAMPAIGNBREIFING ) {
				type = CGAME_EVENT_GAMEVIEW;
			} else if( cgs.eventHandling == CGAME_EVENT_FIRETEAMMSG ) {
				cg.showFireteamMenu = qfalse;								
				trap_Cvar_Set( "cl_bypassmouseinput", "0" );
			} else if( cg.snap && cg.snap->ps.pm_type == PM_INTERMISSION && fForced ) {
				trap_UI_Popup( UIMENU_INGAME );
			}


			break;
	}


	cgs.eventHandling = type;

	if(type == CGAME_EVENT_NONE) {
		trap_Key_SetCatcher(trap_Key_GetCatcher() & ~KEYCATCH_CGAME);
		ccInitial = qfalse;
		if(cg.demoPlayback && cg.demohelpWindow != SHOW_OFF) {
			CG_ShowHelp_Off(&cg.demohelpWindow);
		}
	} else if( type == CGAME_EVENT_HUDEDITOR ) {
		// forty - visual hud editor
		cg.hudEditor.showHudEditor = qtrue;
		trap_Key_SetCatcher(KEYCATCH_CGAME);
	} else if( type == CGAME_EVENT_MULTIVIEW ) {
		trap_Key_SetCatcher(KEYCATCH_CGAME);
	} else if( type == CGAME_EVENT_GAMEVIEW ) {
		cg.showGameView = qtrue;
		CG_LimboPanel_Setup();
		trap_Key_SetCatcher(KEYCATCH_CGAME);
	} else if( type == CGAME_EVENT_FIRETEAMMSG ) {
		cgs.ftMenuPos = -1;
		cgs.ftMenuMode = 0;
		cg.showFireteamMenu = qtrue;
		trap_Cvar_Set( "cl_bypassmouseinput", "1" );
		trap_Key_SetCatcher(KEYCATCH_CGAME);
	} else {
		trap_Key_SetCatcher(KEYCATCH_CGAME);
	}
}
示例#2
0
static void CG_ServerCommand( void ) {
	const char  *cmd;
	char text[MAX_SAY_TEXT];

	cmd = CG_Argv( 0 );

	if ( !cmd[0] ) {
		// server claimed the command
		return;
	}

	if ( !strcmp( cmd, "startCam" ) ) {
		CG_StartCamera( CG_Argv( 1 ), atoi( CG_Argv( 2 ) ) );
		return;
	}

	if ( !strcmp( cmd, "stopCam" ) ) {
		CG_StopCamera();
		return;
	}

	if ( !strcmp( cmd, "mvspd" ) ) {
		CG_RequestMoveSpeed( CG_Argv( 1 ) );
		return;
	}

	if ( !strcmp( cmd, "dp" ) ) {    // dynamite print (what a hack :(

		CG_CenterPrint( va( "%s %d %s", CG_translateString( "dynamitetimer" ), atoi( CG_Argv( 1 ) ), CG_translateString( "seconds" ) ),
						SCREEN_HEIGHT - ( SCREEN_HEIGHT * 0.25 ), SMALLCHAR_WIDTH );
		return;
	}

	if ( !strcmp( cmd, "cp" ) ) {
		CG_CenterPrint( CG_Argv( 1 ), SCREEN_HEIGHT - ( SCREEN_HEIGHT * 0.25 ), SMALLCHAR_WIDTH );
		return;
	}

	if ( !strcmp( cmd, "cs" ) ) {
		CG_ConfigStringModified();
		return;
	}

	if ( !strcmp( cmd, "print" ) ) {
		CG_Printf( "%s", CG_Argv( 1 ) );
#ifdef MISSIONPACK
		cmd = CG_Argv( 1 );           // yes, this is obviously a hack, but so is the way we hear about
									  // votes passing or failing
		if ( !Q_stricmpn( cmd, "vote failed", 11 ) || !Q_stricmpn( cmd, "team vote failed", 16 ) ) {
			trap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER );
		} else if ( !Q_stricmpn( cmd, "vote passed", 11 ) || !Q_stricmpn( cmd, "team vote passed", 16 ) ) {
			trap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER );
		}
#endif
		return;
	}

	if ( !strcmp( cmd, "chat" ) ) {
		if ( !cg_teamChatsOnly.integer ) {
			trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
			Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
			CG_RemoveChatEscapeChar( text );
			CG_Printf( "%s\n", text );
		}
		return;
	}

	if ( !strcmp( cmd, "tchat" ) ) {
		trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		CG_RemoveChatEscapeChar( text );
		CG_AddToTeamChat( text );
		CG_Printf( "%s\n", text );
		return;
	}

	// NERVE - SMF - limbo chat
	if ( !strcmp( cmd, "lchat" ) ) {
		trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		CG_RemoveChatEscapeChar( text );
//		CG_AddToLimboChat( text );
		trap_UI_LimboChat( text );
		CG_Printf( "%s\n", text );
		return;
	}
	// -NERVE - SMF

	if ( !strcmp( cmd, "vchat" ) ) {
//		CG_VoiceChat( SAY_ALL );
		return;
	}

	if ( !strcmp( cmd, "vtchat" ) ) {
//		CG_VoiceChat( SAY_TEAM );
		return;
	}

	if ( !strcmp( cmd, "vtell" ) ) {
//		CG_VoiceChat( SAY_TELL );
		return;
	}

	if ( !strcmp( cmd, "scores" ) ) {
		CG_ParseScores();
		return;
	}

	if ( !strcmp( cmd, "tinfo" ) ) {
		CG_ParseTeamInfo();
		return;
	}

	if ( !strcmp( cmd, "map_restart" ) ) {
		CG_MapRestart();
		return;
	}

	if ( Q_stricmp( cmd, "remapShader" ) == 0 ) {
		if ( trap_Argc() == 4 ) {
			trap_R_RemapShader( CG_Argv( 1 ), CG_Argv( 2 ), CG_Argv( 3 ) );
		}
	}

	// loaddeferred can be both a servercmd and a consolecmd
	if ( !strcmp( cmd, "loaddeferred" ) ) {  // spelling fixed (SA)
		CG_LoadDeferredPlayers();
		return;
	}

	// clientLevelShot is sent before taking a special screenshot for
	// the menu system during development
	if ( !strcmp( cmd, "clientLevelShot" ) ) {
		cg.levelShot = qtrue;
		return;
	}

	// NERVE - SMF
	if ( !Q_stricmp( cmd, "oid" ) ) {
		CG_ObjectivePrint( CG_Argv( 2 ), SMALLCHAR_WIDTH, atoi( CG_Argv( 1 ) ) );
		return;
	}
	// -NERVE - SMF


	//
	// music
	//

	// loops \/
	if ( !strcmp( cmd, "mu_start" ) ) {  // has optional parameter for fade-up time
		int fadeTime = 0;   // default to instant start

		Q_strncpyz( text, CG_Argv( 2 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}

		trap_S_StartBackgroundTrack( CG_Argv( 1 ), CG_Argv( 1 ), fadeTime );
		return;
	}
	// plays once then back to whatever the loop was \/
	if ( !strcmp( cmd, "mu_play" ) ) {   // has optional parameter for fade-up time
		int fadeTime = 0;   // default to instant start

		Q_strncpyz( text, CG_Argv( 2 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}

		trap_S_StartBackgroundTrack( CG_Argv( 1 ), "onetimeonly", fadeTime );
		return;
	}

	if ( !strcmp( cmd, "mu_stop" ) ) {   // has optional parameter for fade-down time
		int fadeTime = 0;   // default to instant stop

		Q_strncpyz( text, CG_Argv( 1 ), MAX_SAY_TEXT );
		if ( text && strlen( text ) ) {
			fadeTime = atoi( text );
		}
		trap_S_FadeBackgroundTrack( 0.0f, fadeTime, 0 );
		trap_S_StartBackgroundTrack( "", "", -2 ); // '-2' for 'queue looping track' (QUEUED_PLAY_LOOPED)
		return;
	}

	if ( !strcmp( cmd, "mu_fade" ) ) {
		trap_S_FadeBackgroundTrack( atof( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ), 0 );
		return;
	}

	if ( !strcmp( cmd, "snd_fade" ) ) {
		trap_S_FadeAllSound( atof( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ) );
		return;
	}

	if ( !strcmp( cmd, "rockandroll" ) ) {   // map loaded, game is ready to begin.
		CG_Fade( 0, 0, 0, 255, cg.time, 0 );      // go black
		trap_UI_Popup( "pregame" );                // start pregame menu
		trap_Cvar_Set( "cg_norender", "1" );    // don't render the world until the player clicks in and the 'playerstart' func has been called (g_main in G_UpdateCvars() ~ilne 949)

		trap_S_FadeAllSound( 1.0f, 1000 );    // fade sound up

		return;
	}



	// ensure a file gets into a build (mainly for scripted music calls)
	if ( !strcmp( cmd, "addToBuild" ) ) {
		fileHandle_t f;

		if ( !cg_buildScript.integer ) {
			return;
		}

		// just open the file so it gets copied to the build dir
		//CG_FileTouchForBuild(CG_Argv(1));
		trap_FS_FOpenFile( CG_Argv( 1 ), &f, FS_READ );
		trap_FS_FCloseFile( f );
		return;
	}


	CG_Printf( "Unknown client game command: %s\n", cmd );
}