Skip to content

Commit 19661e1

Browse files
committed
SAFESTRAFE: no more idrive advantage
1 parent 638fbb3 commit 19661e1

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

include/progs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,10 @@ typedef struct gedict_s
995995
int nullStrafeCount;
996996
// SOCD
997997

998+
// Safe strafe enforcement
999+
qbool safestrafePending; // true if player is in forced stop frame
1000+
float pendingStrafeDirection; // direction player wants to move after stop
1001+
9981002
float shownick_time; // used to force centerprint is off at desired time
9991003
clientType_t ct; // client type for client edicts
10001004
// { timing

src/admin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,16 @@ void ToggleFallBunny(void)
909909
cvar_toggle_msg(self, "k_fallbunny", redtext("fallbunny"));
910910
}
911911

912+
void ToggleSafeStrafe(void)
913+
{
914+
if (match_in_progress)
915+
{
916+
return;
917+
}
918+
919+
cvar_toggle_msg(self, "k_safestrafe", redtext("safestrafe"));
920+
}
921+
912922
void sv_lock(void)
913923
{
914924
int lock_time = 15;

src/client.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,10 @@ void ClientConnect(void)
18501850
self->totalPerfectStrafeCount = 0;
18511851
self->nullStrafeCount = 0;
18521852

1853+
// Safe strafe
1854+
self->safestrafePending = false;
1855+
self->pendingStrafeDirection = 0;
1856+
18531857
// ILLEGALFPS[
18541858

18551859
// Zibbo's frametime checking code
@@ -3864,6 +3868,37 @@ void PlayerPreThink(void)
38643868
}
38653869
}
38663870

3871+
// Safe strafe enforcement
3872+
if (cvar("k_safestrafe"))
3873+
{
3874+
float fSideMoveSpeed = self->movement[1];
3875+
3876+
// If we're in a pending stop frame, force stop
3877+
if (self->safestrafePending)
3878+
{
3879+
self->movement[1] = 0; // Force stop
3880+
self->fLastSideMoveSpeed = 0; // Update for SOCD detection
3881+
self->safestrafePending = false;
3882+
3883+
// Next frame will use the pending direction
3884+
// (it will be applied naturally from client input)
3885+
}
3886+
else if (fSideMoveSpeed != 0 && self->fLastSideMoveSpeed != 0)
3887+
{
3888+
// Check if attempting a perfect strafe (instant direction change)
3889+
int currentDir = (fSideMoveSpeed > 0) - (fSideMoveSpeed < 0);
3890+
int lastDir = (self->fLastSideMoveSpeed > 0) - (self->fLastSideMoveSpeed < 0);
3891+
3892+
if (currentDir != lastDir && self->nullStrafeCount < 4)
3893+
{
3894+
// Perfect strafe detected - force a stop frame
3895+
self->safestrafePending = true;
3896+
self->pendingStrafeDirection = fSideMoveSpeed;
3897+
self->movement[1] = 0; // Force stop this frame
3898+
}
3899+
}
3900+
}
3901+
38673902
// ILLEGALFPS[
38683903

38693904
self->fAverageFrameTime += g_globalvars.frametime;

src/commands.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void ToggleSpawnPoints(void);
133133
void ToggleBerzerk(void);
134134
void ToggleSpecTalk(void);
135135
void ToggleSpeed(void);
136+
void ToggleSafeStrafe(void);
136137
void VotePickup(void);
137138
void UserMode(float umode);
138139
void Wp_Reset(void);
@@ -370,6 +371,7 @@ const char CD_NODESC[] = "no desc";
370371
#define CD_TIMEDOWN "-5 mins match time"
371372
#define CD_TIMEUP "+5 mins match time"
372373
#define CD_FALLBUNNY "toggle fallbunny"
374+
#define CD_SAFESTRAFE "toggle safestrafe"
373375
#define CD_FRAGSDOWN "-10 fraglimit"
374376
#define CD_FRAGSUP "+10 fraglimit"
375377
#define CD_KILLQUAD "kill the quad mode"
@@ -735,6 +737,7 @@ cmd_t cmds[] =
735737
{ "timedown", DEF(TimeDown), 5.0f, CF_PLAYER | CF_SPC_ADMIN, CD_TIMEDOWN },
736738
{ "timeup", DEF(TimeUp), 5.0f, CF_PLAYER | CF_SPC_ADMIN, CD_TIMEUP },
737739
{ "fallbunny", ToggleFallBunny, 0, CF_PLAYER | CF_SPC_ADMIN, CD_FALLBUNNY },
740+
{ "safestrafe", ToggleSafeStrafe, 0, CF_PLAYER | CF_SPC_ADMIN, CD_SAFESTRAFE },
738741
{ "fragsdown", FragsDown, 0, CF_PLAYER | CF_SPC_ADMIN, CD_FRAGSDOWN },
739742
{ "fragsup", FragsUp, 0, CF_PLAYER | CF_SPC_ADMIN, CD_FRAGSUP },
740743
{ "killquad", killquad, 0, CF_PLAYER | CF_SPC_ADMIN, CD_KILLQUAD },

src/world.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ void FirstFrame(void)
10091009
RegisterCvar("k_teamoverlay"); // q3 like team overlay
10101010

10111011
RegisterCvar("k_allow_socd_warning"); // socd
1012+
RegisterCvarEx("k_safestrafe", "1"); // prevent perfect strafes
10121013

10131014
// { SP
10141015
RegisterCvarEx("k_monster_spawn_time", "20");

0 commit comments

Comments
 (0)