Shpoike 2022-07-19 22:36:57 +01:00
parent 987bc0ee75
commit eb02e3b5ed
7 changed files with 32 additions and 28 deletions

View File

@ -1184,7 +1184,7 @@ void SCR_UpdateScreen (void)
// Sbar_SortFrags ();
pr_global_struct->time = qcvm->time;
pr_global_struct->frametime = host_frametime;
pr_global_struct->frametime = qcvm->frametime;
G_FLOAT(OFS_PARM0) = glwidth/s;
G_FLOAT(OFS_PARM1) = glheight/s;
G_FLOAT(OFS_PARM2) = true;

View File

@ -714,7 +714,7 @@ void Host_ServerFrame (void)
// move things around and think
// always pause in single player if in console or menus
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
SV_Physics ();
SV_Physics (host_frametime);
//johnfitz -- devstats
if (cls.signon == SIGNONS)
@ -803,7 +803,7 @@ static void CL_LoadCSProgs(void)
//set a few globals, if they exist
if (qcvm->extglobals.maxclients)
*qcvm->extglobals.maxclients = cl.maxclients;
pr_global_struct->time = cl.time;
pr_global_struct->time = qcvm->time = cl.time;
pr_global_struct->mapname = PR_SetEngineString(cl.mapname);
pr_global_struct->total_monsters = cl.statsf[STAT_TOTALMONSTERS];
pr_global_struct->total_secrets = cl.statsf[STAT_TOTALSECRETS];
@ -934,8 +934,8 @@ void _Host_Frame (double time)
if (cl.qcvm.progs)
{
PR_SwitchQCVM(&cl.qcvm);
pr_global_struct->frametime = host_frametime;
SV_Physics();
SV_Physics(cl.time - qcvm->time);
pr_global_struct->time = cl.time;
PR_SwitchQCVM(NULL);
}

View File

@ -403,6 +403,7 @@ struct qcvm_s
//originally part of the sv_state_t struct
//FIXME: put worldmodel in here too.
double time;
double frametime;
int num_edicts;
int reserved_edicts;
int max_edicts;

View File

@ -976,14 +976,14 @@ void Sbar_Draw (void)
glDisable (GL_ALPHA_TEST); //in the finest tradition of glquake, we litter gl state calls all over the place. yay state trackers.
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
PR_SwitchQCVM(&cl.qcvm);
pr_global_struct->frametime = host_frametime;
pr_global_struct->time = qcvm->time;
pr_global_struct->frametime = qcvm->frametime;
if (qcvm->extglobals.cltime)
*qcvm->extglobals.cltime = realtime;
if (qcvm->extglobals.clframetime)
*qcvm->extglobals.clframetime = host_frametime;
if (qcvm->extglobals.player_localentnum)
*qcvm->extglobals.player_localentnum = cl.viewentity;
pr_global_struct->time = cl.time;
Sbar_SortFrags ();
G_VECTORSET(OFS_PARM0, vid.width/s, vid.height/s, 0);
G_FLOAT(OFS_PARM1) = sb_showscores;

View File

@ -333,7 +333,7 @@ void SV_AddClientToServer (struct qsocket_s *ret);
void SV_ClientPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
void SV_BroadcastPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
void SV_Physics (void);
void SV_Physics (double frametime);
qboolean SV_CheckBottom (edict_t *ent);
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink);

View File

@ -3666,8 +3666,8 @@ void SV_SpawnServer (const char *server)
// run two frames to allow everything to settle
host_frametime = 0.1;
SV_Physics ();
SV_Physics ();
SV_Physics (host_frametime);
SV_Physics (host_frametime);
// create a baseline for more efficient communications
SV_CreateBaseline ();

View File

