mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Net fuzzing
This commit is contained in:
parent
fa13e7d5bf
commit
3031dccfa2
3 changed files with 27 additions and 11 deletions
|
|
@ -838,7 +838,7 @@ consvar_t cv_palettenum = PlayerCheat("palettenum", "0").values(CV_Unsigned).onc
|
||||||
extern CV_PossibleValue_t renderhitbox_cons_t[];
|
extern CV_PossibleValue_t renderhitbox_cons_t[];
|
||||||
consvar_t cv_renderhitbox = PlayerCheat("renderhitbox", "Off").values(renderhitbox_cons_t).description("Show hitboxes around objects");
|
consvar_t cv_renderhitbox = PlayerCheat("renderhitbox", "Off").values(renderhitbox_cons_t).description("Show hitboxes around objects");
|
||||||
|
|
||||||
consvar_t cv_fuzz = PlayerCheat("fuzz", "Off").on_off().description("Human players spam random inputs, get random items");
|
consvar_t cv_fuzz = OnlineCheat("fuzz", "Off").on_off().description("Human players spam random inputs, get random items");
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dummy variables used solely in the menu system.
|
// Dummy variables used solely in the menu system.
|
||||||
|
|
|
||||||
|
|
@ -5050,6 +5050,27 @@ static char NodeToSplitPlayer(int node, int split)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void FuzzTiccmd(ticcmd_t* target)
|
||||||
|
{
|
||||||
|
extern consvar_t cv_fuzz;
|
||||||
|
if (cv_fuzz.value)
|
||||||
|
{
|
||||||
|
target->forwardmove = P_RandomRange(PR_FUZZ, -MAXPLMOVE, MAXPLMOVE);
|
||||||
|
target->turning = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
|
||||||
|
target->throwdir = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
|
||||||
|
target->buttons = P_RandomRange(PR_FUZZ, 0, 255);
|
||||||
|
|
||||||
|
// Make fuzzed players more likely to do impactful things
|
||||||
|
if (P_RandomRange(PR_FUZZ, 0, 500))
|
||||||
|
{
|
||||||
|
target->buttons |= BT_ACCELERATE;
|
||||||
|
target->buttons &= ~BT_LOOKBACK;
|
||||||
|
target->buttons &= ~BT_RESPAWN;
|
||||||
|
target->buttons &= ~BT_BRAKE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Handles a packet received from a node that is in game
|
/** Handles a packet received from a node that is in game
|
||||||
*
|
*
|
||||||
* \param node The packet sender
|
* \param node The packet sender
|
||||||
|
|
@ -5181,6 +5202,8 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
&& (maketic - firstticstosend < BACKUPTICS))
|
&& (maketic - firstticstosend < BACKUPTICS))
|
||||||
faketic++;
|
faketic++;
|
||||||
|
|
||||||
|
FuzzTiccmd(&netbuffer->u.clientpak.cmd);
|
||||||
|
|
||||||
// Copy ticcmd
|
// Copy ticcmd
|
||||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
||||||
|
|
||||||
|
|
@ -5194,6 +5217,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
|
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
|
||||||
&& (nodetoplayer2[node] >= 0))
|
&& (nodetoplayer2[node] >= 0))
|
||||||
{
|
{
|
||||||
|
FuzzTiccmd(&netbuffer->u.client2pak.cmd2);
|
||||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
||||||
&netbuffer->u.client2pak.cmd2, 1);
|
&netbuffer->u.client2pak.cmd2, 1);
|
||||||
|
|
||||||
|
|
@ -5205,6 +5229,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
|
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
|
||||||
&& (nodetoplayer3[node] >= 0))
|
&& (nodetoplayer3[node] >= 0))
|
||||||
{
|
{
|
||||||
|
FuzzTiccmd(&netbuffer->u.client3pak.cmd3);
|
||||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
|
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
|
||||||
&netbuffer->u.client3pak.cmd3, 1);
|
&netbuffer->u.client3pak.cmd3, 1);
|
||||||
|
|
||||||
|
|
@ -5215,6 +5240,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||||
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
|
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
|
||||||
&& (nodetoplayer4[node] >= 0))
|
&& (nodetoplayer4[node] >= 0))
|
||||||
{
|
{
|
||||||
|
FuzzTiccmd(&netbuffer->u.client4pak.cmd4);
|
||||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
|
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
|
||||||
&netbuffer->u.client4pak.cmd4, 1);
|
&netbuffer->u.client4pak.cmd4, 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@
|
||||||
#include "tables.h"
|
#include "tables.h"
|
||||||
#include "m_random.h" // monkey input
|
#include "m_random.h" // monkey input
|
||||||
|
|
||||||
extern "C" consvar_t cv_fuzz;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -146,14 +144,6 @@ class TiccmdBuilder
|
||||||
cmd->turning = clamp(cmd->turning, KART_FULLTURN);
|
cmd->turning = clamp(cmd->turning, KART_FULLTURN);
|
||||||
cmd->throwdir = clamp(cmd->throwdir, KART_FULLTURN);
|
cmd->throwdir = clamp(cmd->throwdir, KART_FULLTURN);
|
||||||
|
|
||||||
if (cv_fuzz.value)
|
|
||||||
{
|
|
||||||
cmd->forwardmove = P_RandomRange(PR_FUZZ, -MAXPLMOVE, MAXPLMOVE);
|
|
||||||
cmd->turning = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
|
|
||||||
cmd->throwdir = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
|
|
||||||
cmd->buttons = P_RandomRange(PR_FUZZ, 0, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send leveltime when this tic was generated to the server for control lag calculations.
|
// Send leveltime when this tic was generated to the server for control lag calculations.
|
||||||
// Only do this when in a level. Also do this after the hook, so that it can't overwrite this.
|
// Only do this when in a level. Also do this after the hook, so that it can't overwrite this.
|
||||||
cmd->latency = (leveltime & TICCMD_LATENCYMASK);
|
cmd->latency = (leveltime & TICCMD_LATENCYMASK);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue