2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // sv_user.c -- server code for moving users
24 cvar_t sv_edgefriction = {0, "edgefriction", "2", "how much you slow down when nearing a ledge you might fall off"};
25 cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8", "how much to look up/down slopes and stairs when not using freelook"};
26 cvar_t sv_maxspeed = {CVAR_NOTIFY, "sv_maxspeed", "320", "maximum speed a player can accelerate to when on ground (can be exceeded by tricks)"};
27 cvar_t sv_maxairspeed = {0, "sv_maxairspeed", "30", "maximum speed a player can accelerate to when airborn (note that it is possible to completely stop by moving the opposite direction)"};
28 cvar_t sv_accelerate = {0, "sv_accelerate", "10", "rate at which a player accelerates to sv_maxspeed"};
39 void SV_SetIdealPitch (void)
41 float angleval, sinval, cosval;
48 if (!((int)host_client->edict->fields.server->flags & FL_ONGROUND))
51 angleval = host_client->edict->fields.server->angles[YAW] * M_PI*2 / 360;
52 sinval = sin(angleval);
53 cosval = cos(angleval);
55 for (i=0 ; i<MAX_FORWARD ; i++)
57 top[0] = host_client->edict->fields.server->origin[0] + cosval*(i+3)*12;
58 top[1] = host_client->edict->fields.server->origin[1] + sinval*(i+3)*12;
59 top[2] = host_client->edict->fields.server->origin[2] + host_client->edict->fields.server->view_ofs[2];
63 bottom[2] = top[2] - 160;
65 tr = SV_Move (top, vec3_origin, vec3_origin, bottom, MOVE_NOMONSTERS, host_client->edict);
66 // if looking at a wall, leave ideal the way is was
74 z[i] = top[2] + tr.fraction*(bottom[2]-top[2]);
82 if (step > -ON_EPSILON && step < ON_EPSILON)
86 if (dir && ( step-dir > ON_EPSILON || step-dir < -ON_EPSILON ) )
95 host_client->edict->fields.server->idealpitch = 0;
101 host_client->edict->fields.server->idealpitch = -dir * sv_idealpitchscale.value;
105 static vec3_t wishdir, forward, right, up;
106 static float wishspeed;
108 static qboolean onground;
116 void SV_UserFriction (void)
118 float speed, newspeed, control, friction;
122 speed = sqrt(host_client->edict->fields.server->velocity[0]*host_client->edict->fields.server->velocity[0]+host_client->edict->fields.server->velocity[1]*host_client->edict->fields.server->velocity[1]);
126 // if the leading edge is over a dropoff, increase friction
127 start[0] = stop[0] = host_client->edict->fields.server->origin[0] + host_client->edict->fields.server->velocity[0]/speed*16;
128 start[1] = stop[1] = host_client->edict->fields.server->origin[1] + host_client->edict->fields.server->velocity[1]/speed*16;
129 start[2] = host_client->edict->fields.server->origin[2] + host_client->edict->fields.server->mins[2];
130 stop[2] = start[2] - 34;
132 trace = SV_Move (start, vec3_origin, vec3_origin, stop, MOVE_NOMONSTERS, host_client->edict);
134 if (trace.fraction == 1.0)
135 friction = sv_friction.value*sv_edgefriction.value;
137 friction = sv_friction.value;
140 control = speed < sv_stopspeed.value ? sv_stopspeed.value : speed;
141 newspeed = speed - sv.frametime*control*friction;
148 VectorScale(host_client->edict->fields.server->velocity, newspeed, host_client->edict->fields.server->velocity);
156 void SV_Accelerate (void)
159 float addspeed, accelspeed, currentspeed;
161 currentspeed = DotProduct (host_client->edict->fields.server->velocity, wishdir);
162 addspeed = wishspeed - currentspeed;
165 accelspeed = sv_accelerate.value*sv.frametime*wishspeed;
166 if (accelspeed > addspeed)
167 accelspeed = addspeed;
169 for (i=0 ; i<3 ; i++)
170 host_client->edict->fields.server->velocity[i] += accelspeed*wishdir[i];
173 void SV_AirAccelerate (vec3_t wishveloc)
176 float addspeed, wishspd, accelspeed, currentspeed;
178 wishspd = VectorNormalizeLength (wishveloc);
179 if (wishspd > sv_maxairspeed.value)
180 wishspd = sv_maxairspeed.value;
181 currentspeed = DotProduct (host_client->edict->fields.server->velocity, wishveloc);
182 addspeed = wishspd - currentspeed;
185 accelspeed = sv_accelerate.value*wishspeed * sv.frametime;
186 if (accelspeed > addspeed)
187 accelspeed = addspeed;
189 for (i=0 ; i<3 ; i++)
190 host_client->edict->fields.server->velocity[i] += accelspeed*wishveloc[i];
194 void DropPunchAngle (void)
199 len = VectorNormalizeLength (host_client->edict->fields.server->punchangle);
201 len -= 10*sv.frametime;
204 VectorScale (host_client->edict->fields.server->punchangle, len, host_client->edict->fields.server->punchangle);
206 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_punchvector)))
208 len = VectorNormalizeLength (val->vector);
210 len -= 20*sv.frametime;
213 VectorScale (val->vector, len, val->vector);
222 void SV_FreeMove (void)
227 AngleVectors (host_client->edict->fields.server->v_angle, forward, right, up);
229 for (i = 0; i < 3; i++)
230 host_client->edict->fields.server->velocity[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove;
232 host_client->edict->fields.server->velocity[2] += cmd.upmove;
234 wishspeed = VectorLength(host_client->edict->fields.server->velocity);
235 if (wishspeed > sv_maxspeed.value)
236 VectorScale(host_client->edict->fields.server->velocity, sv_maxspeed.value / wishspeed, host_client->edict->fields.server->velocity);
245 void SV_WaterMove (void)
249 float speed, newspeed, wishspeed, addspeed, accelspeed, temp;
252 AngleVectors (host_client->edict->fields.server->v_angle, forward, right, up);
254 for (i=0 ; i<3 ; i++)
255 wishvel[i] = forward[i]*cmd.forwardmove + right[i]*cmd.sidemove;
257 if (!cmd.forwardmove && !cmd.sidemove && !cmd.upmove)
258 wishvel[2] -= 60; // drift towards bottom
260 wishvel[2] += cmd.upmove;
262 wishspeed = VectorLength(wishvel);
263 if (wishspeed > sv_maxspeed.value)
265 temp = sv_maxspeed.value/wishspeed;
266 VectorScale (wishvel, temp, wishvel);
267 wishspeed = sv_maxspeed.value;
272 speed = VectorLength(host_client->edict->fields.server->velocity);
275 newspeed = speed - sv.frametime * speed * sv_friction.value;
278 temp = newspeed/speed;
279 VectorScale(host_client->edict->fields.server->velocity, temp, host_client->edict->fields.server->velocity);
284 // water acceleration
288 addspeed = wishspeed - newspeed;
292 VectorNormalize (wishvel);
293 accelspeed = sv_accelerate.value * wishspeed * sv.frametime;
294 if (accelspeed > addspeed)
295 accelspeed = addspeed;
297 for (i=0 ; i<3 ; i++)
298 host_client->edict->fields.server->velocity[i] += accelspeed * wishvel[i];
301 void SV_WaterJump (void)
303 if (sv.time > host_client->edict->fields.server->teleport_time || !host_client->edict->fields.server->waterlevel)
305 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags & ~FL_WATERJUMP;
306 host_client->edict->fields.server->teleport_time = 0;
308 host_client->edict->fields.server->velocity[0] = host_client->edict->fields.server->movedir[0];
309 host_client->edict->fields.server->velocity[1] = host_client->edict->fields.server->movedir[1];
319 void SV_AirMove (void)
323 float fmove, smove, temp;
325 // LordHavoc: correct quake movement speed bug when looking up/down
326 wishvel[0] = wishvel[2] = 0;
327 wishvel[1] = host_client->edict->fields.server->angles[1];
328 AngleVectors (wishvel, forward, right, up);
330 fmove = cmd.forwardmove;
331 smove = cmd.sidemove;
333 // hack to not let you back into teleporter
334 if (sv.time < host_client->edict->fields.server->teleport_time && fmove < 0)
337 for (i=0 ; i<3 ; i++)
338 wishvel[i] = forward[i]*fmove + right[i]*smove;
340 if ((int)host_client->edict->fields.server->movetype != MOVETYPE_WALK)
341 wishvel[2] += cmd.upmove;
343 VectorCopy (wishvel, wishdir);
344 wishspeed = VectorNormalizeLength(wishdir);
345 if (wishspeed > sv_maxspeed.value)
347 temp = sv_maxspeed.value/wishspeed;
348 VectorScale (wishvel, temp, wishvel);
349 wishspeed = sv_maxspeed.value;
352 if (host_client->edict->fields.server->movetype == MOVETYPE_NOCLIP)
355 VectorCopy (wishvel, host_client->edict->fields.server->velocity);
364 // not on ground, so little effect on velocity
365 SV_AirAccelerate (wishvel);
373 the move fields specify an intended velocity in pix/sec
374 the angle fields specify an exact angular motion in degrees
377 void SV_ClientThink (void)
381 if (host_client->edict->fields.server->movetype == MOVETYPE_NONE)
384 onground = (int)host_client->edict->fields.server->flags & FL_ONGROUND;
388 // if dead, behave differently
389 if (host_client->edict->fields.server->health <= 0)
392 cmd = host_client->cmd;
395 // show 1/3 the pitch angle and all the roll angle
396 VectorAdd (host_client->edict->fields.server->v_angle, host_client->edict->fields.server->punchangle, v_angle);
397 host_client->edict->fields.server->angles[ROLL] = V_CalcRoll (host_client->edict->fields.server->angles, host_client->edict->fields.server->velocity)*4;
398 if (!host_client->edict->fields.server->fixangle)
400 host_client->edict->fields.server->angles[PITCH] = -v_angle[PITCH]/3;
401 host_client->edict->fields.server->angles[YAW] = v_angle[YAW];
404 if ( (int)host_client->edict->fields.server->flags & FL_WATERJUMP )
411 // Player is (somehow) outside of the map, or flying, or noclipping
412 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP && (host_client->edict->fields.server->movetype == MOVETYPE_FLY || SV_TestEntityPosition (host_client->edict)))
413 //if (host_client->edict->fields.server->movetype == MOVETYPE_NOCLIP || host_client->edict->fields.server->movetype == MOVETYPE_FLY || SV_TestEntityPosition (host_client->edict))
421 if ((host_client->edict->fields.server->waterlevel >= 2) && (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP))
432 extern cvar_t cl_rollspeed;
433 extern cvar_t cl_rollangle;
434 void SV_ClientThink(void)
437 vec3_t wishvel, wishdir, v, v_forward, v_right, v_up, start, stop;
438 float wishspeed, f, limit;
441 if (host_client->edict->fields.server->movetype == MOVETYPE_NONE)
444 f = DotProduct(host_client->edict->fields.server->punchangle, host_client->edict->fields.server->punchangle);
448 f = (limit - 10 * sv.frametime);
451 VectorScale(host_client->edict->fields.server->punchangle, f, host_client->edict->fields.server->punchangle);
454 // if dead, behave differently
455 if (host_client->edict->fields.server->health <= 0)
458 AngleVectors(host_client->edict->fields.server->v_angle, v_forward, v_right, v_up);
459 // show 1/3 the pitch angle and all the roll angle
460 f = DotProduct(host_client->edict->fields.server->velocity, v_right) * (1.0 / cl_rollspeed.value);
461 host_client->edict->fields.server->angles[2] = bound(-1, f, 1) * cl_rollangle.value * 4;
462 if (!host_client->edict->fields.server->fixangle)
464 host_client->edict->fields.server->angles[0] = (host_client->edict->fields.server->v_angle[0] + host_client->edict->fields.server->punchangle[0]) * -0.333;
465 host_client->edict->fields.server->angles[1] = host_client->edict->fields.server->v_angle[1] + host_client->edict->fields.server->punchangle[1];
468 if ((int)host_client->edict->fields.server->flags & FL_WATERJUMP)
470 host_client->edict->fields.server->velocity[0] = host_client->edict->fields.server->movedir[0];
471 host_client->edict->fields.server->velocity[1] = host_client->edict->fields.server->movedir[1];
472 if (sv.time > host_client->edict->fields.server->teleport_time || host_client->edict->fields.server->waterlevel == 0)
474 host_client->edict->fields.server->flags = (int)host_client->edict->fields.server->flags - ((int)host_client->edict->fields.server->flags & FL_WATERJUMP);
475 host_client->edict->fields.server->teleport_time = 0;
481 if (host_client->edict->fields.server->waterlevel >= 2)
482 if (host_client->edict->fields.server->movetype != MOVETYPE_NOCLIP)
484 if (host_client->cmd.forwardmove == 0 && host_client->cmd.sidemove == 0 && host_client->cmd.upmove == 0)
486 // drift towards bottom
493 for (j = 0;j < 3;j++)
494 wishvel[j] = v_forward[j] * host_client->cmd.forwardmove + v_right[j] * host_client->cmd.sidemove;
495 wishvel[2] += host_client->cmd.upmove;
498 wishspeed = VectorLength(wishvel);
499 wishspeed = min(wishspeed, sv_maxspeed.value) * 0.7;
502 f = VectorLength(host_client->edict->fields.server->velocity) * (1 - sv.frametime * sv_friction.value);
504 f /= VectorLength(host_client->edict->fields.server->velocity);
507 VectorScale(host_client->edict->fields.server->velocity, f, host_client->edict->fields.server->velocity);
509 // water acceleration
514 limit = sv_accelerate.value * wishspeed * sv.frametime;
517 limit = VectorLength(wishvel);
520 VectorMA(host_client->edict->fields.server->velocity, f, wishvel, host_client->edict->fields.server->velocity);
524 // if not flying, move horizontally only
525 if (host_client->edict->fields.server->movetype != MOVETYPE_FLY)
527 VectorClear(wishvel);
528 wishvel[1] = host_client->edict->fields.server->v_angle[1];
529 AngleVectors(wishvel, v_forward, v_right, v_up);
532 // hack to not let you back into teleporter
533 VectorScale(v_right, host_client->cmd.sidemove, wishvel);
534 if (sv.time >= host_client->edict->fields.server->teleport_time || host_client->cmd.forwardmove > 0)
535 VectorMA(wishvel, host_client->cmd.forwardmove, v_forward, wishvel);
536 if (host_client->edict->fields.server->movetype != MOVETYPE_WALK)
537 wishvel[2] += cmd.upmove;
539 VectorCopy(wishvel, wishdir);
540 VectorNormalize(wishdir);
541 wishspeed = VectorLength(wishvel);
542 if (wishspeed > sv_maxspeed.value)
543 wishspeed = sv_maxspeed.value;
545 if (host_client->edict->fields.server->movetype == MOVETYPE_NOCLIP || host_client->edict->fields.server->movetype == MOVETYPE_FLY)
547 VectorScale(wishdir, wishspeed, host_client->edict->fields.server->velocity);
551 if ((int)host_client->edict->fields.server->flags & FL_ONGROUND) // walking
554 f = host_client->edict->fields.server->velocity[0] * host_client->edict->fields.server->velocity[0] + host_client->edict->fields.server->velocity[1] * host_client->edict->fields.server->velocity[1];
558 VectorCopy(host_client->edict->fields.server->velocity, v);
561 // if the leading edge is over a dropoff, increase friction
563 VectorMA(host_client->edict->fields.server->origin, limit, v, v);
564 v[2] += host_client->edict->fields.server->mins[2];
566 VectorCopy(v, start);
569 trace = SV_Move(start, vec3_origin, vec3_origin, stop, MOVE_NOMONSTERS, host_client->edict);
572 if (f < sv_stopspeed.value)
573 f = sv_stopspeed.value / f;
576 if (trace.fraction == 1)
577 f *= sv_edgefriction.value;
578 f = 1 - sv.frametime * f * sv_friction.value;
582 VectorScale(host_client->edict->fields.server->velocity, f, host_client->edict->fields.server->velocity);
586 wishspeed = min(wishspeed, 30);
588 // ground or air acceleration
589 f = wishspeed - DotProduct(host_client->edict->fields.server->velocity, wishdir);
592 limit = sv_accelerate.value * sv.frametime * wishspeed;
595 VectorMA(host_client->edict->fields.server->velocity, f, wishdir, host_client->edict->fields.server->velocity);
605 qboolean SV_ReadClientMove (void)
607 qboolean kickplayer = false;
610 usercmd_t *move = &host_client->cmd;
612 oldmovetime = move->time;
614 // if this move has been applied, clear it, and start accumulating new data
616 memset(move, 0, sizeof(*move));
618 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
621 if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5 && sv.protocol != PROTOCOL_DARKPLACES6)
622 move->sequence = MSG_ReadLong ();
623 move->time = MSG_ReadFloat ();
624 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
625 move->receivetime = sv.time;
627 // read current angles
628 for (i = 0;i < 3;i++)
630 if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE)
631 move->viewangles[i] = MSG_ReadAngle8i();
632 else if (sv.protocol == PROTOCOL_DARKPLACES1)
633 move->viewangles[i] = MSG_ReadAngle16i();
634 else if (sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3)
635 move->viewangles[i] = MSG_ReadAngle32f();
637 move->viewangles[i] = MSG_ReadAngle16i();
639 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
642 move->forwardmove = MSG_ReadCoord16i ();
643 move->sidemove = MSG_ReadCoord16i ();
644 move->upmove = MSG_ReadCoord16i ();
645 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
648 // be sure to bitwise OR them into the move->buttons because we want to
649 // accumulate button presses from multiple packets per actual move
650 if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
651 move->buttons |= MSG_ReadByte ();
653 move->buttons |= MSG_ReadLong ();
654 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
660 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
662 // PRYDON_CLIENTCURSOR
663 if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5)
666 move->cursor_screen[0] = MSG_ReadShort() * (1.0f / 32767.0f);
667 move->cursor_screen[1] = MSG_ReadShort() * (1.0f / 32767.0f);
668 move->cursor_start[0] = MSG_ReadFloat();
669 move->cursor_start[1] = MSG_ReadFloat();
670 move->cursor_start[2] = MSG_ReadFloat();
671 move->cursor_impact[0] = MSG_ReadFloat();
672 move->cursor_impact[1] = MSG_ReadFloat();
673 move->cursor_impact[2] = MSG_ReadFloat();
674 move->cursor_entitynumber = (unsigned short)MSG_ReadShort();
675 if (move->cursor_entitynumber >= prog->max_edicts)
677 Con_DPrintf("SV_ReadClientMessage: client send bad cursor_entitynumber\n");
678 move->cursor_entitynumber = 0;
680 // as requested by FrikaC, cursor_trace_ent is reset to world if the
681 // entity is free at time of receipt
682 if (PRVM_EDICT_NUM(move->cursor_entitynumber)->priv.server->free)
683 move->cursor_entitynumber = 0;
684 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
687 if (!host_client->spawned)
688 memset(move, 0, sizeof(*move));
689 else if (move->time > (float)sv.time + 0.001f) // add a little fuzz factor due to float precision issues
691 Con_DPrintf("client move->time %f > sv.time %f, kicking\n", move->time, sv.time);
692 // if the client is lying about time, we have definitively detected a
693 // speed cheat attempt of the worst sort, and we can immediately kick
694 // the offending player off.
695 // this fixes the timestamp to prevent a speed cheat from working
696 move->time = sv.time;
697 // but we kick the player for good measure
702 // apply the latest accepted move to the entity fields
703 host_client->movesequence = move->sequence;
704 if (host_client->movesequence)
706 double frametime = bound(0, move->time - oldmovetime, 0.1);
707 double oldframetime = prog->globals.server->frametime;
708 //if (move->time - oldmovetime >= 0.1001)
709 // Con_DPrintf("client move exceeds 100ms! (time %f -> time %f)\n", oldmovetime, move->time);
710 prog->globals.server->frametime = frametime;
711 SV_Physics_ClientEntity(host_client->edict);
712 prog->globals.server->frametime = oldframetime;
718 void SV_ApplyClientMove (void)
720 #ifdef NUM_PING_TIMES
725 usercmd_t *move = &host_client->cmd;
727 if (!move->receivetime || move->applied)
730 move->applied = true;
732 // calculate average ping time
733 host_client->ping = move->receivetime - move->time;
734 #ifdef NUM_PING_TIMES
735 host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = move->receivetime - move->time;
736 host_client->num_pings++;
737 for (i=0, total = 0;i < NUM_PING_TIMES;i++)
738 total += host_client->ping_times[i];
739 host_client->ping = total / NUM_PING_TIMES;
742 // set the edict fields
743 host_client->edict->fields.server->button0 = move->buttons & 1;
744 host_client->edict->fields.server->button2 = (move->buttons & 2)>>1;
746 host_client->edict->fields.server->impulse = move->impulse;
747 VectorCopy(move->viewangles, host_client->edict->fields.server->v_angle);
748 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button3))) val->_float = ((move->buttons >> 2) & 1);
749 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button4))) val->_float = ((move->buttons >> 3) & 1);
750 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button5))) val->_float = ((move->buttons >> 4) & 1);
751 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button6))) val->_float = ((move->buttons >> 5) & 1);
752 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button7))) val->_float = ((move->buttons >> 6) & 1);
753 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button8))) val->_float = ((move->buttons >> 7) & 1);
754 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button9))) val->_float = ((move->buttons >> 11) & 1);
755 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button10))) val->_float = ((move->buttons >> 12) & 1);
756 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button11))) val->_float = ((move->buttons >> 13) & 1);
757 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button12))) val->_float = ((move->buttons >> 14) & 1);
758 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button13))) val->_float = ((move->buttons >> 15) & 1);
759 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button14))) val->_float = ((move->buttons >> 16) & 1);
760 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button15))) val->_float = ((move->buttons >> 17) & 1);
761 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button16))) val->_float = ((move->buttons >> 18) & 1);
762 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_buttonuse))) val->_float = ((move->buttons >> 8) & 1);
763 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_buttonchat))) val->_float = ((move->buttons >> 9) & 1);
764 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_active))) val->_float = ((move->buttons >> 10) & 1);
765 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_movement))) VectorSet(val->vector, move->forwardmove, move->sidemove, move->upmove);
766 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_screen))) VectorCopy(move->cursor_screen, val->vector);
767 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_start))) VectorCopy(move->cursor_start, val->vector);
768 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_endpos))) VectorCopy(move->cursor_impact, val->vector);
769 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_cursor_trace_ent))) val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(move->cursor_entitynumber));
770 if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_ping))) val->_float = host_client->ping * 1000.0;
773 void SV_FrameLost(int framenum)
775 if (host_client->entitydatabase5)
776 EntityFrame5_LostFrame(host_client->entitydatabase5, framenum);
779 void SV_FrameAck(int framenum)
781 if (host_client->entitydatabase)
782 EntityFrame_AckFrame(host_client->entitydatabase, framenum);
783 else if (host_client->entitydatabase4)
784 EntityFrame4_AckFrame(host_client->entitydatabase4, framenum, true);
785 else if (host_client->entitydatabase5)
786 EntityFrame5_AckFrame(host_client->entitydatabase5, framenum);
794 extern void SV_SendServerinfo(client_t *client);
795 void SV_ReadClientMessage(void)
800 //MSG_BeginReading ();
804 if (!host_client->active)
806 // a command caused an error
807 SV_DropClient (false);
813 Con_Print("SV_ReadClientMessage: badread\n");
814 SV_DropClient (false);
818 cmd = MSG_ReadChar ();
828 Con_Printf("SV_ReadClientMessage: unknown command char %i\n", cmd);
829 SV_DropClient (false);
836 s = MSG_ReadString ();
837 if (strncasecmp(s, "spawn", 5) == 0
838 || strncasecmp(s, "begin", 5) == 0
839 || strncasecmp(s, "prespawn", 8) == 0)
840 Cmd_ExecuteString (s, src_client);
841 else if (SV_ParseClientCommandQC)
843 PRVM_G_INT(OFS_PARM0) = PRVM_SetEngineString(s);
844 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
845 PRVM_ExecuteProgram ((func_t)(SV_ParseClientCommandQC - prog->functions), "QC function SV_ParseClientCommand is missing");
847 else if (strncasecmp(s, "status", 6) == 0
848 || strncasecmp(s, "name", 4) == 0
849 || strncasecmp(s, "say", 3) == 0
850 || strncasecmp(s, "say_team", 8) == 0
851 || strncasecmp(s, "tell", 4) == 0
852 || strncasecmp(s, "color", 5) == 0
853 || strncasecmp(s, "kill", 4) == 0
854 || strncasecmp(s, "pause", 5) == 0
855 || strncasecmp(s, "kick", 4) == 0
856 || strncasecmp(s, "ping", 4) == 0
857 || strncasecmp(s, "ban", 3) == 0
858 || strncasecmp(s, "pmodel", 6) == 0
859 || strncasecmp(s, "rate", 4) == 0
860 || strncasecmp(s, "playermodel", 11) == 0
861 || strncasecmp(s, "playerskin", 10) == 0
862 || (gamemode == GAME_NEHAHRA && (strncasecmp(s, "max", 3) == 0 || strncasecmp(s, "monster", 7) == 0 || strncasecmp(s, "scrag", 5) == 0 || strncasecmp(s, "gimme", 5) == 0 || strncasecmp(s, "wraith", 6) == 0))
863 || (gamemode != GAME_NEHAHRA && (strncasecmp(s, "god", 3) == 0 || strncasecmp(s, "notarget", 8) == 0 || strncasecmp(s, "fly", 3) == 0 || strncasecmp(s, "give", 4) == 0 || strncasecmp(s, "noclip", 6) == 0)))
864 Cmd_ExecuteString (s, src_client);
866 Con_Printf("%s tried to %s\n", host_client->name, s);
870 SV_DropClient (false); // client wants to disconnect
874 // if ReadClientMove returns true, the client tried to speed cheat
875 if (SV_ReadClientMove ())
876 SV_DropClient (false);
880 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
881 num = MSG_ReadLong();
882 if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
883 if (developer_networkentities.integer >= 1)
884 Con_Printf("recv clc_ackframe %i\n", num);
885 // if the client hasn't progressed through signons yet,
886 // ignore any clc_ackframes we get (they're probably from the
888 if (host_client->spawned && host_client->latestframenum < num)
891 for (i = host_client->latestframenum + 1;i < num;i++)
894 host_client->latestframenum = num;