mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
cl_scrn.c aufgeräumt und neu durchkommentiert
This commit is contained in:
parent
769f15a318
commit
bb0ff2c6f5
2 changed files with 509 additions and 721 deletions
|
@ -1,33 +1,26 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "header/client.h"
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
CL_CheckPredictionError
|
||||
===================
|
||||
*/
|
||||
void CL_CheckPredictionError (void)
|
||||
{
|
||||
void CL_CheckPredictionError (void) {
|
||||
int frame;
|
||||
int delta[3];
|
||||
int i;
|
||||
|
@ -36,53 +29,45 @@ void CL_CheckPredictionError (void)
|
|||
if (!cl_predict->value || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION))
|
||||
return;
|
||||
|
||||
// calculate the last usercmd_t we sent that the server has processed
|
||||
/* calculate the last usercmd_t we sent that the server has processed */
|
||||
frame = cls.netchan.incoming_acknowledged;
|
||||
frame &= (CMD_BACKUP-1);
|
||||
|
||||
// compare what the server returned with what we had predicted it to be
|
||||
/* compare what the server returned with what we had predicted it to be */
|
||||
VectorSubtract (cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame], delta);
|
||||
|
||||
// save the prediction error for interpolation
|
||||
/* save the prediction error for interpolation */
|
||||
len = abs(delta[0]) + abs(delta[1]) + abs(delta[2]);
|
||||
if (len > 640) // 80 world units
|
||||
{ // a teleport or something
|
||||
|
||||
/* 80 world units */
|
||||
if (len > 640) {
|
||||
/* a teleport or something */
|
||||
VectorClear (cl.prediction_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
} else {
|
||||
if (cl_showmiss->value && (delta[0] || delta[1] || delta[2]) )
|
||||
Com_Printf ("prediction miss on %i: %i\n", cl.frame.serverframe,
|
||||
delta[0] + delta[1] + delta[2]);
|
||||
Com_Printf ("prediction miss on %i: %i\n", cl.frame.serverframe,
|
||||
delta[0] + delta[1] + delta[2]);
|
||||
|
||||
VectorCopy (cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame]);
|
||||
|
||||
// save for error itnerpolation
|
||||
/* save for error itnerpolation */
|
||||
for (i=0 ; i<3 ; i++)
|
||||
cl.prediction_error[i] = delta[i]*0.125f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
CL_ClipMoveToEntities
|
||||
|
||||
====================
|
||||
*/
|
||||
void CL_ClipMoveToEntities ( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *tr )
|
||||
{
|
||||
void CL_ClipMoveToEntities ( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, trace_t *tr ) {
|
||||
int i, x, zd, zu;
|
||||
trace_t trace;
|
||||
int headnode;
|
||||
float *angles;
|
||||
entity_state_t *ent;
|
||||
int num;
|
||||
cmodel_t *cmodel;
|
||||
cmodel_t *cmodel;
|
||||
vec3_t bmins, bmaxs;
|
||||
|
||||
for (i=0 ; i<cl.frame.num_entities ; i++)
|
||||
{
|
||||
for (i=0 ; i<cl.frame.num_entities ; i++) {
|
||||
num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
|
||||
ent = &cl_parse_entities[num];
|
||||
|
||||
|
@ -92,16 +77,18 @@ void CL_ClipMoveToEntities ( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end,
|
|||
if (ent->number == cl.playernum+1)
|
||||
continue;
|
||||
|
||||
if (ent->solid == 31)
|
||||
{ // special value for bmodel
|
||||
if (ent->solid == 31) {
|
||||
/* special value for bmodel */
|
||||
cmodel = cl.model_clip[ent->modelindex];
|
||||
|
||||
if (!cmodel)
|
||||
continue;
|
||||
|
||||
headnode = cmodel->headnode;
|
||||
angles = ent->angles;
|
||||
}
|
||||
else
|
||||
{ // encoded bbox
|
||||
|
||||
} else {
|
||||
/* encoded bbox */
|
||||
x = 8*(ent->solid & 31);
|
||||
zd = 8*((ent->solid>>5) & 31);
|
||||
zu = 8*((ent->solid>>10) & 63) - 32;
|
||||
|
@ -112,56 +99,48 @@ void CL_ClipMoveToEntities ( vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end,
|
|||
bmaxs[2] = (float)zu;
|
||||
|
||||
headnode = CM_HeadnodeForBox (bmins, bmaxs);
|
||||
angles = vec3_origin; // boxes don't rotate
|
||||
angles = vec3_origin; /* boxes don't rotate */
|
||||
}
|
||||
|
||||
if (tr->allsolid)
|
||||
return;
|
||||
|
||||
trace = CM_TransformedBoxTrace (start, end,
|
||||
mins, maxs, headnode, MASK_PLAYERSOLID,
|
||||
ent->origin, angles);
|
||||
mins, maxs, headnode, MASK_PLAYERSOLID,
|
||||
ent->origin, angles);
|
||||
|
||||
if (trace.allsolid || trace.startsolid ||
|
||||
trace.fraction < tr->fraction)
|
||||
{
|
||||
trace.fraction < tr->fraction) {
|
||||
trace.ent = (struct edict_s *)ent;
|
||||
if (tr->startsolid)
|
||||
{
|
||||
|
||||
if (tr->startsolid) {
|
||||
*tr = trace;
|
||||
tr->startsolid = true;
|
||||
}
|
||||
else
|
||||
|
||||
} else
|
||||
*tr = trace;
|
||||
}
|
||||
else if (trace.startsolid)
|
||||
|
||||
} else if (trace.startsolid)
|
||||
tr->startsolid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CL_PMTrace
|
||||
================
|
||||
*/
|
||||
trace_t CL_PMTrace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end)
|
||||
{
|
||||
trace_t CL_PMTrace (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) {
|
||||
trace_t t;
|
||||
|
||||
// check against world
|
||||
/* check against world */
|
||||
t = CM_BoxTrace (start, end, mins, maxs, 0, MASK_PLAYERSOLID);
|
||||
|
||||
if (t.fraction < 1.0)
|
||||
t.ent = (struct edict_s *)1;
|
||||
|
||||
// check all other solid models
|
||||
/* check all other solid models */
|
||||
CL_ClipMoveToEntities (start, mins, maxs, end, &t);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
int CL_PMpointcontents (vec3_t point)
|
||||
{
|
||||
int CL_PMpointcontents (vec3_t point) {
|
||||
int i;
|
||||
entity_state_t *ent;
|
||||
int num;
|
||||
|
@ -170,15 +149,15 @@ int CL_PMpointcontents (vec3_t point)
|
|||
|
||||
contents = CM_PointContents (point, 0);
|
||||
|
||||
for (i=0 ; i<cl.frame.num_entities ; i++)
|
||||
{
|
||||
for (i=0 ; i<cl.frame.num_entities ; i++) {
|
||||
num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
|
||||
ent = &cl_parse_entities[num];
|
||||
|
||||
if (ent->solid != 31) // special value for bmodel
|
||||
if (ent->solid != 31) /* special value for bmodel */
|
||||
continue;
|
||||
|
||||
cmodel = cl.model_clip[ent->modelindex];
|
||||
|
||||
if (!cmodel)
|
||||
continue;
|
||||
|
||||
|
@ -190,14 +169,9 @@ int CL_PMpointcontents (vec3_t point)
|
|||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_PredictMovement
|
||||
|
||||
Sets cl.predicted_origin and cl.predicted_angles
|
||||
=================
|
||||
*/
|
||||
void CL_PredictMovement (void)
|
||||
{
|
||||
* Sets cl.predicted_origin and cl.predicted_angles
|
||||
*/
|
||||
void CL_PredictMovement (void) {
|
||||
int ack, current;
|
||||
int frame;
|
||||
int oldframe;
|
||||
|
@ -213,27 +187,27 @@ void CL_PredictMovement (void)
|
|||
if (cl_paused->value)
|
||||
return;
|
||||
|
||||
if (!cl_predict->value || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION))
|
||||
{ // just set angles
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
if (!cl_predict->value || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION)) {
|
||||
/* just set angles */
|
||||
for (i=0 ; i<3 ; i++) {
|
||||
cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ack = cls.netchan.incoming_acknowledged;
|
||||
current = cls.netchan.outgoing_sequence;
|
||||
|
||||
// if we are too far out of date, just freeze
|
||||
if (current - ack >= CMD_BACKUP)
|
||||
{
|
||||
/* if we are too far out of date, just freeze */
|
||||
if (current - ack >= CMD_BACKUP) {
|
||||
if (cl_showmiss->value)
|
||||
Com_Printf ("exceeded CMD_BACKUP\n");
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// copy current state to pmove
|
||||
/* copy current state to pmove */
|
||||
pm.trace = CL_PMTrace;
|
||||
pm.pointcontents = CL_PMpointcontents;
|
||||
|
||||
|
@ -246,30 +220,28 @@ void CL_PredictMovement (void)
|
|||
VectorSet (pm.mins, -16, -16, -24);
|
||||
VectorSet (pm.maxs, 16, 16, 32);
|
||||
|
||||
// run frames
|
||||
while (++ack < current)
|
||||
{
|
||||
/* run frames */
|
||||
while (++ack < current) {
|
||||
frame = ack & (CMD_BACKUP-1);
|
||||
cmd = &cl.cmds[frame];
|
||||
|
||||
pm.cmd = *cmd;
|
||||
Pmove (&pm);
|
||||
|
||||
// save for debug checking
|
||||
/* save for debug checking */
|
||||
VectorCopy (pm.s.origin, cl.predicted_origins[frame]);
|
||||
}
|
||||
|
||||
oldframe = (ack-2) & (CMD_BACKUP-1);
|
||||
oldz = cl.predicted_origins[oldframe][2];
|
||||
step = pm.s.origin[2] - oldz;
|
||||
if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) )
|
||||
{
|
||||
|
||||
if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) ) {
|
||||
cl.predicted_step = step * 0.125f;
|
||||
cl.predicted_step_time = cls.realtime - cls.frametime * 500;
|
||||
}
|
||||
|
||||
|
||||
// copy results out for rendering
|
||||
/* copy results out for rendering */
|
||||
cl.predicted_origin[0] = pm.s.origin[0]*0.125f;
|
||||
cl.predicted_origin[1] = pm.s.origin[1]*0.125f;
|
||||
cl.predicted_origin[2] = pm.s.origin[2]*0.125f;
|
||||
|
|
1048
src/client/cl_scrn.c
1048
src/client/cl_scrn.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue