Skip to content

Commit 2e2b7a2

Browse files
authored
Merge pull request #1 from b1az3/socd-detection
SOCD detection
2 parents 8a9caca + 631b375 commit 2e2b7a2

File tree

7 files changed

+141
-10
lines changed

7 files changed

+141
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ x64/*
3131
*.suobackup
3232
*.VC.db
3333
/.cache
34+
/tools/vs/.vs/
35+
/tools/vs/ktx/x64/
36+
/tools/vs/x64/

include/progs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,17 @@ typedef struct gedict_s
944944
float fIllegalFPSWarnings;
945945
// ILLEGALFPS]
946946

947+
// SOCD detectioin
948+
float fStrafeChangeCount;
949+
float fFramePerfectStrafeChangeCount;
950+
int socdDetected;
951+
int socdChecksCount;
952+
float fLastSideMoveSpeed;
953+
int matchStrafeChangeCount;
954+
int matchPerfectStrafeCount;
955+
int nullStrafeCount;
956+
// SOCD
957+
947958
float shownick_time; // used to force centerprint is off at desired time
948959
clientType_t ct; // client type for client edicts
949960
// { timing

src/client.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,16 @@ void ClientConnect()
16581658
SendIntermissionToClient();
16591659
}
16601660

1661+
// SOCD
1662+
self->socdChecksCount = 0;
1663+
self->socdDetected = 0;
1664+
self->fStrafeChangeCount = 0;
1665+
self->fFramePerfectStrafeChangeCount = 0;
1666+
self->fLastSideMoveSpeed = 0;
1667+
self->matchStrafeChangeCount = 0;
1668+
self->matchPerfectStrafeCount = 0;
1669+
self->nullStrafeCount = 0;
1670+
16611671
// ILLEGALFPS[
16621672

16631673
// Zibbo's frametime checking code
@@ -3520,6 +3530,57 @@ void PlayerPreThink()
35203530
}
35213531
#endif
35223532

3533+
// SOCD detection
3534+
{
3535+
float fSideMoveSpeed = self->movement[1];
3536+
3537+
if ((fSideMoveSpeed != 0) && (fSideMoveSpeed != self->fLastSideMoveSpeed) && (self->nullStrafeCount < 3)) //strafechange
3538+
{
3539+
self->fStrafeChangeCount += 1;
3540+
if (match_in_progress)
3541+
self->matchStrafeChangeCount += 1;
3542+
3543+
if ((fSideMoveSpeed != 0) && (self->fLastSideMoveSpeed != 0))
3544+
{
3545+
self->fFramePerfectStrafeChangeCount += 1;
3546+
if (match_in_progress)
3547+
self->matchPerfectStrafeCount += 1;
3548+
}
3549+
3550+
self->nullStrafeCount = 0;
3551+
}
3552+
else
3553+
{
3554+
if (0 == fSideMoveSpeed)
3555+
self->nullStrafeCount += 1;
3556+
else
3557+
self->nullStrafeCount = 0;
3558+
}
3559+
3560+
self->fLastSideMoveSpeed = fSideMoveSpeed;
3561+
3562+
if (self->fStrafeChangeCount >= 16)
3563+
{
3564+
if (self->fFramePerfectStrafeChangeCount / self->fStrafeChangeCount >= 0.75)
3565+
{
3566+
int k_allow_socd_warning = cvar("k_allow_socd_warning");
3567+
3568+
self->socdDetected += 1;
3569+
3570+
if ((!match_in_progress) && (!self->isBot) && k_allow_socd_warning)
3571+
{
3572+
G_bprint(PRINT_HIGH,
3573+
"Warning! %s: SOCD movement assistance detected. Please disable iDrive or keyboard SOCD features.\n",
3574+
self->netname);
3575+
}
3576+
}
3577+
3578+
self->socdChecksCount += 1;
3579+
self->fStrafeChangeCount = 0;
3580+
self->fFramePerfectStrafeChangeCount = 0;
3581+
}
3582+
}
3583+
35233584
// ILLEGALFPS[
35243585

35253586
self->fAverageFrameTime += g_globalvars.frametime;

src/commands.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8114,16 +8114,44 @@ void fcheck()
81148114

81158115
if (!is_real_adm(self))
81168116
{
8117-
if (strneq(arg_x, "f_version") && strneq(arg_x, "f_modified") && strneq(arg_x, "f_server"))
8117+
if (strneq(arg_x, "f_version") && strneq(arg_x, "f_modified") && strneq(arg_x, "f_server") && strneq(arg_x, "f_movement"))
81188118
{
81198119
G_sprint(self, 2, "You are not allowed to check \020%s\021\n"
8120-
"available checks are: f_version, f_modified and f_server\n",
8120+
"available checks are: f_version, f_modified, f_server and f_movement\n",
81218121
arg_x);
81228122

81238123
return;
81248124
}
81258125
}
81268126

8127+
if (streq(arg_x, "f_movement"))
8128+
{
8129+
G_bprint(2, "%s is checking \020%s\021\n", self->netname, arg_x);
8130+
8131+
for (i = 1; i <= MAX_CLIENTS; i++)
8132+
{
8133+
if (!strnull(g_edicts[i].netname))
8134+
{
8135+
if (g_edicts[i].socdDetected > 0)
8136+
{
8137+
G_bprint(2, "%s: SOCD movement assistance detected!\n", g_edicts[i].netname);
8138+
}
8139+
else
8140+
{
8141+
if (g_edicts[i].socdChecksCount >= 2)
8142+
{
8143+
G_bprint(2, "%s: no assistance detected.\n", g_edicts[i].netname);
8144+
}
8145+
else
8146+
{
8147+
G_bprint(2, "%s: not enough movement to run SOCD detection. Please move around a map.\n", g_edicts[i].netname);
8148+
}
8149+
}
8150+
}
8151+
}
8152+
return;
8153+
}
8154+
81278155
for (i = 1; i <= MAX_CLIENTS; i++)
81288156
{
81298157
if (g_edicts[i].f_checkbuf)

src/stats.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,14 @@ void OnePlayerStats(gedict_t *p, int tp)
763763
p->ps.vel_frames > 0 ? p->ps.velocity_sum / p->ps.vel_frames : 0.);
764764
}
765765

766+
if (!p->isBot)
767+
{
768+
G_bprint(2, "%s: %s:%d/%d %s:%d/%d\n", redtext("Movement"), redtext("Perfect strafes"),
769+
p->matchPerfectStrafeCount, p->matchStrafeChangeCount, redtext("SOCD detections"),
770+
p->socdDetected, p->socdChecksCount);
771+
}
772+
773+
766774
// armors + megahealths
767775
if (!lgc_enabled())
768776
{

src/world.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,8 @@ void FirstFrame()
10001000

10011001
RegisterCvar("k_teamoverlay"); // q3 like team overlay
10021002

1003+
RegisterCvar("k_allow_socd_warning"); // socd
1004+
10031005
// { SP
10041006
RegisterCvarEx("k_monster_spawn_time", "20");
10051007
// }

tools/vs/ktx.vcxproj

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@
7171
</ImportGroup>
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74-
<TargetName>qwprogs.dll</TargetName>
74+
<TargetName>qwprogs</TargetName>
7575
</PropertyGroup>
7676
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
77-
<TargetName>qwprogs.dll</TargetName>
77+
<TargetName>qwprogs</TargetName>
7878
</PropertyGroup>
7979
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80-
<TargetName>qwprogs.dll</TargetName>
80+
<TargetName>qwprogs</TargetName>
8181
</PropertyGroup>
8282
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
83-
<TargetName>qwprogs.dll</TargetName>
83+
<TargetName>qwprogs</TargetName>
8484
</PropertyGroup>
8585
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8686
<ClCompile>
@@ -91,7 +91,7 @@
9191
<PrecompiledHeader>NotUsing</PrecompiledHeader>
9292
<PrecompiledHeaderFile>
9393
</PrecompiledHeaderFile>
94-
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
94+
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9595
<PrecompiledHeaderOutputFile />
9696
</ClCompile>
9797
<Link>
@@ -111,7 +111,7 @@
111111
<PrecompiledHeader>NotUsing</PrecompiledHeader>
112112
<PrecompiledHeaderFile>
113113
</PrecompiledHeaderFile>
114-
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
114+
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
115115
<PrecompiledHeaderOutputFile />
116116
</ClCompile>
117117
<Link>
@@ -131,7 +131,7 @@
131131
<PrecompiledHeader>NotUsing</PrecompiledHeader>
132132
<PrecompiledHeaderFile>
133133
</PrecompiledHeaderFile>
134-
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
134+
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
135135
<PrecompiledHeaderOutputFile />
136136
</ClCompile>
137137
<Link>
@@ -151,7 +151,7 @@
151151
<PrecompiledHeader>NotUsing</PrecompiledHeader>
152152
<PrecompiledHeaderFile>
153153
</PrecompiledHeaderFile>
154-
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
154+
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
155155
<PrecompiledHeaderOutputFile />
156156
</ClCompile>
157157
<Link>
@@ -163,6 +163,7 @@
163163
</Link>
164164
</ItemDefinitionGroup>
165165
<ItemGroup>
166+
<ClInclude Include="..\..\include\bg_lib.h" />
166167
<ClInclude Include="..\..\include\deathtype.h" />
167168
<ClInclude Include="..\..\include\fb_globals.h" />
168169
<ClInclude Include="..\..\include\g_consts.h" />
@@ -174,13 +175,23 @@
174175
<ClInclude Include="..\..\include\progdefs.h" />
175176
<ClInclude Include="..\..\include\progs.h" />
176177
<ClInclude Include="..\..\include\q_shared.h" />
178+
<ClInclude Include="..\..\include\rng.h" />
179+
<ClInclude Include="..\..\include\rng_gen_impl.h" />
180+
<ClInclude Include="..\..\include\rng_gen_state.h" />
181+
<ClInclude Include="..\..\include\rng_seed_impl.h" />
177182
<ClInclude Include="..\..\include\stats.h" />
178183
<ClInclude Include="framework.h" />
179184
<ClInclude Include="pch.h" />
180185
</ItemGroup>
181186
<ItemGroup>
182187
<ClCompile Include="..\..\src\admin.c" />
183188
<ClCompile Include="..\..\src\arena.c" />
189+
<ClCompile Include="..\..\src\bg_lib.c">
190+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
191+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
192+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
193+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
194+
</ClCompile>
184195
<ClCompile Include="..\..\src\bot_aim.c" />
185196
<ClCompile Include="..\..\src\bot_blocked.c" />
186197
<ClCompile Include="..\..\src\bot_botenemy.c" />
@@ -215,15 +226,19 @@
215226
<ClCompile Include="..\..\src\doors.c" />
216227
<ClCompile Include="..\..\src\fb_globals.c" />
217228
<ClCompile Include="..\..\src\files.c" />
229+
<ClCompile Include="..\..\src\func_bob.c" />
230+
<ClCompile Include="..\..\src\func_laser.c" />
218231
<ClCompile Include="..\..\src\globals.c" />
219232
<ClCompile Include="..\..\src\grapple.c" />
220233
<ClCompile Include="..\..\src\g_cmd.c" />
221234
<ClCompile Include="..\..\src\g_main.c" />
222235
<ClCompile Include="..\..\src\g_mem.c" />
223236
<ClCompile Include="..\..\src\g_spawn.c" />
224237
<ClCompile Include="..\..\src\g_syscalls.c" />
238+
<ClCompile Include="..\..\src\g_syscalls_extra.c" />
225239
<ClCompile Include="..\..\src\g_userinfo.c" />
226240
<ClCompile Include="..\..\src\g_utils.c" />
241+
<ClCompile Include="..\..\src\hiprot.c" />
227242
<ClCompile Include="..\..\src\hoonymode.c" />
228243
<ClCompile Include="..\..\src\items.c" />
229244
<ClCompile Include="..\..\src\logs.c" />
@@ -244,6 +259,9 @@
244259
<ClCompile Include="..\..\src\player.c" />
245260
<ClCompile Include="..\..\src\q_shared.c" />
246261
<ClCompile Include="..\..\src\race.c" />
262+
<ClCompile Include="..\..\src\rng.c" />
263+
<ClCompile Include="..\..\src\rng_gen_impl.c" />
264+
<ClCompile Include="..\..\src\rng_seed_impl.c" />
247265
<ClCompile Include="..\..\src\route_calc.c" />
248266
<ClCompile Include="..\..\src\route_fields.c" />
249267
<ClCompile Include="..\..\src\route_lookup.c" />

0 commit comments

Comments
 (0)