Skip to content

Commit

Permalink
Add CVAR host_phys_max_ticrate [0 - MAX_PHYSICS_FREQ] (default = 0 = …
Browse files Browse the repository at this point in the history
…disabled, nor archived) to run physics not faster the specified ticrate
  • Loading branch information
vsonnier committed Jul 15, 2024
1 parent debcaca commit b9d9f76
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Quake/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ float host_netinterval = 1.0 / MAX_PHYSICS_FREQ;
cvar_t host_framerate = {"host_framerate", "0", CVAR_NONE}; // set for slow motion
cvar_t host_speeds = {"host_speeds", "0", CVAR_NONE}; // set for running times
cvar_t host_maxfps = {"host_maxfps", "200", CVAR_ARCHIVE}; // johnfitz

cvar_t host_phys_max_ticrate = {"host_phys_max_ticrate", "0", CVAR_NONE}; // vso = [0 = disabled; MAX_PHYSICS_FREQ]

cvar_t host_timescale = {"host_timescale", "0", CVAR_NONE}; // johnfitz
cvar_t max_edicts = {"max_edicts", "8192", CVAR_NONE}; // johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE
cvar_t cl_nocsqc = {"cl_nocsqc", "0", CVAR_NONE}; // spike -- blocks the loading of any csqc modules
Expand Down Expand Up @@ -110,13 +113,24 @@ static void Max_Edicts_f (cvar_t *var)
Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n");
}

// forward declarations for below...
static void Max_Fps_f (cvar_t *var);
static void Phys_Ticrate_f (cvar_t *var);

/*
================
Max_Fps_f -- ericw
================
*/
static void Max_Fps_f (cvar_t *var)
{
// host_phys_max_ticrate overrides normal behaviour
if (host_phys_max_ticrate.value > 0)
{
Phys_Ticrate_f (&host_phys_max_ticrate);
return;
}

if (var->value > MAX_PHYSICS_FREQ || var->value <= 0)
{
if (!host_netinterval)
Expand All @@ -134,6 +148,29 @@ static void Max_Fps_f (cvar_t *var)
}
}

/*
================
Phys_Ticrate_f -- vso
================
*/
static void Phys_Ticrate_f (cvar_t *var)
{
if (var->value > 0)
{
// clamp within valid limits, authorize float values
var->value = CLAMP (0.0, var->value, MAX_PHYSICS_FREQ);

Con_Printf ("Using max physics tics rate = %dHz.\n", (int)var->value);
host_netinterval = 1.0 / var->value;
}
else
{
Con_Printf ("Disable max physics tics rate, using host_maxfps control...\n");
// apply max_fps policy
Max_Fps_f (&host_maxfps);
}
}

/*
================
Host_EndGame
Expand Down Expand Up @@ -294,6 +331,8 @@ void Host_InitLocal (void)
Cvar_RegisterVariable (&host_speeds);
Cvar_RegisterVariable (&host_maxfps); // johnfitz
Cvar_SetCallback (&host_maxfps, Max_Fps_f);
Cvar_RegisterVariable (&host_phys_max_ticrate); // vso
Cvar_SetCallback (&host_phys_max_ticrate, Phys_Ticrate_f);
Cvar_RegisterVariable (&host_timescale); // johnfitz

Cvar_RegisterVariable (&cl_nocsqc); // spike
Expand Down

0 comments on commit b9d9f76

Please sign in to comment.