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 (); // Sbar_SortFrags ();
pr_global_struct->time = qcvm->time; 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_PARM0) = glwidth/s;
G_FLOAT(OFS_PARM1) = glheight/s; G_FLOAT(OFS_PARM1) = glheight/s;
G_FLOAT(OFS_PARM2) = true; G_FLOAT(OFS_PARM2) = true;

View file

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

View file

@ -403,6 +403,7 @@ struct qcvm_s
//originally part of the sv_state_t struct //originally part of the sv_state_t struct
//FIXME: put worldmodel in here too. //FIXME: put worldmodel in here too.
double time; double time;
double frametime;
int num_edicts; int num_edicts;
int reserved_edicts; int reserved_edicts;
int max_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. 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); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
PR_SwitchQCVM(&cl.qcvm); 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) if (qcvm->extglobals.cltime)
*qcvm->extglobals.cltime = realtime; *qcvm->extglobals.cltime = realtime;
if (qcvm->extglobals.clframetime) if (qcvm->extglobals.clframetime)
*qcvm->extglobals.clframetime = host_frametime; *qcvm->extglobals.clframetime = host_frametime;
if (qcvm->extglobals.player_localentnum) if (qcvm->extglobals.player_localentnum)
*qcvm->extglobals.player_localentnum = cl.viewentity; *qcvm->extglobals.player_localentnum = cl.viewentity;
pr_global_struct->time = cl.time;
Sbar_SortFrags (); Sbar_SortFrags ();
G_VECTORSET(OFS_PARM0, vid.width/s, vid.height/s, 0); G_VECTORSET(OFS_PARM0, vid.width/s, vid.height/s, 0);
G_FLOAT(OFS_PARM1) = sb_showscores; 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_ClientPrintf (const char *fmt, ...) FUNC_PRINTF(1,2);
void SV_BroadcastPrintf (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_CheckBottom (edict_t *ent);
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink); 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 // run two frames to allow everything to settle
host_frametime = 0.1; host_frametime = 0.1;
SV_Physics (); SV_Physics (host_frametime);
SV_Physics (); SV_Physics (host_frametime);
// create a baseline for more efficient communications // create a baseline for more efficient communications
SV_CreateBaseline (); SV_CreateBaseline ();

View file

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