X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=sv_user.c;h=1e3d581f0c186bd501531e93af826af6a60fcdf0;hb=ecfab2093025515ba0dd1fb38723a1812970a554;hp=67dbdcc5a943902b8668e0cb5ea664f1bb5045b8;hpb=197da0b9148dfb2d1b16457df1ba1c08b86ff9c2;p=xonotic%2Fdarkplaces.git diff --git a/sv_user.c b/sv_user.c index 67dbdcc5..1e3d581f 100644 --- a/sv_user.c +++ b/sv_user.c @@ -23,8 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sv_demo.h" #define DEBUGMOVES 0 -static usercmd_t cmd; +static usercmd_t usercmd; extern cvar_t sv_autodemo_perclient; +extern cvar_t sv_rollangle; +extern cvar_t sv_rollspeed; /* ================== @@ -111,8 +113,7 @@ void SV_Spawn_f(cmd_state_t *cmd) PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); prog->ExecuteProgram(prog, PRVM_serverfunction(ClientConnect), "QC function ClientConnect is missing"); - if (cls.state == ca_dedicated) - Con_Printf("%s connected\n", host_client->name); + Con_Printf("%s connected\n", host_client->name); PRVM_serverglobalfloat(time) = sv.time; prog->ExecuteProgram(prog, PRVM_serverfunction(PutClientInServer), "QC function PutClientInServer is missing"); @@ -304,7 +305,7 @@ void SV_SetIdealPitch (void) static vec3_t wishdir, forward, right, up; static float wishspeed; -static qboolean onground; +static qbool onground; /* ================== @@ -443,12 +444,12 @@ static void SV_WaterMove (void) AngleVectors(v_angle, forward, right, up); for (i=0 ; i<3 ; i++) - wishvel[i] = forward[i]*cmd.forwardmove + right[i]*cmd.sidemove; + wishvel[i] = forward[i]*usercmd.forwardmove + right[i]*usercmd.sidemove; - if (!cmd.forwardmove && !cmd.sidemove && !cmd.upmove) + if (!usercmd.forwardmove && !usercmd.sidemove && !usercmd.upmove) wishvel[2] -= 60; // drift towards bottom else - wishvel[2] += cmd.upmove; + wishvel[2] += usercmd.upmove; fwishspeed = VectorLength(wishvel); if (fwishspeed > sv_maxspeed.value) @@ -520,8 +521,8 @@ static void SV_AirMove (void) wishvel[1] = PRVM_serveredictvector(host_client->edict, angles)[1]; AngleVectors (wishvel, forward, right, up); - fmove = cmd.forwardmove; - smove = cmd.sidemove; + fmove = usercmd.forwardmove; + smove = usercmd.sidemove; // hack to not let you back into teleporter if (sv.time < PRVM_serveredictfloat(host_client->edict, teleport_time) && fmove < 0) @@ -531,7 +532,7 @@ static void SV_AirMove (void) wishvel[i] = forward[i]*fmove + right[i]*smove; if ((int)PRVM_serveredictfloat(host_client->edict, movetype) != MOVETYPE_WALK) - wishvel[2] += cmd.upmove; + wishvel[2] += usercmd.upmove; VectorCopy (wishvel, wishdir); wishspeed = VectorNormalizeLength(wishdir); @@ -561,13 +562,13 @@ static void SV_AirMove (void) /* =================== -SV_ClientThink +SV_PlayerPhysics the move fields specify an intended velocity in pix/sec the angle fields specify an exact angular motion in degrees =================== */ -void SV_ClientThink (void) +void SV_PlayerPhysics (void) { prvm_prog_t *prog = SVVM_prog; vec3_t v_angle, angles, velocity; @@ -578,7 +579,7 @@ void SV_ClientThink (void) // make sure the velocity is sane (not a NaN) SV_CheckVelocity(host_client->edict); - // LadyHavoc: QuakeC replacement for SV_ClientThink (player movement) + // LadyHavoc: QuakeC replacement for SV_PlayerPhysics (player movement) if (PRVM_serverfunction(SV_PlayerPhysics) && sv_playerphysicsqc.integer) { PRVM_serverglobalfloat(time) = sv.time; @@ -599,14 +600,14 @@ void SV_ClientThink (void) if (PRVM_serveredictfloat(host_client->edict, health) <= 0) return; - cmd = host_client->cmd; + usercmd = host_client->cmd; // angles // show 1/3 the pitch angle and all the roll angle VectorAdd (PRVM_serveredictvector(host_client->edict, v_angle), PRVM_serveredictvector(host_client->edict, punchangle), v_angle); VectorCopy(PRVM_serveredictvector(host_client->edict, angles), angles); VectorCopy(PRVM_serveredictvector(host_client->edict, velocity), velocity); - PRVM_serveredictvector(host_client->edict, angles)[ROLL] = V_CalcRoll (angles, velocity)*4; + PRVM_serveredictvector(host_client->edict, angles)[ROLL] = Com_CalcRoll (angles, velocity, sv_rollangle.value, sv_rollspeed.value)*4; if (!PRVM_serveredictfloat(host_client->edict, fixangle)) { PRVM_serveredictvector(host_client->edict, angles)[PITCH] = -v_angle[PITCH]/3; @@ -620,16 +621,6 @@ void SV_ClientThink (void) return; } - /* - // Player is (somehow) outside of the map, or flying, or noclipping - if (PRVM_serveredictfloat(host_client->edict, movetype) != MOVETYPE_NOCLIP && (PRVM_serveredictfloat(host_client->edict, movetype) == MOVETYPE_FLY || SV_TestEntityPosition (host_client->edict))) - //if (PRVM_serveredictfloat(host_client->edict, movetype) == MOVETYPE_NOCLIP || PRVM_serveredictfloat(host_client->edict, movetype) == MOVETYPE_FLY || SV_TestEntityPosition (host_client->edict)) - { - SV_FreeMove (); - return; - } - */ - // walk if ((PRVM_serveredictfloat(host_client->edict, waterlevel) >= 2) && (PRVM_serveredictfloat(host_client->edict, movetype) != MOVETYPE_NOCLIP)) { @@ -747,7 +738,8 @@ static void SV_ReadClientMove (void) sv_readmoves[sv_numreadmoves++] = *move; // movement packet loss tracking - if(move->sequence) + // bones_was_here: checking begun prevents heavy loss detection right after a map change + if(move->sequence && host_client->begun) { if(move->sequence > host_client->movement_highestsequence_seen) { @@ -784,7 +776,7 @@ static void SV_ExecuteClientMoves(void) { prvm_prog_t *prog = SVVM_prog; int moveindex; - float moveframetime; + double moveframetime; double oldframetime; double oldframetime2; #ifdef NUM_PING_TIMES @@ -820,7 +812,8 @@ static void SV_ExecuteClientMoves(void) // this is a new move move->time = bound(sv.time - 1, move->time, sv.time); // prevent slowhack/speedhack combos move->time = max(move->time, host_client->cmd.time); // prevent backstepping of time - moveframetime = bound(0, move->time - host_client->cmd.time, min(0.1, sv_clmovement_inputtimeout.value)); + // bones_was_here: limit moveframetime to a multiple of sv.frametime to match inputtimeout behaviour + moveframetime = min(move->time - host_client->cmd.time, min(0.1, sys_ticrate.value > 0.0 ? sv.frametime * ceil(sv_clmovement_inputtimeout.value / sv.frametime) : sv_clmovement_inputtimeout.value)); // discard (treat like lost) moves with too low distance from // the previous one to prevent hacks using float inaccuracy @@ -849,8 +842,6 @@ static void SV_ExecuteClientMoves(void) // with this approach, and if they don't send input for a while they // start moving anyway, so the longest 'lagaport' possible is // determined by the sv_clmovement_inputtimeout cvar) - if (moveframetime <= 0) - continue; oldframetime = PRVM_serverglobalfloat(frametime); oldframetime2 = sv.frametime; // update ping time for qc to see while executing this move @@ -866,7 +857,7 @@ static void SV_ExecuteClientMoves(void) SV_Physics_ClientMove(); sv.frametime = oldframetime2; PRVM_serverglobalfloat(frametime) = oldframetime; - host_client->clmovement_inputtimeout = sv_clmovement_inputtimeout.value; + host_client->clmovement_inputtimeout = min(0.1, sv_clmovement_inputtimeout.value); } } } @@ -971,7 +962,7 @@ void SV_ApplyClientMove (void) PRVM_serveredictfloat(host_client->edict, ping_movementloss) = movementloss / (float) NETGRAPH_PACKETS; } -static qboolean SV_FrameLost(int framenum) +static qbool SV_FrameLost(int framenum) { if (host_client->entitydatabase5) { @@ -1072,7 +1063,7 @@ void SV_ReadClientMessage(void) if (strncasecmp(s, "spawn", 5) == 0 || strncasecmp(s, "begin", 5) == 0 || strncasecmp(s, "prespawn", 8) == 0) - Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true); + Cmd_ExecuteString (cmd_serverfromclient, s, src_client, true); else if (PRVM_serverfunction(SV_ParseClientCommand)) { int restorevm_tempstringsbuf_cursize; @@ -1084,7 +1075,7 @@ void SV_ReadClientMessage(void) prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; } else - Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true); + Cmd_ExecuteString (cmd_serverfromclient, s, src_client, true); break; clc_stringcmd_invalid: