Unify all sv_* code with dquake

This commit is contained in:
cypress 2024-09-04 19:06:33 -07:00
parent 5686e4f13e
commit cd1fed05c8
6 changed files with 615 additions and 509 deletions

View file

@ -510,7 +510,7 @@ void CL_SendMove (usercmd_t *cmd)
int bits;
sizebuf_t buf;
byte data[128];
vec3_t tempv;
buf.maxsize = 128;
buf.cursize = 0;
buf.data = data;
@ -559,9 +559,10 @@ void CL_SendMove (usercmd_t *cmd)
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
VectorAdd(cl.gun_kick, cl.viewangles, tempv);
for (i=0 ; i<3 ; i++)
MSG_WriteAngle (&buf, cl.viewangles[i]);
MSG_WriteFloat (&buf, tempv[i]);
MSG_WriteShort (&buf, cmd->forwardmove);
MSG_WriteShort (&buf, cmd->sidemove);
MSG_WriteShort (&buf, cmd->upmove);
@ -608,13 +609,6 @@ void CL_SendMove (usercmd_t *cmd)
MSG_WriteByte (&buf, in_impulse);
in_impulse = 0;
#ifdef QUAKE2
//
// light level
//
MSG_WriteByte (&buf, cmd->lightlevel);
#endif
//
// deliver the message
//
@ -627,7 +621,7 @@ void CL_SendMove (usercmd_t *cmd)
//
if (++cl.movemessages <= 2)
return;
if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1)
{
Con_Printf ("CL_SendMove: lost server connection\n");

View file

@ -638,3 +638,127 @@ fixed16_t Invert24To16(fixed16_t val)
}
#endif
/*
========================================================================
Matrix4x4 operations
========================================================================
*/
void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] )
{
out[0] = v[0] * in[0][0] + v[1] * in[0][1] + v[2] * in[0][2] + in[0][3];
out[1] = v[0] * in[1][0] + v[1] * in[1][1] + v[2] * in[1][2] + in[1][3];
out[2] = v[0] * in[2][0] + v[1] * in[2][1] + v[2] * in[2][2] + in[2][3];
}
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] )
{
vec3_t dir;
dir[0] = v[0] - in[0][3];
dir[1] = v[1] - in[1][3];
dir[2] = v[2] - in[2][3];
out[0] = dir[0] * in[0][0] + dir[1] * in[1][0] + dir[2] * in[2][0];
out[1] = dir[0] * in[0][1] + dir[1] * in[1][1] + dir[2] * in[2][1];
out[2] = dir[0] * in[0][2] + dir[1] * in[1][2] + dir[2] * in[2][2];
}
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale )
{
float angle, sr, sp, sy, cr, cp, cy;
if( angles[ROLL] )
{
angle = angles[YAW] * (M_PI*2 / 360);
sincos( angle, &sy, &cy );
angle = angles[PITCH] * (M_PI*2 / 360);
sincos( angle, &sp, &cp );
angle = angles[ROLL] * (M_PI*2 / 360);
sincos( angle, &sr, &cr );
out[0][0] = (cp*cy) * scale;
out[0][1] = (sr*sp*cy+cr*-sy) * scale;
out[0][2] = (cr*sp*cy+-sr*-sy) * scale;
out[0][3] = origin[0];
out[1][0] = (cp*sy) * scale;
out[1][1] = (sr*sp*sy+cr*cy) * scale;
out[1][2] = (cr*sp*sy+-sr*cy) * scale;
out[1][3] = origin[1];
out[2][0] = (-sp) * scale;
out[2][1] = (sr*cp) * scale;
out[2][2] = (cr*cp) * scale;
out[2][3] = origin[2];
out[3][0] = 0;
out[3][1] = 0;
out[3][2] = 0;
out[3][3] = 1;
}
else if( angles[PITCH] )
{
angle = angles[YAW] * (M_PI*2 / 360);
sincos( angle, &sy, &cy );
angle = angles[PITCH] * (M_PI*2 / 360);
sincos( angle, &sp, &cp );
out[0][0] = (cp*cy) * scale;
out[0][1] = (-sy) * scale;
out[0][2] = (sp*cy) * scale;
out[0][3] = origin[0];
out[1][0] = (cp*sy) * scale;
out[1][1] = (cy) * scale;
out[1][2] = (sp*sy) * scale;
out[1][3] = origin[1];
out[2][0] = (-sp) * scale;
out[2][1] = 0;
out[2][2] = (cp) * scale;
out[2][3] = origin[2];
out[3][0] = 0;
out[3][1] = 0;
out[3][2] = 0;
out[3][3] = 1;
}
else if( angles[YAW] )
{
angle = angles[YAW] * (M_PI*2 / 360);
sincos( angle, &sy, &cy );
out[0][0] = (cy) * scale;
out[0][1] = (-sy) * scale;
out[0][2] = 0;
out[0][3] = origin[0];
out[1][0] = (sy) * scale;
out[1][1] = (cy) * scale;
out[1][2] = 0;
out[1][3] = origin[1];
out[2][0] = 0;
out[2][1] = 0;
out[2][2] = scale;
out[2][3] = origin[2];
out[3][0] = 0;
out[3][1] = 0;
out[3][2] = 0;
out[3][3] = 1;
}
else
{
out[0][0] = scale;
out[0][1] = 0;
out[0][2] = 0;
out[0][3] = origin[0];
out[1][0] = 0;
out[1][1] = scale;
out[1][2] = 0;
out[1][3] = origin[1];
out[2][0] = 0;
out[2][1] = 0;
out[2][2] = scale;
out[2][3] = origin[2];
out[3][0] = 0;
out[3][1] = 0;
out[3][2] = 0;
out[3][3] = 1;
}
}

