X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=sv_user.c;h=6a621bac6d293c9ec2a573187e7ee821f1f805c9;hp=e3bc231a0ad00132d949627c9bba43f029848483;hb=0706fdfa8e33548670e59234409eac2c51849631;hpb=8881e4f2a4725a8e45db56db3e280b2361c5b3fe diff --git a/sv_user.c b/sv_user.c index e3bc231a..6a621bac 100644 --- a/sv_user.c +++ b/sv_user.c @@ -654,7 +654,7 @@ static void SV_ReadClientMove (void) // read ping time if (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE && sv.protocol != PROTOCOL_NEHAHRABJP && sv.protocol != PROTOCOL_NEHAHRABJP2 && sv.protocol != PROTOCOL_NEHAHRABJP3 && sv.protocol != PROTOCOL_DARKPLACES1 && sv.protocol != PROTOCOL_DARKPLACES2 && sv.protocol != PROTOCOL_DARKPLACES3 && sv.protocol != PROTOCOL_DARKPLACES4 && sv.protocol != PROTOCOL_DARKPLACES5 && sv.protocol != PROTOCOL_DARKPLACES6) move->sequence = MSG_ReadLong(&sv_message); - move->time = move->clienttime = MSG_ReadFloat(&sv_message); + move->time = MSG_ReadFloat(&sv_message); if (sv_message.badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__); move->receivetime = (float)sv.time; @@ -663,7 +663,7 @@ static void SV_ReadClientMove (void) #endif // limit reported time to current time // (incase the client is trying to cheat) - move->time = min(move->time, move->receivetime + sv.frametime); + move->time = min(move->time, sv.time + sv.frametime); // read current angles for (i = 0;i < 3;i++) @@ -718,7 +718,7 @@ static void SV_ReadClientMove (void) } // as requested by FrikaC, cursor_trace_ent is reset to world if the // entity is free at time of receipt - if (PRVM_EDICT_NUM(move->cursor_entitynumber)->priv.server->free) + if (PRVM_EDICT_NUM(move->cursor_entitynumber)->free) move->cursor_entitynumber = 0; if (sv_message.badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__); } @@ -738,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) { @@ -778,9 +779,7 @@ static void SV_ExecuteClientMoves(void) double moveframetime; double oldframetime; double oldframetime2; -#ifdef NUM_PING_TIMES - double total; -#endif + if (sv_numreadmoves < 1) return; // only start accepting input once the player is spawned @@ -812,7 +811,8 @@ static void SV_ExecuteClientMoves(void) 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 // 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)); + moveframetime = min(move->time - host_client->cmd.time, min(0.1, sys_ticrate.value > 0.0 && sv.frametime > 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 @@ -885,17 +885,9 @@ static void SV_ExecuteClientMoves(void) host_client->movesequence = 0; // make sure that normal physics takes over immediately host_client->clmovement_inputtimeout = 0; + // update ping time + host_client->ping = host_client->cmd.receivetime - sv_readmoves[sv_numreadmoves-1].time; } - - // calculate average ping time - host_client->ping = host_client->cmd.receivetime - host_client->cmd.clienttime; -#ifdef NUM_PING_TIMES - host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = host_client->cmd.receivetime - host_client->cmd.clienttime; - host_client->num_pings++; - for (i=0, total = 0;i < NUM_PING_TIMES;i++) - total += host_client->ping_times[i]; - host_client->ping = total / NUM_PING_TIMES; -#endif } void SV_ApplyClientMove (void) @@ -1007,14 +999,14 @@ void SV_ReadClientMessage(void) if (!host_client->active) { // a command caused an error - SV_DropClient (false); + SV_DropClient (false, "Connection closing"); return; } if (sv_message.badread) { Con_Print("SV_ReadClientMessage: badread\n"); - SV_DropClient (false); + SV_DropClient (false, "An internal server error occurred"); return; } @@ -1033,7 +1025,7 @@ void SV_ReadClientMessage(void) Con_Printf("SV_ReadClientMessage: unknown command char %i (at offset 0x%x)\n", netcmd, sv_message.readcount); if (developer_networking.integer) Com_HexDumpToConsole(sv_message.data, sv_message.cursize); - SV_DropClient (false); + SV_DropClient (false, "Unknown message sent to the server"); return; case clc_nop: @@ -1084,7 +1076,9 @@ clc_stringcmd_invalid: break; case clc_disconnect: - SV_DropClient (false); // client wants to disconnect + SV_DropClient (true, sv.protocol == PROTOCOL_DARKPLACES8 + ? MSG_ReadString(&sv_message, sv_readstring, sizeof(sv_readstring)) + : "Disconnect by user"); // client wants to disconnect return; case clc_move: