From 6f6ddbce2864138ff26f138c8cffd4f07e7e7266 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 27 Oct 2023 03:42:01 +0300 Subject: [PATCH] engine: add argument -timedemo that makes engine run timedemo and exit --- engine/client/cl_demo.c | 5 ++++- engine/common/host.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 44ad36cd..e947c76d 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -1124,7 +1124,10 @@ void CL_FinishTimeDemo( void ) time = host.realtime - cls.td_starttime; if( !time ) time = 1.0; - Con_Printf( "%i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time ); + Con_Printf( "timedemo result: %i frames %5.3f seconds %5.3f fps\n", frames, time, frames / time ); + + if( Sys_CheckParm( "-timedemo" )) + CL_Quit_f(); } /* diff --git a/engine/common/host.c b/engine/common/host.c index 66e0625d..577bc913 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -127,6 +127,7 @@ void Sys_PrintUsage( void ) O("-noenginejoy ", "disable engine builtin joystick support") O("-noenginemouse ", "disable engine builtin mouse support") O("-nosound ", "disable sound output") + O("-timedemo ", "run timedemo and exit") #endif "\nPlatform-specific options:\n" @@ -1158,6 +1159,7 @@ Host_Main int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) { static double oldtime, newtime; + string demoname; host.starttime = Sys_DoubleTime(); @@ -1254,6 +1256,9 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa Cbuf_ExecStuffCmds(); // execute stuffcmds (commandline) SCR_CheckStartupVids(); // must be last + if( Sys_GetParmFromCmdLine( "-timedemo", demoname )) + Cbuf_AddTextf( "timedemo %s\n", demoname ); + oldtime = Sys_DoubleTime() - 0.1; if( Host_IsDedicated( ))