mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-16 06:00:33 +01:00
engine: add sys_timescale implementation
This commit is contained in:
parent
edc171be04
commit
85f99c723a
@ -533,6 +533,8 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
|
||||
// spatialize
|
||||
memset( target_chan, 0, sizeof( *target_chan ));
|
||||
|
||||
pitch *= (sys_timescale.value + 1) / 2;
|
||||
|
||||
VectorCopy( pos, target_chan->origin );
|
||||
target_chan->staticsound = ( ent == 0 ) ? true : false;
|
||||
target_chan->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
|
||||
@ -788,6 +790,8 @@ void S_AmbientSound( const vec3_t pos, int ent, sound_t handle, float fvol, floa
|
||||
return;
|
||||
}
|
||||
|
||||
pitch *= (sys_timescale.value + 1) / 2;
|
||||
|
||||
// never update positions if source entity is 0
|
||||
ch->staticsound = ( ent == 0 ) ? true : false;
|
||||
ch->use_loop = (flags & SND_STOP_LOOPING) ? false : true;
|
||||
|
@ -184,7 +184,8 @@ extern convar_t host_developer;
|
||||
extern convar_t *host_limitlocal;
|
||||
extern convar_t *host_framerate;
|
||||
extern convar_t *host_maxfps;
|
||||
extern convar_t cl_filterstuffcmd;
|
||||
extern convar_t sys_timescale;
|
||||
extern convar_t cl_filterstuffcmd;
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
@ -51,6 +51,7 @@ struct tests_stats_s tests_stats;
|
||||
#endif
|
||||
|
||||
CVAR_DEFINE( host_developer, "developer", "0", FCVAR_FILTERABLE, "engine is in development-mode" );
|
||||
CVAR_DEFINE_AUTO( sys_timescale, "1.0", FCVAR_CHEAT|FCVAR_FILTERABLE, "scale frame time" );
|
||||
CVAR_DEFINE_AUTO( sys_ticrate, "100", 0, "framerate in dedicated mode" );
|
||||
|
||||
convar_t *host_serverstate;
|
||||
@ -626,8 +627,9 @@ qboolean Host_FilterTime( float time )
|
||||
{
|
||||
static double oldtime;
|
||||
double fps;
|
||||
double scale = sys_timescale.value;
|
||||
|
||||
host.realtime += time;
|
||||
host.realtime += time * scale;
|
||||
fps = Host_CalcFPS( );
|
||||
|
||||
// clamp the fps in multiplayer games
|
||||
@ -638,12 +640,12 @@ qboolean Host_FilterTime( float time )
|
||||
|
||||
if( Host_IsDedicated() )
|
||||
{
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )))
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / ( fps + 1.0 )) * scale)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / fps ))
|
||||
if(( host.realtime - oldtime ) < ( 1.0 / fps ) * scale )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -654,7 +656,7 @@ qboolean Host_FilterTime( float time )
|
||||
|
||||
// NOTE: allow only in singleplayer while demos are not active
|
||||
if( host_framerate->value > 0.0f && Host_IsLocalGame() && !CL_IsPlaybackDemo() && !CL_IsRecordDemo( ))
|
||||
host.frametime = bound( MIN_FRAMETIME, host_framerate->value, MAX_FRAMETIME );
|
||||
host.frametime = bound( MIN_FRAMETIME, host_framerate->value * scale, MAX_FRAMETIME );
|
||||
else host.frametime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
|
||||
|
||||
return true;
|
||||
@ -1101,6 +1103,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa
|
||||
host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" );
|
||||
host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" );
|
||||
con_gamemaps = Cvar_Get( "con_mapfilter", "1", FCVAR_ARCHIVE, "when true show only maps in game folder" );
|
||||
Cvar_RegisterVariable( &sys_timescale );
|
||||
|
||||
build = Cvar_Get( "buildnum", va( "%i", Q_buildnum_compat()), FCVAR_READ_ONLY, "returns a current build number" );
|
||||
ver = Cvar_Get( "ver", va( "%i/%s (hw build %i)", PROTOCOL_VERSION, XASH_COMPAT_VERSION, Q_buildnum_compat()), FCVAR_READ_ONLY, "shows an engine version" );
|
||||
|
Loading…
Reference in New Issue
Block a user