Skip to content

Commit 957c2bd

Browse files
committed
SAFESTRAFE: no more idrive advantage
1 parent 638fbb3 commit 957c2bd

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,32 @@ void ToggleFallBunny(void)
909909
cvar_toggle_msg(self, "k_fallbunny", redtext("fallbunny"));
910910
}
911911

912+
void ToggleSafeStrafe(void)
913+
{
914+
int sv_safestrafe = bound(0, cvar("sv_safestrafe"), 1);
915+
916+
if (match_in_progress)
917+
{
918+
return;
919+
}
920+
921+
if (++sv_safestrafe > 1)
922+
{
923+
sv_safestrafe = 0;
924+
}
925+
926+
if (sv_safestrafe)
927+
{
928+
G_bprint(2, "%s enables %s \n", getname(self), redtext("safestrafe"));
929+
}
930+
else
931+
{
932+
G_bprint(2, "%s disables %s \n", getname(self), redtext("safestrafe"));
933+
}
934+
935+
cvar_fset("sv_safestrafe", sv_safestrafe);
936+
}
937+
912938
void sv_lock(void)
913939
{
914940
int lock_time = 15;

src/client.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,36 @@ void PlayerPreThink(void)
38643864
}
38653865
}
38663866

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

38693899
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 },

0 commit comments

Comments
 (0)