mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-22 11:51:17 +00:00
Mercury's solution to the speed cheat problem, test the hell out of it!
This commit is contained in:
parent
ef8e59610a
commit
9e47ecdf16
2 changed files with 37 additions and 30 deletions
|
@ -189,6 +189,7 @@ typedef struct client_s
|
||||||
int chokecount;
|
int chokecount;
|
||||||
int delta_sequence; // -1 = no compression
|
int delta_sequence; // -1 = no compression
|
||||||
netchan_t netchan;
|
netchan_t netchan;
|
||||||
|
double frame_time_1, frame_time_2;
|
||||||
} client_t;
|
} client_t;
|
||||||
|
|
||||||
// a client can leave the server in one of four ways:
|
// a client can leave the server in one of four ways:
|
||||||
|
|
|
@ -1363,37 +1363,43 @@ void SV_PreRunCmd(void)
|
||||||
SV_RunCmd
|
SV_RunCmd
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
void SV_RunCmd (usercmd_t *ucmd)
|
void SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
||||||
{
|
{
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
int i, n;
|
int i, n;
|
||||||
int oldmsec;
|
int oldmsec;
|
||||||
|
double tmp_time;
|
||||||
|
|
||||||
//MBD: The id client limits msec to 100.
|
if (!inside) {
|
||||||
if (ucmd->msec > 100) {
|
oldmsec = ucmd->msec;
|
||||||
Con_Printf("Speed cheat detected for player %s\n",
|
tmp_time = realtime - host_client->frame_time_2;
|
||||||
host_client->name);
|
tmp_time /= 2;
|
||||||
// We want to punish people that tries to do this. Let us
|
ucmd->msec = tmp_time * 1000;
|
||||||
// set their fps to 1000
|
if (ucmd->msec > oldmsec)
|
||||||
ucmd->msec = 1;
|
ucmd->msec = oldmsec;
|
||||||
// This has the added benefit that the server eventually will
|
|
||||||
// KICK the player, calling him a timedemo cheater.
|
if (abs(oldmsec - ucmd->msec) > 10) {
|
||||||
// Neat, huh? :-)
|
printf("tmp_time: %f, realtime: %f, frame_time_1: %f\n",
|
||||||
|
tmp_time, realtime, host_client->frame_time_1);
|
||||||
|
printf("oldmsec: '%d', msec: '%d'\n", oldmsec,
|
||||||
|
ucmd->msec);
|
||||||
}
|
}
|
||||||
|
host_client->frame_time_2 = host_client->frame_time_1;
|
||||||
|
host_client->frame_time_1 = realtime;
|
||||||
|
|
||||||
cmd = *ucmd;
|
cmd = *ucmd;
|
||||||
|
|
||||||
// chop up very long commands
|
// chop up very long commands
|
||||||
if (cmd.msec > 50)
|
if (cmd.msec > 50) {
|
||||||
{
|
|
||||||
oldmsec = ucmd->msec;
|
oldmsec = ucmd->msec;
|
||||||
cmd.msec = oldmsec/2;
|
cmd.msec = oldmsec/2;
|
||||||
SV_RunCmd (&cmd);
|
SV_RunCmd (&cmd, 1);
|
||||||
cmd.msec = oldmsec/2;
|
cmd.msec = oldmsec/2;
|
||||||
cmd.impulse = 0;
|
cmd.impulse = 0;
|
||||||
SV_RunCmd (&cmd);
|
SV_RunCmd (&cmd, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!sv_player->v.fixangle)
|
if (!sv_player->v.fixangle)
|
||||||
VectorCopy (ucmd->angles, sv_player->v.v_angle);
|
VectorCopy (ucmd->angles, sv_player->v.v_angle);
|
||||||
|
@ -1651,15 +1657,15 @@ void SV_ExecuteClientMessage (client_t *cl)
|
||||||
{
|
{
|
||||||
while (net_drop > 2)
|
while (net_drop > 2)
|
||||||
{
|
{
|
||||||
SV_RunCmd (&cl->lastcmd);
|
SV_RunCmd (&cl->lastcmd, 0);
|
||||||
net_drop--;
|
net_drop--;
|
||||||
}
|
}
|
||||||
if (net_drop > 1)
|
if (net_drop > 1)
|
||||||
SV_RunCmd (&oldest);
|
SV_RunCmd (&oldest, 0);
|
||||||
if (net_drop > 0)
|
if (net_drop > 0)
|
||||||
SV_RunCmd (&oldcmd);
|
SV_RunCmd (&oldcmd, 0);
|
||||||
}
|
}
|
||||||
SV_RunCmd (&newcmd);
|
SV_RunCmd (&newcmd, 0);
|
||||||
|
|
||||||
SV_PostRunCmd();
|
SV_PostRunCmd();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue