Add timescale cvar

Slow the game down to debug animations / interpolation problems! Speed it up if you need to get somewhere quickly while mapping!
This commit is contained in:
Sally Coolatta 2022-03-29 21:58:14 -04:00 committed by Eidolon
parent f2a19b29d9
commit bb6d4d10b5
2 changed files with 17 additions and 0 deletions

View file

@ -194,6 +194,9 @@ extern UINT8 *scr_borderpatch; // patch used to fill the view borders
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen;
// wait for page flipping to end or not
extern consvar_t cv_vidwait;
#ifdef DEVELOP
extern consvar_t cv_timescale;
#endif
// Initialize the screen
void SCR_Startup(void);

View file

@ -2147,6 +2147,16 @@ static double tic_frequency;
static Uint64 tic_epoch;
static double elapsed_tics;
#ifdef DEVELOP // Tied behind DEVELOP, until sv_cheats is made better
static void UpdateTicFreq(void)
{
tic_frequency = (timer_frequency / (double)NEWTICRATE) / FIXED_TO_FLOAT(cv_timescale.value);
}
static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_timescale = CVAR_INIT ("timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT|CV_CALL, timescale_cons_t, UpdateTicFreq);
#endif
static void UpdateElapsedTics(void)
{
const Uint64 now = SDL_GetPerformanceCounter();
@ -2251,6 +2261,10 @@ double I_GetFrameTime(void)
//
void I_StartupTimer(void)
{
#ifdef DEVELOP
CV_RegisterVar(&cv_timescale);
#endif
timer_frequency = SDL_GetPerformanceFrequency();
tic_epoch = SDL_GetPerformanceCounter();