Esempio n. 1
0
/*
* SV_Demo_Stop
*/
static void SV_Demo_Stop( bool cancel, bool silent )
{
	if( !svs.demo.file )
	{
		if( !silent ) {
			Com_Printf( "No server demo recording in progress\n" );
		}
		return;
	}

	if( cancel )
	{
		Com_Printf( "Canceled server demo recording: %s\n", svs.demo.filename );
	}
	else
	{
		SNAP_StopDemoRecording( svs.demo.file );

		Com_Printf( "Stopped server demo recording: %s\n", svs.demo.filename );
	}

	FS_FCloseFile( svs.demo.file );
	svs.demo.file = 0;

	if( cancel )
	{
		if( !FS_RemoveFile( svs.demo.tempname ) )
			Com_Printf( "Error: Failed to delete the temporary server demo file\n" );
	}
	else
	{
		// write some meta information about the match/demo
		SV_SetDemoMetaKeyValue( "hostname", sv.configstrings[CS_HOSTNAME] );
		SV_SetDemoMetaKeyValue( "localtime", va( "%u", svs.demo.localtime ) );
		SV_SetDemoMetaKeyValue( "multipov", "1" );
		SV_SetDemoMetaKeyValue( "duration", va( "%u", (int)ceil( svs.demo.duration/1000.0f ) ) );
		SV_SetDemoMetaKeyValue( "mapname", sv.configstrings[CS_MAPNAME] );
		SV_SetDemoMetaKeyValue( "gametype", sv.configstrings[CS_GAMETYPENAME] );
		SV_SetDemoMetaKeyValue( "levelname", sv.configstrings[CS_MESSAGE] );
		SV_SetDemoMetaKeyValue( "matchname", sv.configstrings[CS_MATCHNAME] );
		SV_SetDemoMetaKeyValue( "matchscore", sv.configstrings[CS_MATCHSCORE] );
		SV_SetDemoMetaKeyValue( "matchuuid", sv.configstrings[CS_MATCHUUID] );

		SNAP_WriteDemoMetaData( svs.demo.tempname, svs.demo.meta_data, svs.demo.meta_data_realsize );

		if( !FS_MoveFile( svs.demo.tempname, svs.demo.filename ) )
			Com_Printf( "Error: Failed to rename the server demo file\n" );
	}

	svs.demo.localtime = 0;
	svs.demo.basetime = svs.demo.duration = 0;

	SNAP_FreeClientFrames( &svs.demo.client );

	Mem_ZoneFree( svs.demo.filename );
	svs.demo.filename = NULL;
	Mem_ZoneFree( svs.demo.tempname );
	svs.demo.tempname = NULL;
}
Esempio n. 2
0
/*
* TV_Upstream_StopDemoRecord
*/
void TV_Upstream_StopDemoRecord( upstream_t *upstream, qboolean silent, qboolean cancel )
{
	assert( upstream );

	if( !upstream->demo.recording )
	{
		if( !silent )
			Com_Printf( "Not recording a demo.\n" );
		return;
	}

	// finish up
	SNAP_StopDemoRecording( upstream->demo.filehandle );

	FS_FCloseFile( upstream->demo.filehandle );

	// cancel the demos
	if( cancel )
	{
		// remove the file that correspond to cls.demo.file
		if( !silent )
			Com_Printf( "Canceling demo: %s\n", upstream->demo.filename );
		if( !FS_RemoveFile( upstream->demo.tempname ) && !silent )
			Com_Printf( "Error canceling demo." );
	}
	else
	{
		// write some meta information about the match/demo
		TV_Upstream_SetDemoMetaKeyValue( upstream, "hostname", upstream->configstrings[CS_HOSTNAME] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "localtime", va( "%u", upstream->demo.localtime ) );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "multipov", "1" );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "duration", va( "%u", (int)ceil( upstream->demo.duration/1000.0f ) ) );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "mapname", upstream->configstrings[CS_MAPNAME] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "gametype", upstream->configstrings[CS_GAMETYPENAME] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "levelname", upstream->configstrings[CS_MESSAGE] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "matchname", upstream->configstrings[CS_MATCHNAME] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "matchscore", upstream->configstrings[CS_MATCHSCORE] );
		TV_Upstream_SetDemoMetaKeyValue( upstream, "matchuuid", upstream->configstrings[CS_MATCHUUID] );

		SNAP_WriteDemoMetaData( upstream->demo.tempname, upstream->demo.meta_data, upstream->demo.meta_data_realsize );

		if( !FS_MoveFile( upstream->demo.tempname, upstream->demo.filename ) )
			Com_Printf( "Error: Failed to rename the demo file\n" );
	}

	if( !silent )
		Com_Printf( "Stopped demo: %s\n", upstream->demo.filename );

	upstream->demo.filehandle = 0; // file id

	Mem_ZoneFree( upstream->demo.filename );
	upstream->demo.filename = NULL;
	Mem_ZoneFree( upstream->demo.tempname );
	upstream->demo.tempname = NULL;

	upstream->demo.recording = qfalse;
	upstream->demo.autorecording = qfalse;
}