View file

@ -23,6 +23,7 @@ typedef float vec_t;
typedef vec_t vec3_t[3];
typedef vec_t vec5_t[5];
typedef vec_t vec2_t[2];
typedef vec_t matrix4x4[4][4];
typedef int fixed4_t;
typedef int fixed8_t;
@ -97,6 +98,10 @@ void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
float anglemod(float a);
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale );
void Matrix4x4_VectorTransform( const matrix4x4 in, const float v[3], float out[3] );
void Matrix4x4_VectorITransform( const matrix4x4 in, const float v[3], float out[3] );
extern int _mathlib_temp_int1, _mathlib_temp_int2, _mathlib_temp_int3;
extern float _mathlib_temp_float1, _mathlib_temp_float2, _mathlib_temp_float3;
extern vec3_t _mathlib_temp_vec1, _mathlib_temp_vec2, _mathlib_temp_vec3;

View file

@ -8,7 +8,7 @@ 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@ -40,7 +40,7 @@ qboolean SV_CheckBottom (edict_t *ent)
trace_t trace;
int x, y;
float mid, bottom;
VectorAdd (ent->v.origin, ent->v.mins, mins);
VectorAdd (ent->v.origin, ent->v.maxs, maxs);
@ -66,7 +66,7 @@ realcheck:
// check it for real...
//
start[2] = mins[2];
// the midpoint must be within 16 of the bottom
start[0] = stop[0] = (mins[0] + maxs[0])*0.5;
start[1] = stop[1] = (mins[1] + maxs[1])*0.5;
@ -76,16 +76,16 @@ realcheck:
if (trace.fraction == 1.0)
return false;
mid = bottom = trace.endpos[2];
// the corners must be within 16 of the midpoint
// the corners must be within 16 of the midpoint
for (x=0 ; x<=1 ; x++)
for (y=0 ; y<=1 ; y++)
{
start[0] = stop[0] = x ? maxs[0] : mins[0];
start[1] = stop[1] = y ? maxs[1] : mins[1];
trace = SV_Move (start, vec3_origin, vec3_origin, stop, true, ent);
if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
bottom = trace.endpos[2];
if (trace.fraction == 1.0 || mid - trace.endpos[2] > STEPSIZE)
@ -107,7 +107,8 @@ possible, no move is done, false is returned, and
pr_global_struct->trace_normal is set to the normal of the blocking wall
=============
*/
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)//Blubs edited this to make zombies walk through zombies
{
float dz;
vec3_t oldorg, neworg, end;
@ -115,7 +116,7 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
int i;
edict_t *enemy;
// try the move
// try the move
VectorCopy (ent->v.origin, oldorg);
VectorAdd (ent->v.origin, move, neworg);
@ -135,23 +136,22 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
if (dz < 30)
neworg[2] += 8;
}
trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, neworg, MOVE_NOMONSTERS, ent); //sB fixing zombies, was FALSE thanks blubs
trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, neworg,MOVE_NOMONSTERS, ent);//blubs edit, was 'false'
if (trace.fraction == 1)
{
if ( ((int)ent->v.flags & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY )
return false; // swim monster left water
VectorCopy (trace.endpos, ent->v.origin);
if (relink)
SV_LinkEdict (ent, true);
return true;
}
if (enemy == sv.edicts)
break;
}
return false;
}
@ -160,17 +160,21 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
VectorCopy (neworg, end);
end[2] -= STEPSIZE*2;
trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end, MOVE_NOMONSTERS, ent); //sB see above
trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end,MOVE_NOMONSTERS , ent);//blubsmove, 'false'
if (trace.allsolid)
{
return false;
}
if (trace.startsolid)
{
neworg[2] -= STEPSIZE;
trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end, MOVE_NOMONSTERS, ent); //sB
trace = SV_Move (neworg, ent->v.mins, ent->v.maxs, end,MOVE_NOMONSTERS , ent);//blubs edit, 'false'
if (trace.allsolid || trace.startsolid)
{
return false;
}
}
if (trace.fraction == 1)
{
@ -181,16 +185,14 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
if (relink)
SV_LinkEdict (ent, true);
ent->v.flags = (int)ent->v.flags & ~FL_ONGROUND;
// Con_Printf ("fall down\n");
return true;
}
return false; // walked off an edge
}
// check point traces down for dangling corners
VectorCopy (trace.endpos, ent->v.origin);
if (!SV_CheckBottom (ent))
{
if ( (int)ent->v.flags & FL_PARTIALGROUND )
@ -206,7 +208,7 @@ qboolean SV_movestep (edict_t *ent, vec3_t move, qboolean relink)
if ( (int)ent->v.flags & FL_PARTIALGROUND )
{
// Con_Printf ("back on ground\n");
// Con_Printf ("back on ground\n");
ent->v.flags = (int)ent->v.flags & ~FL_PARTIALGROUND;
}
ent->v.groundentity = EDICT_TO_PROG(trace.ent);
@ -234,13 +236,13 @@ qboolean SV_StepDirection (edict_t *ent, float yaw, float dist)
{
vec3_t move, oldorigin;
float delta;
ent->v.ideal_yaw = yaw;
PF_changeyaw();
yaw = yaw*M_PI*2 / 360;
move[0] = cos(yaw)*dist;
move[1] = sin(yaw)*dist;
move[0] = cosf(yaw)*dist;
move[1] = sinf(yaw)*dist;
move[2] = 0;
VectorCopy (ent->v.origin, oldorigin);
@ -255,7 +257,7 @@ qboolean SV_StepDirection (edict_t *ent, float yaw, float dist)
return true;
}
SV_LinkEdict (ent, true);
return false;
}
@ -268,7 +270,7 @@ SV_FixCheckBottom
void SV_FixCheckBottom (edict_t *ent)
{
// Con_Printf ("SV_FixCheckBottom\n");
ent->v.flags = (int)ent->v.flags | FL_PARTIALGROUND;
}
@ -312,7 +314,7 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
tdir = d[2] == 90 ? 45 : 315;
else
tdir = d[2] == 90 ? 135 : 215;
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
return;
}
@ -325,7 +327,95 @@ void SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
d[2]=tdir;
}
if (d[1]!=DI_NODIR && d[1]!=turnaround
if (d[1]!=DI_NODIR && d[1]!=turnaround
&& SV_StepDirection(actor, d[1], dist))
return;
if (d[2]!=DI_NODIR && d[2]!=turnaround
&& SV_StepDirection(actor, d[2], dist))
return;
/* there is no direct path to the player, so pick another direction */
if (olddir!=DI_NODIR && SV_StepDirection(actor, olddir, dist))
return;
if (rand()&1) /*randomly determine direction of search*/
{
for (tdir=0 ; tdir<=315 ; tdir += 45)
if (tdir!=turnaround && SV_StepDirection(actor, tdir, dist) )
return;
}
else
{
for (tdir=315 ; tdir >=0 ; tdir -= 45)
if (tdir!=turnaround && SV_StepDirection(actor, tdir, dist) )
return;
}
if (turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist) )
return;
actor->v.ideal_yaw = olddir; // can't move
// if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all
if (!SV_CheckBottom (actor))
SV_FixCheckBottom (actor);
}
/*
================
SV_NewChaseDirO
================
*/
void SV_NewChaseDirO (edict_t *actor, vec3_t goal, float dist)
{
float deltax,deltay;
float d[3];
float tdir, olddir, turnaround;
olddir = anglemod( (int)(actor->v.ideal_yaw/45)*45 );
turnaround = anglemod(olddir - 180);
deltax = goal[0] - actor->v.origin[0];
deltay = goal[1] - actor->v.origin[1];
if (deltax>10)
d[1]= 0;
else if (deltax<-10)
d[1]= 180;
else
d[1]= DI_NODIR;
if (deltay<-10)
d[2]= 270;
else if (deltay>10)
d[2]= 90;
else
d[2]= DI_NODIR;
// try direct route
if (d[1] != DI_NODIR && d[2] != DI_NODIR)
{
if (d[1] == 0)
tdir = d[2] == 90 ? 45 : 315;
else
tdir = d[2] == 90 ? 135 : 215;
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
return;
}
// try other directions
if ( ((rand()&3) & 1) || abs(deltay)>abs(deltax))
{
tdir=d[1];
d[1]=d[2];
d[2]=tdir;
}
if (d[1]!=DI_NODIR && d[1]!=turnaround
&& SV_StepDirection(actor, d[1], dist))
return;
@ -373,7 +463,7 @@ SV_CloseEnough
qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
{
int i;
for (i=0 ; i<3 ; i++)
{
if (goal->v.absmin[i] > ent->v.absmax[i] + dist)
@ -384,6 +474,26 @@ qboolean SV_CloseEnough (edict_t *ent, edict_t *goal, float dist)
return true;
}
/*
======================
SV_CloseEnough
======================
*/
qboolean SV_CloseEnoughO (edict_t *ent, vec3_t goal, float dist)
{
int i;
for (i=0 ; i<3 ; i++)
{
if (goal[i] > ent->v.absmax[i] + dist)
return false;
if (goal[i] < ent->v.absmin[i] - dist)
return false;
}
return true;
}
/*
======================
SV_MoveToGoal
@ -392,15 +502,14 @@ SV_MoveToGoal
*/
void SV_MoveToGoal (void)
{
edict_t *ent, *goal;
edict_t *ent;
float dist;
#ifdef QUAKE2
edict_t *enemy;
#endif
float *goal;
ent = PROG_TO_EDICT(pr_global_struct->self);
goal = PROG_TO_EDICT(ent->v.goalentity);
dist = G_FLOAT(OFS_PARM0);
goal = G_VECTOR(OFS_PARM1);
if ( !( (int)ent->v.flags & (FL_ONGROUND|FL_FLY|FL_SWIM) ) )
{
@ -409,20 +518,13 @@ void SV_MoveToGoal (void)
}
// if the next step hits the enemy, return immediately
#ifdef QUAKE2
enemy = PROG_TO_EDICT(ent->v.enemy);
if (enemy != sv.edicts && SV_CloseEnough (ent, enemy, dist) )
#else
if ( PROG_TO_EDICT(ent->v.enemy) != sv.edicts && SV_CloseEnough (ent, goal, dist) )
#endif
if ( PROG_TO_EDICT(ent->v.enemy) != sv.edicts && SV_CloseEnoughO (ent, goal, dist) )
return;
// bump around...
if ( (rand()&3)==1 ||
!SV_StepDirection (ent, ent->v.ideal_yaw, dist))
{
SV_NewChaseDir (ent, goal, dist);
}
if ((rand()&3)==1 || !SV_StepDirection (ent, ent->v.ideal_yaw, dist))
SV_NewChaseDirO (ent, goal, dist);
}
/*
@ -455,3 +557,4 @@ void SV_MoveToOrigin (void)
SV_NewChaseDir (ent, goal, dist);
}

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ 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.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@ -58,34 +58,34 @@ void SV_SetIdealPitch (void)
float z[MAX_FORWARD];
int i, j;
int step, dir, steps;
if (!((int)sv_player->v.flags & FL_ONGROUND))
return;
angleval = sv_player->v.angles[YAW] * M_PI*2 / 360;
sinval = sin(angleval);
cosval = cos(angleval);
sinval = sinf(angleval);
cosval = cosf(angleval);
for (i=0 ; i<MAX_FORWARD ; i++)
{
top[0] = sv_player->v.origin[0] + cosval*(i+3)*12;
top[1] = sv_player->v.origin[1] + sinval*(i+3)*12;
top[2] = sv_player->v.origin[2] + sv_player->v.view_ofs[2];
bottom[0] = top[0];
bottom[1] = top[1];
bottom[2] = top[2] - 160;
tr = SV_Move (top, vec3_origin, vec3_origin, bottom, 1, sv_player);
if (tr.allsolid)
return; // looking at a wall, leave ideal the way is was
if (tr.fraction == 1)
return; // near a dropoff
z[i] = top[2] + tr.fraction*(bottom[2]-top[2]);
}
dir = 0;
steps = 0;
for (j=1 ; j<i ; j++)
@ -97,16 +97,16 @@ void SV_SetIdealPitch (void)
if (dir && ( step-dir > ON_EPSILON || step-dir < -ON_EPSILON ) )
return; // mixed changes
steps++;
steps++;
dir = step;
}
if (!dir)
{
sv_player->v.idealpitch = 0;
return;
}
if (steps < 2)
return;
sv_player->v.idealpitch = -dir * sv_idealpitchscale.value;
@ -126,10 +126,10 @@ void SV_UserFriction (void)
vec3_t start, stop;
float friction;
trace_t trace;
vel = velocity;
speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1]);
speed = sqrtf(vel[0]*vel[0] +vel[1]*vel[1]);
if (!speed)
return;
@ -146,10 +146,10 @@ void SV_UserFriction (void)
else
friction = sv_friction.value;
// apply friction
// apply friction
control = speed < sv_stopspeed.value ? sv_stopspeed.value : speed;
newspeed = speed - host_frametime*control*friction;
if (newspeed < 0)
newspeed = 0;
newspeed /= speed;
@ -182,9 +182,9 @@ void SV_Accelerate (vec3_t wishvel)
accelspeed = sv_accelerate.value*host_frametime*addspeed;
if (accelspeed > addspeed)
accelspeed = addspeed;
for (i=0 ; i<3 ; i++)
velocity[i] += accelspeed*pushvec[i];
velocity[i] += accelspeed*pushvec[i];
}
#endif
void SV_Accelerate (void)
@ -199,16 +199,16 @@ void SV_Accelerate (void)
accelspeed = sv_accelerate.value*host_frametime*wishspeed;
if (accelspeed > addspeed)
accelspeed = addspeed;
for (i=0 ; i<3 ; i++)
velocity[i] += accelspeed*wishdir[i];
velocity[i] += accelspeed*wishdir[i];
}
void SV_AirAccelerate (vec3_t wishveloc)
{
int i;
float addspeed, wishspd, accelspeed, currentspeed;
wishspd = VectorNormalize (wishveloc);
if (wishspd > 30)
wishspd = 30;
@ -220,19 +220,19 @@ void SV_AirAccelerate (vec3_t wishveloc)
accelspeed = sv_accelerate.value*wishspeed * host_frametime;
if (accelspeed > addspeed)
accelspeed = addspeed;
for (i=0 ; i<3 ; i++)
velocity[i] += accelspeed*wishveloc[i];
velocity[i] += accelspeed*wishveloc[i];
}
void DropPunchAngle (void)
{
float len;
len = VectorNormalize (sv_player->v.punchangle);
len -= 10*host_frametime;
len -= 20*host_frametime;
if (len < 0)
len = 0;
VectorScale (sv_player->v.punchangle, len, sv_player->v.punchangle);
@ -279,12 +279,12 @@ void SV_WaterMove (void)
{
newspeed = speed - host_frametime * speed * sv_friction.value;
if (newspeed < 0)
newspeed = 0;
newspeed = 0;
VectorScale (velocity, newspeed/speed, velocity);
}
else
newspeed = 0;
//
// water acceleration
//
@ -333,11 +333,11 @@ void SV_AirMove (void)
fmove = cmd.forwardmove;
smove = cmd.sidemove;
// hack to not let you back into teleporter
if (sv.time < sv_player->v.teleport_time && fmove < 0)
fmove = 0;
for (i=0 ; i<3 ; i++)
wishvel[i] = forward[i]*fmove + right[i]*smove;
@ -353,12 +353,12 @@ void SV_AirMove (void)
VectorScale (wishvel, sv_maxspeed.value/wishspeed, wishvel);
wishspeed = sv_maxspeed.value;
}
if ( sv_player->v.movetype == MOVETYPE_NOCLIP)
{ // noclip
VectorCopy (wishvel, velocity);
}
else if ( (int)sv_player->v.flags & FL_ONGROUND )
else if ( onground )
{
SV_UserFriction ();
SV_Accelerate ();
@ -366,7 +366,7 @@ void SV_AirMove (void)
else
{ // not on ground, so little effect on velocity
SV_AirAccelerate (wishvel);
}
}
}
/*
@ -383,14 +383,17 @@ void SV_ClientThink (void)
if (sv_player->v.movetype == MOVETYPE_NONE)
return;
onground = (int)sv_player->v.flags & FL_ONGROUND;
if ((int)sv_player->v.flags & FL_ONGROUND)
onground = qtrue;
else
onground = qfalse;
origin = sv_player->v.origin;
velocity = sv_player->v.velocity;
DropPunchAngle ();
//
// if dead, behave differently
//
@ -402,7 +405,7 @@ void SV_ClientThink (void)
// show 1/3 the pitch angle and all the roll angle
cmd = host_client->cmd;
angles = sv_player->v.angles;
VectorAdd (sv_player->v.v_angle, sv_player->v.punchangle, v_angle);
angles[ROLL] = V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;
if (!sv_player->v.fixangle)
@ -426,7 +429,7 @@ void SV_ClientThink (void)
return;
}
SV_AirMove ();
SV_AirMove ();
}
@ -440,23 +443,23 @@ void SV_ReadClientMove (usercmd_t *move)
int i;
vec3_t angle;
int bits;
// read ping time
host_client->ping_times[host_client->num_pings%NUM_PING_TIMES]
= sv.time - MSG_ReadFloat ();
host_client->num_pings++;
// read current angles
// read current angles
for (i=0 ; i<3 ; i++)
angle[i] = MSG_ReadAngle ();
angle[i] = MSG_ReadFloat ();
VectorCopy (angle, host_client->edict->v.v_angle);
// read movement
move->forwardmove = MSG_ReadShort ();
move->sidemove = MSG_ReadShort ();
move->upmove = MSG_ReadShort ();
// read buttons
bits = MSG_ReadLong ();
host_client->edict->v.button0 = bits & 1;
@ -472,11 +475,6 @@ void SV_ReadClientMove (usercmd_t *move)
i = MSG_ReadByte ();
if (i)
host_client->edict->v.impulse = i;
#ifdef QUAKE2
// read light level
host_client->edict->v.light_level = MSG_ReadByte ();
#endif
}
/*
@ -491,7 +489,7 @@ qboolean SV_ReadClientMessage (void)
int ret;
int cmd;
char *s;
do
{
nextmsg:
@ -503,9 +501,9 @@ nextmsg:
}
if (!ret)
return true;
MSG_BeginReading ();
while (1)
{
if (!host_client->active)
@ -515,24 +513,24 @@ nextmsg:
{
Sys_Printf ("SV_ReadClientMessage: badread\n");
return false;
}
}
cmd = MSG_ReadChar ();
switch (cmd)
{
case -1:
goto nextmsg; // end of message
default:
Sys_Printf ("SV_ReadClientMessage: unknown command char\n");
return false;
case clc_nop:
// Sys_Printf ("clc_nop\n");
break;
case clc_stringcmd:
case clc_stringcmd:
s = MSG_ReadString ();
if (host_client->privileged)
ret = 2;
@ -583,18 +581,18 @@ nextmsg:
else
Con_DPrintf("%s tried to %s\n", host_client->name, s);
break;
case clc_disconnect:
// Sys_Printf ("SV_ReadClientMessage: client disconnected\n");
return false;
case clc_move:
SV_ReadClientMove (&host_client->cmd);
break;
}
}
} while (ret == 1);
return true;
}
@ -607,12 +605,12 @@ SV_RunClients
void SV_RunClients (void)
{
int i;
for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
{
if (!host_client->active)
continue;
sv_player = host_client->edict;
if (!SV_ReadClientMessage ())