mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2025-05-31 01:10:58 +00:00
The real speed cheat fix!
This commit is contained in:
parent
34391442c7
commit
b5034f28d6
3 changed files with 28 additions and 69 deletions
|
@ -193,8 +193,8 @@ typedef struct client_s
|
||||||
int delta_sequence; // -1 = no compression
|
int delta_sequence; // -1 = no compression
|
||||||
int ping;
|
int ping;
|
||||||
netchan_t netchan;
|
netchan_t netchan;
|
||||||
int msecs[MAX_MSECS], msec_count, msec_head, msec_total, msec_pool;
|
int msecs, msec_cheating;
|
||||||
double frame_time;
|
double last_check;
|
||||||
} 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:
|
||||||
|
|
|
@ -714,13 +714,9 @@ void SVC_DirectConnect (void)
|
||||||
newcl->sendinfo = true;
|
newcl->sendinfo = true;
|
||||||
|
|
||||||
// QuakeForge stuff.
|
// QuakeForge stuff.
|
||||||
for (i=0; i<MAX_MSECS; i++)
|
newcl->msecs = 0;
|
||||||
newcl->msecs[i] = 0;
|
newcl->msec_cheating = 0;
|
||||||
|
newcl->last_check = realtime;
|
||||||
newcl->msec_count = 0;
|
|
||||||
newcl->msec_head = 0;
|
|
||||||
newcl->msec_total = 0;
|
|
||||||
newcl->frame_time = realtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Rcon_Validate (void)
|
int Rcon_Validate (void)
|
||||||
|
|
|
@ -1368,6 +1368,7 @@ void SV_PreRunCmd(void)
|
||||||
/* maximum msec offset we will allow before penalizing the player */
|
/* maximum msec offset we will allow before penalizing the player */
|
||||||
#define POOLMAX 150
|
#define POOLMAX 150
|
||||||
|
|
||||||
|
#define CHECK_TIME 10
|
||||||
/*
|
/*
|
||||||
===========
|
===========
|
||||||
SV_RunCmd
|
SV_RunCmd
|
||||||
|
@ -1376,71 +1377,33 @@ SV_RunCmd
|
||||||
void SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
void SV_RunCmd (usercmd_t *ucmd, qboolean inside)
|
||||||
{
|
{
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
int i, n, oldmsec, idealmsec;
|
int i, n, oldmsec;
|
||||||
double tmp_time;
|
double tmp_time;
|
||||||
|
|
||||||
// To prevent a infinite loop
|
// To prevent a infinite loop
|
||||||
if (!inside) {
|
if (!inside) {
|
||||||
oldmsec = ucmd->msec;
|
host_client->msecs += ucmd->msec;
|
||||||
// Calculate the ideal msec.
|
|
||||||
tmp_time = realtime - host_client->frame_time;
|
|
||||||
idealmsec = tmp_time * 1000;
|
|
||||||
|
|
||||||
if (loss)
|
if ((tmp_time = realtime - host_client->last_check) >= CHECK_TIME) {
|
||||||
idealmsec /= (loss + 1);
|
tmp_time *= 1000;
|
||||||
|
if (host_client->msecs > tmp_time) {
|
||||||
|
host_client->msec_cheating++;
|
||||||
|
SV_BroadcastPrintf(PRINT_HIGH,
|
||||||
|
va("Err, %s may be CHEATING! %d %f %d\n",
|
||||||
|
host_client->name, host_client->msecs, tmp_time,
|
||||||
|
host_client->msec_cheating));
|
||||||
|
|
||||||
// Cap it at a max of 250 msec though..
|
if (host_client->msec_cheating >= 2) {
|
||||||
idealmsec = min(idealmsec, 250);
|
SV_BroadcastPrintf(PRINT_HIGH,
|
||||||
idealmsec = max(idealmsec, 10);
|
va("*WHACK* %s (%s) has been caught cheating!\n",
|
||||||
|
host_client->name, NET_AdrToString(host_client->netchan.remote_address)));
|
||||||
|
SV_DropClient(host_client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
host_client->msec_total -= host_client->msecs[host_client->msec_head];
|
host_client->msecs = 0;
|
||||||
host_client->msec_total += idealmsec;
|
host_client->last_check = realtime;
|
||||||
|
|
||||||
host_client->msecs[host_client->msec_head] = idealmsec;
|
|
||||||
host_client->msec_head = (host_client->msec_head + 1) % MSECSIZE;
|
|
||||||
host_client->msec_count = min(MSECSIZE, host_client->msec_count + 1);
|
|
||||||
|
|
||||||
host_client->msec_pool += idealmsec - oldmsec;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (abs(host_client->msec_pool) > POOLMAX)
|
|
||||||
{
|
|
||||||
printf("tmp_t: %f, realt: %f, frame_t: %f, loss: %d, total: %d\n",
|
|
||||||
tmp_time, realtime, host_client->frame_time, loss,
|
|
||||||
host_client->msec_total);
|
|
||||||
/*
|
|
||||||
printf("%3d %3d %3d %3d %3d ",
|
|
||||||
host_client->msecs[0],
|
|
||||||
host_client->msecs[1],
|
|
||||||
host_client->msecs[2],
|
|
||||||
host_client->msecs[3],
|
|
||||||
host_client->msecs[4]);
|
|
||||||
*/
|
|
||||||
if (abs(host_client->msec_pool) > POOLMAX)
|
|
||||||
printf("*** ");
|
|
||||||
else
|
|
||||||
printf(" ");
|
|
||||||
|
|
||||||
printf("oldmsec: %d, msec: %d, pool: %d\n", oldmsec,
|
|
||||||
idealmsec, host_client->msec_pool);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (abs(host_client->msec_pool) > POOLMAX)
|
|
||||||
{
|
|
||||||
/* if our pool exceeds POOLMAX msec, empty it into msec. This
|
|
||||||
should cause the client to 'jitter' back a bit as his
|
|
||||||
position is reset. */
|
|
||||||
ucmd->msec = oldmsec - host_client->msec_pool;
|
|
||||||
host_client->msec_pool = 0;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
/* trust the client - if he's cheating, his pool will overflow
|
|
||||||
anyway within a couple of packets. */
|
|
||||||
ucmd->msec = oldmsec;
|
|
||||||
}
|
|
||||||
|
|
||||||
host_client->frame_time = realtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = *ucmd;
|
cmd = *ucmd;
|
||||||
|
@ -1712,13 +1675,13 @@ void SV_ExecuteClientMessage (client_t *cl)
|
||||||
|
|
||||||
if (net_drop < 20) {
|
if (net_drop < 20) {
|
||||||
while (net_drop > 2) {
|
while (net_drop > 2) {
|
||||||
SV_RunCmd (&cl->lastcmd, 1);
|
SV_RunCmd (&cl->lastcmd, 0);
|
||||||
net_drop--;
|
net_drop--;
|
||||||
}
|
}
|
||||||
if (net_drop > 1)
|
if (net_drop > 1)
|
||||||
SV_RunCmd (&oldest, 1);
|
SV_RunCmd (&oldest, 0);
|
||||||
if (net_drop > 0)
|
if (net_drop > 0)
|
||||||
SV_RunCmd (&oldcmd, 1);
|
SV_RunCmd (&oldcmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_RunCmd (&newcmd, 0);
|
SV_RunCmd (&newcmd, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue