mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-21 19:51:18 +00:00
readability cleanup of vector comparisons to 0, now all such comparisons use VectorIsNull, and a little more whitespace cleanup in cl_pred.c
This commit is contained in:
parent
f922262b61
commit
05545350e7
6 changed files with 21 additions and 29 deletions
|
@ -48,6 +48,9 @@ extern int nanmask;
|
|||
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
|
||||
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
|
||||
|
||||
// LordHavoc: makes code more readable
|
||||
#define VectorIsNull(a) ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0)
|
||||
|
||||
/*
|
||||
* VectorDistance, the distance between two points.
|
||||
* Yes, this is the same as sqrt(VectorSubtract then DotProduct),
|
||||
|
|
|
@ -55,9 +55,7 @@ CL_PredictUsercmd (player_state_t * from, player_state_t * to, usercmd_t *u,
|
|||
{
|
||||
|
||||
// Dabb: if there is no movement to start with, don't predict...
|
||||
if(cl_nostatpred->int_val && !from->velocity[0]
|
||||
&& !from->velocity[1]
|
||||
&& !from->velocity[2]) {
|
||||
if(cl_nostatpred->int_val && VectorIsNull(from->velocity)) {
|
||||
VectorCopy (from->origin, to->origin);
|
||||
VectorCopy (u->angles, to->viewangles);
|
||||
VectorCopy (from->velocity, to->velocity);
|
||||
|
@ -123,7 +121,8 @@ CL_PredictMove (void)
|
|||
if (cl.paused)
|
||||
return;
|
||||
|
||||
cl.onground = 0; // assume on ground unless prediction says different
|
||||
// assume on ground unless prediction says different
|
||||
cl.onground = 0;
|
||||
|
||||
cl.time = realtime - cls.latency - cl_pushlatency->value * 0.001;
|
||||
if (cl.time > realtime)
|
||||
|
@ -145,8 +144,8 @@ CL_PredictMove (void)
|
|||
from = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK];
|
||||
|
||||
// we can now render a frame
|
||||
if (cls.state == ca_onserver) { // first update is the final signon
|
||||
// stage
|
||||
if (cls.state == ca_onserver) {
|
||||
// first update is the final signon stage
|
||||
VID_SetCaption (cls.servername);
|
||||
cls.state = ca_active;
|
||||
}
|
||||
|
@ -159,9 +158,8 @@ CL_PredictMove (void)
|
|||
|
||||
// Dabb: if there is no movement to start with, don't predict...
|
||||
|
||||
if(cl_nostatpred->int_val && !from->playerstate[cl.playernum].velocity[0]
|
||||
&& !from->playerstate[cl.playernum].velocity[1]
|
||||
&& !from->playerstate[cl.playernum].velocity[2]) {
|
||||
if(cl_nostatpred->int_val
|
||||
&& VectorIsNull(from->playerstate[cl.playernum].velocity)) {
|
||||
VectorCopy (from->playerstate[cl.playernum].velocity, cl.simvel);
|
||||
VectorCopy (from->playerstate[cl.playernum].origin, cl.simorg);
|
||||
return;
|
||||
|
@ -176,8 +174,8 @@ CL_PredictMove (void)
|
|||
for (i = 1; i < UPDATE_BACKUP - 1 && cls.netchan.incoming_sequence + i <
|
||||
cls.netchan.outgoing_sequence; i++) {
|
||||
to = &cl.frames[(cls.netchan.incoming_sequence + i) & UPDATE_MASK];
|
||||
CL_PredictUsercmd (&from->playerstate[cl.playernum]
|
||||
, &to->playerstate[cl.playernum], &to->cmd,
|
||||
CL_PredictUsercmd (&from->playerstate[cl.playernum],
|
||||
&to->playerstate[cl.playernum], &to->cmd,
|
||||
cl.spectator);
|
||||
cl.onground = onground;
|
||||
if (to->senttime >= cl.time)
|
||||
|
@ -194,21 +192,13 @@ CL_PredictMove (void)
|
|||
// now interpolate some fraction of the final frame
|
||||
if (to->senttime == from->senttime)
|
||||
f = 0;
|
||||
else {
|
||||
f = (cl.time - from->senttime) / (to->senttime - from->senttime);
|
||||
|
||||
if (f < 0)
|
||||
f = 0;
|
||||
if (f > 1)
|
||||
f = 1;
|
||||
}
|
||||
else
|
||||
f = bound(0, (cl.time - from->senttime) / (to->senttime - from->senttime), 1);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
if (fabs
|
||||
(from->playerstate[cl.playernum].origin[i] -
|
||||
to->playerstate[cl.playernum].origin[i]) > 128) { // teleported,
|
||||
// so don't
|
||||
// lerp
|
||||
if (fabs(from->playerstate[cl.playernum].origin[i] -
|
||||
to->playerstate[cl.playernum].origin[i]) > 128) {
|
||||
// teleported, so don't lerp
|
||||
VectorCopy (to->playerstate[cl.playernum].velocity, cl.simvel);
|
||||
VectorCopy (to->playerstate[cl.playernum].origin, cl.simorg);
|
||||
return;
|
||||
|
|
|
@ -285,7 +285,7 @@ PM_GroundMove (void)
|
|||
float downdist, updist;
|
||||
|
||||
pmove.velocity[2] = 0;
|
||||
if (!pmove.velocity[0] && !pmove.velocity[1] && !pmove.velocity[2])
|
||||
if (VectorIsNull(pmove.velocity))
|
||||
return;
|
||||
|
||||
// first try just moving to the destination
|
||||
|
|
|
@ -442,8 +442,7 @@ PR_ExecuteProgram (progs_t *pr, func_t fnum)
|
|||
OPC->_float = !OPA->_float;
|
||||
break;
|
||||
case OP_NOT_V:
|
||||
OPC->_float = !OPA->vector[0] && !OPA->vector[1]
|
||||
&& !OPA->vector[2];
|
||||
OPC->_float = VectorIsNull(OPA->vector);
|
||||
break;
|
||||
case OP_NOT_S:
|
||||
OPC->_float = !OPA->string || !*PR_GetString (pr, OPA->string);
|
||||
|
|
|
@ -537,8 +537,7 @@ SV_PushMove (edict_t *pusher, float movetime)
|
|||
int i;
|
||||
vec3_t move;
|
||||
|
||||
if (!pusher->v.v.velocity[0] && !pusher->v.v.velocity[1]
|
||||
&& !pusher->v.v.velocity[2]) {
|
||||
if (VectorIsNull(pusher->v.v.velocity)) {
|
||||
pusher->v.v.ltime += movetime;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -477,6 +477,7 @@ SV_ClipToLinks (areanode_t *node, moveclip_t * clip)
|
|||
|| clip->boxmaxs[2] < touch->v.v.absmin[2])
|
||||
continue;
|
||||
|
||||
// LordHavoc: err... FIXME?? I decided not to touch this weird code...
|
||||
if (clip->passedict != 0 && clip->passedict->v.v.size[0]
|
||||
&& !touch->v.v.size[0]) continue; // points never interact
|
||||
|
||||
|
|
Loading…
Reference in a new issue