Skip to content

Commit

Permalink
Add CVAR host_phys_cst_ticrate [0 - 72] (default = 0 = disabled) to a…
Browse files Browse the repository at this point in the history
…lways run physics at the specified value
  • Loading branch information
vsonnier committed Jul 4, 2024
1 parent 0e77c27 commit 9d3851c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 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 / 72;
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_cst_ticrate = {"host_phys_cst_ticrate", "0", CVAR_ARCHIVE}; // vso = [0 = disabled; 72]

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_cst_ticrate overrides normal behaviour
if (host_phys_cst_ticrate.value > 0)
{
Phys_Ticrate_f (&host_phys_cst_ticrate);
return;
}

if (var->value > 72 || var->value <= 0)
{
if (!host_netinterval)
Expand All @@ -134,6 +148,27 @@ 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, use only integer values
var->value = roundf (CLAMP (0, var->value, 72));

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

/*
================
Host_EndGame
Expand Down Expand Up @@ -296,6 +331,9 @@ void Host_InitLocal (void)
Cvar_SetCallback (&host_maxfps, Max_Fps_f);
Cvar_RegisterVariable (&host_timescale); // johnfitz

Cvar_RegisterVariable (&host_phys_cst_ticrate); // vso
Cvar_SetCallback (&host_phys_cst_ticrate, Phys_Ticrate_f); // vso

Cvar_RegisterVariable (&cl_nocsqc); // spike
Cvar_RegisterVariable (&max_edicts); // johnfitz
Cvar_SetCallback (&max_edicts, Max_Edicts_f);
Expand Down

0 comments on commit 9d3851c

Please sign in to comment.