Merc's speed cheat code ported from oldtree

This commit is contained in:
Dan Olson 2000-05-14 19:29:57 +00:00
parent 71f7f1836e
commit 4312654fc2
5 changed files with 153 additions and 112 deletions

View file

@ -24,7 +24,7 @@ M: Ender has built these binaries sucessfully with a makefile.
[ ] 4. Any structural changes to the tree we agree to make
[ ] 5a. Linux targets need to be verified
[ ] 5b Win32 targets need to be verified
[ ] 6a. Mercury's speed cheat fix
[X] 6a. Mercury's speed cheat fix
< > M2k. QSG Standards Version 1
[-] 6b. Cvar revamp
[-] 7. Global config file

View file

@ -57,6 +57,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "world.h"
#include "pmove.h"
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
//=============================================================================
// the host system specifies the base of the directory tree, the

View file

@ -189,6 +189,8 @@ typedef struct client_s
int chokecount;
int delta_sequence; // -1 = no compression
netchan_t netchan;
int msecs, msec_cheating;
double last_check;
} client_t;
// a client can leave the server in one of four ways:

View file

@ -66,6 +66,9 @@ cvar_t sv_phs = {"sv_phs", "1"};
cvar_t pausable = {"pausable", "1"};
extern cvar_t sv_timekick;
extern cvar_t sv_timekick_fuzz;
extern cvar_t sv_timekick_interval;
//
// game rules mirrored in svs.info
@ -1352,6 +1355,10 @@ void SV_InitLocal (void)
Cvar_RegisterVariable (&sv_aim);
Cvar_RegisterVariable (&sv_timekick);
Cvar_RegisterVariable (&sv_timekick_fuzz);
Cvar_RegisterVariable (&sv_timekick_interval);
Cvar_RegisterVariable (&filterban);
Cvar_RegisterVariable (&allow_download);

View file

