This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/client/cl_cmds.c

294 lines
5.9 KiB
C
Raw Normal View History

2007-11-06 22:00:00 +01:00
//=======================================================================
// Copyright XashXT Group 2007 <20>
// cl_cmds.c - client console commnds
//=======================================================================
2008-06-09 22:00:00 +02:00
#include "common.h"
2007-11-06 22:00:00 +01:00
#include "client.h"
2010-03-26 22:00:00 +01:00
#define SCRSHOT_TYPE SI->scrshot_ext
#define LEVELSHOT_TYPE SI->levshot_ext
#define SAVESHOT_TYPE SI->savshot_ext
#define DEMOSHOT_TYPE SI->savshot_ext
2008-10-20 22:00:00 +02:00
2008-08-04 22:00:00 +02:00
/*
====================
CL_PlayVideo_f
movie <moviename>
====================
*/
void CL_PlayVideo_f( void )
{
if( Cmd_Argc() != 2 )
{
Msg( "movie <moviename>\n" );
return;
}
if( cls.state == ca_active )
{
// FIXME: get rid of this stupid alias
2010-03-26 22:00:00 +01:00
Cbuf_AddText( va( "killserver\n; wait\n; movie %s\n;", Cmd_Argv( 1 )));
2008-08-04 22:00:00 +02:00
return;
}
2009-11-23 22:00:00 +01:00
SCR_PlayCinematic( Cmd_Argv( 1 ));
2008-08-04 22:00:00 +02:00
}
2008-08-02 22:00:00 +02:00
/*
===============
CL_Download_f
Request a download from the server
===============
*/
void CL_Download_f( void )
{
if( Cmd_Argc() != 2 )
{
Msg( "Usage: download <filename>\n" );
return;
}
CL_CheckOrDownloadFile(Cmd_Argv(1));
}
2007-11-06 22:00:00 +01:00
/*
==================
CL_ScreenshotGetName
==================
*/
void CL_ScreenshotGetName( int lastnum, char *filename )
{
int a, b, c, d;
2009-07-03 22:00:00 +02:00
if( !filename ) return;
if( lastnum < 0 || lastnum > 9999 )
2007-11-06 22:00:00 +01:00
{
// bound
2010-03-26 22:00:00 +01:00
com.sprintf( filename, "scrshots/%s/!error.%s", cl.configstrings[CS_NAME], SCRSHOT_TYPE );
2007-11-06 22:00:00 +01:00
return;
}
a = lastnum / 1000;
lastnum -= a * 1000;
b = lastnum / 100;
lastnum -= b * 100;
c = lastnum / 10;
lastnum -= c * 10;
d = lastnum;
2008-10-20 22:00:00 +02:00
com.sprintf( filename, "scrshots/%s/shot%i%i%i%i.%s", cl.configstrings[CS_NAME], a, b, c, d, SCRSHOT_TYPE );
2007-11-06 22:00:00 +01:00
}
/*
==============================================================================
SCREEN SHOTS
==============================================================================
*/
/*
==================
CL_ScreenShot_f
normal screenshot
==================
*/
void CL_ScreenShot_f( void )
{
2008-07-23 22:00:00 +02:00
int i;
string checkname;
2007-11-06 22:00:00 +01:00
// scan for a free filename
2009-07-03 22:00:00 +02:00
for( i = 0; i <= 9999; i++ )
2007-11-06 22:00:00 +01:00
{
CL_ScreenshotGetName( i, checkname );
2009-07-03 22:00:00 +02:00
if( !FS_FileExists( checkname )) break;
2007-11-06 22:00:00 +01:00
}
Con_ClearNotify();
2009-09-10 22:00:00 +02:00
re->ScrShot( checkname, VID_SCREENSHOT );
2007-11-06 22:00:00 +01:00
}
2008-11-09 22:00:00 +01:00
void CL_EnvShot_f( void )
{
2009-07-03 22:00:00 +02:00
if( Cmd_Argc() < 2 )
2008-11-09 22:00:00 +01:00
{
2009-07-03 22:00:00 +02:00
Msg( "Usage: envshot <shotname>\n" );
2008-11-09 22:00:00 +01:00
return;
}
2010-03-26 22:00:00 +01:00
com.sprintf( cls.shotname, "%s/%s", SI->envpath, Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_envshot; // build new frame for envshot
cls.envshot_vieworg = NULL; // no custom view
2008-11-09 22:00:00 +01:00
}
void CL_SkyShot_f( void )
{
2009-07-03 22:00:00 +02:00
if( Cmd_Argc() < 2 )
2008-11-09 22:00:00 +01:00
{
2010-03-26 22:00:00 +01:00
Msg( "Usage: skyshot <shotname>\n" );
2008-11-09 22:00:00 +01:00
return;
}
2010-03-26 22:00:00 +01:00
com.sprintf( cls.shotname, "%s/%s", SI->envpath, Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_skyshot; // build new frame for skyshot
cls.envshot_vieworg = NULL; // no custom view
2008-11-09 22:00:00 +01:00
}
2007-11-06 22:00:00 +01:00
/*
==================
CL_LevelShot_f
splash logo while map is loading
==================
*/
void CL_LevelShot_f( void )
{
2009-09-23 22:00:00 +02:00
if( cls.scrshot_request != scrshot_plaque ) return;
cls.scrshot_request = scrshot_inactive;
2007-11-06 22:00:00 +01:00
// check for exist
2010-03-06 22:00:00 +01:00
com.sprintf( cls.shotname, "levelshots/%s.%s", cl.configstrings[CS_NAME], LEVELSHOT_TYPE );
2010-06-17 22:00:00 +02:00
if( !FS_FileExists( va( "<EFBFBD>%s", cls.shotname )))
2009-09-23 22:00:00 +02:00
cls.scrshot_action = scrshot_plaque; // build new frame for levelshot
else cls.scrshot_action = scrshot_inactive; // disable - not needs
2007-11-13 22:00:00 +01:00
}
2009-09-10 22:00:00 +02:00
/*
==================
CL_SaveShot_f
mini-pic in loadgame menu
==================
*/
void CL_SaveShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Msg( "Usage: saveshot <savename>\n" );
return;
}
2010-03-10 22:00:00 +01:00
com.sprintf( cls.shotname, "save/%s.%s", Cmd_Argv( 1 ), SAVESHOT_TYPE );
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
2009-09-10 22:00:00 +02:00
}
2010-01-07 22:00:00 +01:00
/*
==================
CL_DemoShot_f
mini-pic in playdemo menu
==================
*/
void CL_DemoShot_f( void )
{
if( Cmd_Argc() < 2 )
{
2010-03-26 22:00:00 +01:00
Msg( "Usage: demoshot <demoname>\n" );
2010-01-07 22:00:00 +01:00
return;
}
2010-03-10 22:00:00 +01:00
com.sprintf( cls.shotname, "demos/%s.%s", Cmd_Argv( 1 ), DEMOSHOT_TYPE );
cls.scrshot_action = scrshot_demoshot; // build new frame for demoshot
2010-01-07 22:00:00 +01:00
}
/*
==============
CL_DeleteDemo_f
==============
*/
void CL_DeleteDemo_f( void )
{
if( Cmd_Argc() != 2 )
{
2010-04-03 22:00:00 +02:00
Msg( "Usage: killdemo <name>\n" );
2010-01-07 22:00:00 +01:00
return;
}
if( cls.demorecording && !com.stricmp( cls.demoname, Cmd_Argv( 1 )))
{
Msg( "Can't delete %s - recording\n", Cmd_Argv( 1 ));
return;
}
// delete save and saveshot
2010-03-27 22:00:00 +01:00
FS_Delete( va( "demos/%s.dem", Cmd_Argv( 1 )));
FS_Delete( va( "demos/%s.%s", Cmd_Argv( 1 ), DEMOSHOT_TYPE ));
2010-01-07 22:00:00 +01:00
}
2007-11-13 22:00:00 +01:00
/*
=================
CL_SetSky_f
Set a specific sky and rotation speed
=================
*/
void CL_SetSky_f( void )
{
2009-08-07 22:00:00 +02:00
if( Cmd_Argc() < 2 )
2007-11-13 22:00:00 +01:00
{
2009-07-03 22:00:00 +02:00
Msg( "Usage: sky <shadername>\n" );
2007-11-13 22:00:00 +01:00
return;
}
2009-07-26 22:00:00 +02:00
re->RegisterShader( Cmd_Argv(1), SHADER_SKY );
2007-11-13 22:00:00 +01:00
}
/*
================
SCR_TimeRefresh_f
2008-08-04 22:00:00 +02:00
timerefres [noflip]
2007-11-13 22:00:00 +01:00
================
*/
2008-06-30 22:00:00 +02:00
void SCR_TimeRefresh_f( void )
2007-11-13 22:00:00 +01:00
{
int i;
2009-06-22 22:00:00 +02:00
double start, stop;
double time;
2007-11-13 22:00:00 +01:00
2009-09-17 22:00:00 +02:00
if( cls.state != ca_active )
2007-11-13 22:00:00 +01:00
return;
2009-06-22 22:00:00 +02:00
start = Sys_DoubleTime();
2007-11-13 22:00:00 +01:00
2008-06-30 22:00:00 +02:00
if( Cmd_Argc() == 2 )
2007-11-13 22:00:00 +01:00
{
// run without page flipping
2009-10-12 22:00:00 +02:00
re->BeginFrame( false );
2008-06-30 22:00:00 +02:00
for( i = 0; i < 128; i++ )
2007-11-13 22:00:00 +01:00
{
2009-06-22 22:00:00 +02:00
cl.refdef.viewangles[1] = i / 128.0 * 360.0f;
re->RenderFrame( &cl.refdef );
2007-11-13 22:00:00 +01:00
}
re->EndFrame();
}
else
{
2008-06-30 22:00:00 +02:00
for( i = 0; i < 128; i++ )
2007-11-13 22:00:00 +01:00
{
2009-06-22 22:00:00 +02:00
cl.refdef.viewangles[1] = i / 128.0 * 360.0f;
2007-11-13 22:00:00 +01:00
2009-10-12 22:00:00 +02:00
re->BeginFrame( true );
2009-07-03 22:00:00 +02:00
re->RenderFrame( &cl.refdef );
2007-11-13 22:00:00 +01:00
re->EndFrame();
}
}
2009-06-22 22:00:00 +02:00
stop = Sys_DoubleTime ();
time = (stop - start);
2008-06-30 22:00:00 +02:00
Msg( "%f seconds (%f fps)\n", time, 128 / time );
2008-08-04 22:00:00 +02:00
}
/*
=============
SCR_Viewpos_f
viewpos
=============
*/
void SCR_Viewpos_f( void )
{
2009-12-01 22:00:00 +01:00
Msg( "org ( %g %g %g )\n", cl.refdef.vieworg[0], cl.refdef.vieworg[1], cl.refdef.vieworg[2] );
Msg( "ang ( %g %g %g )\n", cl.refdef.viewangles[0], cl.refdef.viewangles[1], cl.refdef.viewangles[2] );
2007-11-06 22:00:00 +01:00
}