@ -150,7 +150,7 @@ qboolean SV_RunThink (edict_t *ent)
int i; //johnfitz
thinktime = ent->v.nextthink;
if (thinktime <= 0 || thinktime > qcvm->time + host_frametime)
if (thinktime <= 0 || thinktime > qcvm->time + qcvm->frametime)
return true;
if (thinktime < qcvm->time)
@ -417,7 +417,7 @@ void SV_AddGravity (edict_t *ent)
else
ent_gravity = 1.0;
ent->v.velocity[2] -= ent_gravity * sv_gravity.value * host_frametime;
ent->v.velocity[2] -= ent_gravity * sv_gravity.value * qcvm->frametime;
}
@ -847,14 +847,14 @@ void SV_Physics_Pusher (edict_t *ent)
oldltime = ent->v.ltime;
thinktime = ent->v.nextthink;
if (thinktime < ent->v.ltime + host_frametime)
if (thinktime < ent->v.ltime + qcvm->frametime)
{
movetime = thinktime - ent->v.ltime;
if (movetime < 0)
movetime = 0;
}
else
movetime = host_frametime;
movetime = qcvm->frametime;
if (movetime)
{
@ -1104,7 +1104,7 @@ void SV_WalkMove (edict_t *ent)
VectorCopy (ent->v.origin, oldorg);
VectorCopy (ent->v.velocity, oldvel);
clip = SV_FlyMove (ent, host_frametime, &steptrace);
clip = SV_FlyMove (ent, qcvm->frametime, &steptrace);
if ( !(clip & 2) )
return; // move didn't block on a step
@ -1132,7 +1132,7 @@ void SV_WalkMove (edict_t *ent)
VectorCopy (vec3_origin, upmove);
VectorCopy (vec3_origin, downmove);
upmove[2] = STEPSIZE;
downmove[2] = -STEPSIZE + oldvel[2]*host_frametime;
downmove[2] = -STEPSIZE + oldvel[2]*qcvm->frametime;
// move up
SV_PushEntity (ent, upmove); // FIXME: don't link?
@ -1141,7 +1141,7 @@ void SV_WalkMove (edict_t *ent)
ent->v.velocity[0] = oldvel[0];
ent->v. velocity[1] = oldvel[1];
ent->v. velocity[2] = 0;
clip = SV_FlyMove (ent, host_frametime, &steptrace);
clip = SV_FlyMove (ent, qcvm->frametime, &steptrace);
// check for stuckness, possibly due to the limited precision of floats
// in the clipping hulls
@ -1246,13 +1246,13 @@ void SV_Physics_Client (edict_t *ent, int num)
case MOVETYPE_FLY:
if (!SV_RunThink (ent))
return;
SV_FlyMove (ent, host_frametime, NULL);
SV_FlyMove (ent, qcvm->frametime, NULL);
break;
case MOVETYPE_NOCLIP:
if (!SV_RunThink (ent))
return;
VectorMA (ent->v.origin, host_frametime, ent->v.velocity, ent->v.origin);
VectorMA (ent->v.origin, qcvm->frametime, ent->v.velocity, ent->v.origin);
break;
default:
@ -1297,8 +1297,8 @@ void SV_Physics_Noclip (edict_t *ent)
if (!SV_RunThink (ent))
return;
VectorMA (ent->v.angles, host_frametime, ent->v.avelocity, ent->v.angles);
VectorMA (ent->v.origin, host_frametime, ent->v.velocity, ent->v.origin);
VectorMA (ent->v.angles, qcvm->frametime, ent->v.avelocity, ent->v.angles);
VectorMA (ent->v.origin, qcvm->frametime, ent->v.velocity, ent->v.origin);
SV_LinkEdict (ent, false);
}
@ -1381,10 +1381,10 @@ void SV_Physics_Toss (edict_t *ent)
SV_AddGravity (ent);
// move angles
VectorMA (ent->v.angles, host_frametime, ent->v.avelocity, ent->v.angles);
VectorMA (ent->v.angles, qcvm->frametime, ent->v.avelocity, ent->v.angles);
// move origin
VectorScale (ent->v.velocity, host_frametime, move);
VectorScale (ent->v.velocity, qcvm->frametime, move);
trace = SV_PushEntity (ent, move);
if (trace.fraction == 1)
return;
@ -1499,7 +1499,7 @@ void SV_Physics_Step (edict_t *ent)
SV_AddGravity (ent);
SV_CheckVelocity (ent);
SV_FlyMove (ent, host_frametime, NULL);
SV_FlyMove (ent, qcvm->frametime, NULL);
SV_LinkEdict (ent, true);
if ( (int)ent->v.flags & FL_ONGROUND ) // just hit ground
@ -1524,7 +1524,7 @@ SV_Physics
================
*/
void SV_Physics (void)
void SV_Physics (double frametime)
{
int i;
int entity_cap; // For sv_freezenonclients
@ -1537,9 +1537,12 @@ void SV_Physics (void)
else
physics_mode = (qcvm==&cl.qcvm)?0:2; //csqc doesn't run thinks by default. it was meant to simplify implementations, but we just force fields to match ssqc so its not that large a burden.
pr_global_struct->time = qcvm->time;
pr_global_struct->frametime = qcvm->frametime = frametime;
if (!physics_mode)
{
qcvm->time += host_frametime;
qcvm->time += frametime;
return;
}
else if (physics_mode==1)
@ -1550,7 +1553,7 @@ void SV_Physics (void)
continue;
SV_RunThink(ent);
}
qcvm->time += host_frametime;
qcvm->time += frametime;
return;
}
// else if (physics_mode==2) standard quake physics
@ -1638,5 +1641,5 @@ void SV_Physics (void)
}
if (!(sv_freezenonclients.value && qcvm == &sv.qcvm))
qcvm->time += host_frametime;
qcvm->time += frametime;
}