@ -26,7 +26,7 @@
$Id$
*/
// sv_user.c -- server code for moving users
#include <math.h>
#include "qwsvdef.h"
edict_t *sv_player;
@ -39,6 +39,10 @@ cvar_t sv_spectalk = {"sv_spectalk", "1"};
cvar_t sv_mapcheck = {"sv_mapcheck", "1"};
cvar_t sv_timekick = {"sv_timekick", "3", false, true};
cvar_t sv_timekick_fuzz = {"sv_timekick_fuzz", "10"};
cvar_t sv_timekick_interval = {"sv_timekick_interval", "30"};
extern vec3_t player_mins;
extern int fp_messages, fp_persecond, fp_secondsdead;
@ -693,7 +697,7 @@ void SV_BeginDownload_f(void)
char *p;
for (p = name; *p; p++)
*p = tolower((int)*p);
*p = (char)tolower(*p);
}
@ -1373,148 +1377,171 @@ void SV_PreRunCmd(void)
SV_RunCmd
===========
*/
void SV_RunCmd (usercmd_t *ucmd)
void SV_RunCmd (usercmd_t *ucmd, qboolean inside)
{
edict_t *ent;
int i, n;
int oldmsec;
edict_t *ent;
int i, n, oldmsec;
double tmp_time;
cmd = *ucmd;
// To prevent a infinite loop
if (!inside) {
host_client->msecs += ucmd->msec;
// chop up very long commands
if (cmd.msec > 50)
{
oldmsec = ucmd->msec;
cmd.msec = oldmsec/2;
SV_RunCmd (&cmd);
cmd.msec = oldmsec/2;
cmd.impulse = 0;
SV_RunCmd (&cmd);
return;
}
if ((sv_timekick.value >= 1) &&
(tmp_time = realtime - host_client->last_check) >= sv_timekick_interval.value) {
tmp_time *= (1000 + sv_timekick_fuzz.value);
if (host_client->msecs > (int) tmp_time) {
host_client->msec_cheating++;
SV_BroadcastPrintf( PRINT_HIGH,
va("%s thinks %d msecs pass in %f msecs. (Strike %d/%d)\n",
host_client->name, host_client->msecs, tmp_time,
host_client->msec_cheating, (int)sv_timekick.value));
if (!sv_player->v.fixangle)
VectorCopy (ucmd->angles, sv_player->v.v_angle);
if (host_client->msec_cheating >= sv_timekick.value) {
SV_BroadcastPrintf(PRINT_HIGH, va("Strike %d for %s!!\n",
host_client->msec_cheating, host_client->name));
SV_BroadcastPrintf(PRINT_HIGH, "Please see http://www.quakeforge.net/speed_cheat.php for infomation on QuakeForge's time cheat protection, and to explain how some may be cheating without knowing it.\n"
);
SV_DropClient(host_client);
}
}
sv_player->v.button0 = ucmd->buttons & 1;
sv_player->v.button2 = (ucmd->buttons & 2)>>1;
if (ucmd->impulse)
sv_player->v.impulse = ucmd->impulse;
host_client->msecs = 0;
host_client->last_check = realtime;
}
}
cmd = *ucmd;
// chop up very long commands
if (cmd.msec > 50) {
oldmsec = ucmd->msec;
cmd.msec = oldmsec/2;
SV_RunCmd (&cmd, 1);
cmd.msec = oldmsec/2;
cmd.impulse = 0;
SV_RunCmd (&cmd, 1);
return;
}
if (!sv_player->v.fixangle)
VectorCopy (ucmd->angles, sv_player->v.v_angle);
sv_player->v.button0 = ucmd->buttons & 1;
sv_player->v.button2 = (ucmd->buttons & 2)>>1;
if (ucmd->impulse)
sv_player->v.impulse = ucmd->impulse;
//
// angles
// show 1/3 the pitch angle and all the roll angle
if (sv_player->v.health > 0)
{
if (!sv_player->v.fixangle)
{
sv_player->v.angles[PITCH] = -sv_player->v.v_angle[PITCH]/3;
sv_player->v.angles[YAW] = sv_player->v.v_angle[YAW];
}
sv_player->v.angles[ROLL] =
V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;
}
if (sv_player->v.health > 0) {
if (!sv_player->v.fixangle) {
sv_player->v.angles[PITCH] = -sv_player->v.v_angle[PITCH
]/3;
sv_player->v.angles[YAW] = sv_player->v.v_angle[YAW];
}
sv_player->v.angles[ROLL] =
V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*
4;
}
host_frametime = ucmd->msec * 0.001;
if (host_frametime > 0.1)
host_frametime = 0.1;
host_frametime = min(0.1, ucmd->msec * 0.001);
if (!host_client->spectator)
{
pr_global_struct->frametime = host_frametime;
if (!host_client->spectator) {
pr_global_struct->frametime = host_frametime;
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (pr_global_struct->PlayerPreThink);
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (pr_global_struct->PlayerPreThink);
SV_RunThink (sv_player);
}
SV_RunThink (sv_player);
}
for (i=0 ; i<3 ; i++)
pmove.origin[i] = sv_player->v.origin[i] + (sv_player->v.mins[i] - player_mins[i]);
VectorCopy (sv_player->v.velocity, pmove.velocity);
VectorCopy (sv_player->v.v_angle, pmove.angles);
for (i=0 ; i<3 ; i++)
pmove.origin[i] = sv_player->v.origin[i] + (sv_player->v.mins[i]
- player_mins[i]);
VectorCopy (sv_player->v.velocity, pmove.velocity);
VectorCopy (sv_player->v.v_angle, pmove.angles);
pmove.flying = sv_player->v.movetype == MOVETYPE_FLY;
pmove.spectator = host_client->spectator;
pmove.waterjumptime = sv_player->v.teleport_time;
pmove.numphysent = 1;
pmove.physents[0].model = sv.worldmodel;
pmove.cmd = *ucmd;
pmove.dead = sv_player->v.health <= 0;
pmove.oldbuttons = host_client->oldbuttons;
pmove.flying = sv_player->v.movetype == MOVETYPE_FLY;
pmove.spectator = host_client->spectator;
pmove.waterjumptime = sv_player->v.teleport_time;
pmove.numphysent = 1;
pmove.physents[0].model = sv.worldmodel;
pmove.cmd = *ucmd;
pmove.dead = sv_player->v.health <= 0;
pmove.oldbuttons = host_client->oldbuttons;
movevars.entgravity = host_client->entgravity;
movevars.maxspeed = host_client->maxspeed;
movevars.entgravity = host_client->entgravity;
movevars.maxspeed = host_client->maxspeed;
for (i=0 ; i<3 ; i++)
{
pmove_mins[i] = pmove.origin[i] - 256;
pmove_maxs[i] = pmove.origin[i] + 256;
}
for (i=0 ; i<3 ; i++) {
pmove_mins[i] = pmove.origin[i] - 256;
pmove_maxs[i] = pmove.origin[i] + 256;
}
#if 1
AddLinksToPmove ( sv_areanodes );
AddLinksToPmove ( sv_areanodes );
#else
AddAllEntsToPmove ();
AddAllEntsToPmove ();
#endif
#if 0
{
int before, after;
int before, after;
before = PM_TestPlayerPosition (pmove.origin);
PlayerMove ();
PlayerMove ();
after = PM_TestPlayerPosition (pmove.origin);
if (sv_player->v.health > 0 && before && !after )
Con_Printf ("player %s got stuck in playermove!!!!\n", host_client->name);
Con_Printf ("player %s got stuck in playermove!!!!\n", host_client->name
);
}
#else
PlayerMove ();
PlayerMove ();
#endif
host_client->oldbuttons = pmove.oldbuttons;
sv_player->v.teleport_time = pmove.waterjumptime;
sv_player->v.waterlevel = waterlevel;
sv_player->v.watertype = watertype;
if (onground != -1)
{
sv_player->v.flags = (int)sv_player->v.flags | FL_ONGROUND;
sv_player->v.groundentity = EDICT_TO_PROG(EDICT_NUM(pmove.physents[onground].info));
}
else
sv_player->v.flags = (int)sv_player->v.flags & ~FL_ONGROUND;
for (i=0 ; i<3 ; i++)
sv_player->v.origin[i] = pmove.origin[i] - (sv_player->v.mins[i] - player_mins[i]);
host_client->oldbuttons = pmove.oldbuttons;
sv_player->v.teleport_time = pmove.waterjumptime;
sv_player->v.waterlevel = waterlevel;
sv_player->v.watertype = watertype;
if (onground != -1) {
sv_player->v.flags = (int)sv_player->v.flags | FL_ONGROUND;
sv_player->v.groundentity = EDICT_TO_PROG(EDICT_NUM(pmove.physents[onground].info));
} else {
sv_player->v.flags = (int)sv_player->v.flags & ~FL_ONGROUND;
}
for (i=0 ; i<3 ; i++)
sv_player->v.origin[i] = pmove.origin[i] - (sv_player->v.mins[i]
- player_mins[i]);
#if 0
// truncate velocity the same way the net protocol will
for (i=0 ; i<3 ; i++)
sv_player->v.velocity[i] = (int)pmove.velocity[i];
// truncate velocity the same way the net protocol will
for (i=0 ; i<3 ; i++)
sv_player->v.velocity[i] = (int)pmove.velocity[i];
#else
VectorCopy (pmove.velocity, sv_player->v.velocity);
VectorCopy (pmove.velocity, sv_player->v.velocity);
#endif
VectorCopy (pmove.angles, sv_player->v.v_angle);
VectorCopy (pmove.angles, sv_player->v.v_angle);
if (!host_client->spectator)
{
// link into place and touch triggers
SV_LinkEdict (sv_player, true);
if (!host_client->spectator) {
// link into place and touch triggers
SV_LinkEdict (sv_player, true);
// touch other objects
for (i=0 ; i<pmove.numtouch ; i++)
{
n = pmove.physents[pmove.touchindex[i]].info;
ent = EDICT_NUM(n);
if (!ent->v.touch || (playertouch[n/8]&(1<<(n%8))))
continue;
pr_global_struct->self = EDICT_TO_PROG(ent);
pr_global_struct->other = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (ent->v.touch);
playertouch[n/8] |= 1 << (n%8);
}
}
// touch other objects
for (i=0 ; i<pmove.numtouch ; i++) {
n = pmove.physents[pmove.touchindex[i]].info;
ent = EDICT_NUM(n);
if (!ent->v.touch || (playertouch[n/8]&(1<<(n%8))))
continue;
pr_global_struct->self = EDICT_TO_PROG(ent);
pr_global_struct->other = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (ent->v.touch);
playertouch[n/8] |= 1 << (n%8);
}
}
}
/*
@ -1650,15 +1677,15 @@ void SV_ExecuteClientMessage (client_t *cl)
{
while (net_drop > 2)
{
SV_RunCmd (&cl->lastcmd);
SV_RunCmd (&cl->lastcmd, 0);
net_drop--;
}
if (net_drop > 1)
SV_RunCmd (&oldest);
SV_RunCmd (&oldest, 0);
if (net_drop > 0)
SV_RunCmd (&oldcmd);
SV_RunCmd (&oldcmd, 0);
}
SV_RunCmd (&newcmd);
SV_RunCmd (&newcmd, 0);
SV_PostRunCmd();
}