mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-28 14:53:16 +00:00
Merc's speed cheat code ported from oldtree
This commit is contained in:
parent
71f7f1836e
commit
4312654fc2
5 changed files with 153 additions and 112 deletions
|
@ -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
|
[ ] 4. Any structural changes to the tree we agree to make
|
||||||
[ ] 5a. Linux targets need to be verified
|
[ ] 5a. Linux targets need to be verified
|
||||||
[ ] 5b Win32 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
|
< > M2k. QSG Standards Version 1
|
||||||
[-] 6b. Cvar revamp
|
[-] 6b. Cvar revamp
|
||||||
[-] 7. Global config file
|
[-] 7. Global config file
|
||||||
|
|
|
@ -57,6 +57,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "pmove.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
|
// the host system specifies the base of the directory tree, the
|
||||||
|
|
|
@ -189,6 +189,8 @@ 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;
|
||||||
|
int msecs, msec_cheating;
|
||||||
|
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:
|
||||||
|
|
|
@ -66,6 +66,9 @@ cvar_t sv_phs = {"sv_phs", "1"};
|
||||||
|
|
||||||
cvar_t pausable = {"pausable", "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
|
// game rules mirrored in svs.info
|
||||||
|
@ -1352,6 +1355,10 @@ void SV_InitLocal (void)
|
||||||
|
|
||||||
Cvar_RegisterVariable (&sv_aim);
|
Cvar_RegisterVariable (&sv_aim);
|
||||||
|
|
||||||
|
Cvar_RegisterVariable (&sv_timekick);
|
||||||
|
Cvar_RegisterVariable (&sv_timekick_fuzz);
|
||||||
|
Cvar_RegisterVariable (&sv_timekick_interval);
|
||||||
|
|
||||||
Cvar_RegisterVariable (&filterban);
|
Cvar_RegisterVariable (&filterban);
|
||||||
|
|
||||||
Cvar_RegisterVariable (&allow_download);
|
Cvar_RegisterVariable (&allow_download);
|
||||||
|
|
249
source/sv_user.c
249
source/sv_user.c
|
@ -26,7 +26,7 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
// sv_user.c -- server code for moving users
|
// sv_user.c -- server code for moving users
|
||||||
|
#include <math.h>
|
||||||
#include "qwsvdef.h"
|
#include "qwsvdef.h"
|
||||||
|
|
||||||
edict_t *sv_player;
|
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_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 vec3_t player_mins;
|
||||||
|
|
||||||
extern int fp_messages, fp_persecond, fp_secondsdead;
|
extern int fp_messages, fp_persecond, fp_secondsdead;
|
||||||
|
@ -693,7 +697,7 @@ void SV_BeginDownload_f(void)
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
for (p = name; *p; p++)
|
for (p = name; *p; p++)
|
||||||
*p = tolower((int)*p);
|
*p = (char)tolower(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1373,148 +1377,171 @@ 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, oldmsec;
|
||||||
int oldmsec;
|
double tmp_time;
|
||||||
|
|
||||||
cmd = *ucmd;
|
// To prevent a infinite loop
|
||||||
|
if (!inside) {
|
||||||
|
host_client->msecs += ucmd->msec;
|
||||||
|
|
||||||
// chop up very long commands
|
if ((sv_timekick.value >= 1) &&
|
||||||
if (cmd.msec > 50)
|
(tmp_time = realtime - host_client->last_check) >= sv_timekick_interval.value) {
|
||||||
{
|
tmp_time *= (1000 + sv_timekick_fuzz.value);
|
||||||
oldmsec = ucmd->msec;
|
if (host_client->msecs > (int) tmp_time) {
|
||||||
cmd.msec = oldmsec/2;
|
host_client->msec_cheating++;
|
||||||
SV_RunCmd (&cmd);
|
SV_BroadcastPrintf( PRINT_HIGH,
|
||||||
cmd.msec = oldmsec/2;
|
va("%s thinks %d msecs pass in %f msecs. (Strike %d/%d)\n",
|
||||||
cmd.impulse = 0;
|
host_client->name, host_client->msecs, tmp_time,
|
||||||
SV_RunCmd (&cmd);
|
host_client->msec_cheating, (int)sv_timekick.value));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sv_player->v.fixangle)
|
if (host_client->msec_cheating >= sv_timekick.value) {
|
||||||
VectorCopy (ucmd->angles, sv_player->v.v_angle);
|
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;
|
host_client->msecs = 0;
|
||||||
sv_player->v.button2 = (ucmd->buttons & 2)>>1;
|
host_client->last_check = realtime;
|
||||||
if (ucmd->impulse)
|
}
|
||||||
sv_player->v.impulse = ucmd->impulse;
|
}
|
||||||
|
|
||||||
|
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
|
// angles
|
||||||
// show 1/3 the pitch angle and all the roll angle
|
// show 1/3 the pitch angle and all the roll angle
|
||||||
if (sv_player->v.health > 0)
|
if (sv_player->v.health > 0) {
|
||||||
{
|
if (!sv_player->v.fixangle) {
|
||||||
if (!sv_player->v.fixangle)
|
sv_player->v.angles[PITCH] = -sv_player->v.v_angle[PITCH
|
||||||
{
|
]/3;
|
||||||
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[YAW] = sv_player->v.v_angle[YAW];
|
}
|
||||||
}
|
sv_player->v.angles[ROLL] =
|
||||||
sv_player->v.angles[ROLL] =
|
V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*
|
||||||
V_CalcRoll (sv_player->v.angles, sv_player->v.velocity)*4;
|
4;
|
||||||
}
|
}
|
||||||
|
|
||||||
host_frametime = ucmd->msec * 0.001;
|
host_frametime = min(0.1, ucmd->msec * 0.001);
|
||||||
if (host_frametime > 0.1)
|
|
||||||
host_frametime = 0.1;
|
if (!host_client->spectator) {
|
||||||
|
pr_global_struct->frametime = host_frametime;
|
||||||
|
|
||||||
if (!host_client->spectator)
|
pr_global_struct->time = sv.time;
|
||||||
{
|
pr_global_struct->self = EDICT_TO_PROG(sv_player);
|
||||||
pr_global_struct->frametime = host_frametime;
|
PR_ExecuteProgram (pr_global_struct->PlayerPreThink);
|
||||||
|
|
||||||
pr_global_struct->time = sv.time;
|
SV_RunThink (sv_player);
|
||||||
pr_global_struct->self = EDICT_TO_PROG(sv_player);
|
}
|
||||||
PR_ExecuteProgram (pr_global_struct->PlayerPreThink);
|
|
||||||
|
|
||||||
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.flying = sv_player->v.movetype == MOVETYPE_FLY;
|
||||||
pmove.origin[i] = sv_player->v.origin[i] + (sv_player->v.mins[i] - player_mins[i]);
|
pmove.spectator = host_client->spectator;
|
||||||
VectorCopy (sv_player->v.velocity, pmove.velocity);
|
pmove.waterjumptime = sv_player->v.teleport_time;
|
||||||
VectorCopy (sv_player->v.v_angle, pmove.angles);
|
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;
|
movevars.entgravity = host_client->entgravity;
|
||||||
pmove.spectator = host_client->spectator;
|
movevars.maxspeed = host_client->maxspeed;
|
||||||
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;
|
for (i=0 ; i<3 ; i++) {
|
||||||
movevars.maxspeed = host_client->maxspeed;
|
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
|
#if 1
|
||||||
AddLinksToPmove ( sv_areanodes );
|
AddLinksToPmove ( sv_areanodes );
|
||||||
#else
|
#else
|
||||||
AddAllEntsToPmove ();
|
AddAllEntsToPmove ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
int before, after;
|
int before, after;
|
||||||
|
|
||||||
before = PM_TestPlayerPosition (pmove.origin);
|
before = PM_TestPlayerPosition (pmove.origin);
|
||||||
PlayerMove ();
|
PlayerMove ();
|
||||||
after = PM_TestPlayerPosition (pmove.origin);
|
after = PM_TestPlayerPosition (pmove.origin);
|
||||||
|
|
||||||
if (sv_player->v.health > 0 && before && !after )
|
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
|
#else
|
||||||
PlayerMove ();
|
PlayerMove ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
host_client->oldbuttons = pmove.oldbuttons;
|
host_client->oldbuttons = pmove.oldbuttons;
|
||||||
sv_player->v.teleport_time = pmove.waterjumptime;
|
sv_player->v.teleport_time = pmove.waterjumptime;
|
||||||
sv_player->v.waterlevel = waterlevel;
|
sv_player->v.waterlevel = waterlevel;
|
||||||
sv_player->v.watertype = watertype;
|
sv_player->v.watertype = watertype;
|
||||||
if (onground != -1)
|
if (onground != -1) {
|
||||||
{
|
sv_player->v.flags = (int)sv_player->v.flags | FL_ONGROUND;
|
||||||
sv_player->v.flags = (int)sv_player->v.flags | FL_ONGROUND;
|
sv_player->v.groundentity = EDICT_TO_PROG(EDICT_NUM(pmove.physents[onground].info));
|
||||||
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;
|
||||||
else
|
}
|
||||||
sv_player->v.flags = (int)sv_player->v.flags & ~FL_ONGROUND;
|
for (i=0 ; i<3 ; i++)
|
||||||
for (i=0 ; i<3 ; i++)
|
sv_player->v.origin[i] = pmove.origin[i] - (sv_player->v.mins[i]
|
||||||
sv_player->v.origin[i] = pmove.origin[i] - (sv_player->v.mins[i] - player_mins[i]);
|
- player_mins[i]);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// truncate velocity the same way the net protocol will
|
// truncate velocity the same way the net protocol will
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
sv_player->v.velocity[i] = (int)pmove.velocity[i];
|
sv_player->v.velocity[i] = (int)pmove.velocity[i];
|
||||||
#else
|
#else
|
||||||
VectorCopy (pmove.velocity, sv_player->v.velocity);
|
VectorCopy (pmove.velocity, sv_player->v.velocity);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VectorCopy (pmove.angles, sv_player->v.v_angle);
|
VectorCopy (pmove.angles, sv_player->v.v_angle);
|
||||||
|
|
||||||
if (!host_client->spectator)
|
if (!host_client->spectator) {
|
||||||
{
|
// link into place and touch triggers
|
||||||
// link into place and touch triggers
|
SV_LinkEdict (sv_player, true);
|
||||||
SV_LinkEdict (sv_player, true);
|
|
||||||
|
|
||||||
// touch other objects
|
// touch other objects
|
||||||
for (i=0 ; i<pmove.numtouch ; i++)
|
for (i=0 ; i<pmove.numtouch ; i++) {
|
||||||
{
|
n = pmove.physents[pmove.touchindex[i]].info;
|
||||||
n = pmove.physents[pmove.touchindex[i]].info;
|
ent = EDICT_NUM(n);
|
||||||
ent = EDICT_NUM(n);
|
if (!ent->v.touch || (playertouch[n/8]&(1<<(n%8))))
|
||||||
if (!ent->v.touch || (playertouch[n/8]&(1<<(n%8))))
|
continue;
|
||||||
continue;
|
pr_global_struct->self = EDICT_TO_PROG(ent);
|
||||||
pr_global_struct->self = EDICT_TO_PROG(ent);
|
pr_global_struct->other = EDICT_TO_PROG(sv_player);
|
||||||
pr_global_struct->other = EDICT_TO_PROG(sv_player);
|
PR_ExecuteProgram (ent->v.touch);
|
||||||
PR_ExecuteProgram (ent->v.touch);
|
playertouch[n/8] |= 1 << (n%8);
|
||||||
playertouch[n/8] |= 1 << (n%8);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1650,15 +1677,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