Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOCD detection #354

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ x64/*
*.suobackup
*.VC.db
/.cache
/tools/vs/.vs/
/tools/vs/ktx/x64/
/tools/vs/x64/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just skip these and delete tools/vs in a separate PR

11 changes: 11 additions & 0 deletions include/progs.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,17 @@ typedef struct gedict_s
float fIllegalFPSWarnings;
// ILLEGALFPS]

// SOCD detectioin
float fStrafeChangeCount;
float fFramePerfectStrafeChangeCount;
int socdDetected;
int socdChecksCount;
float fLastSideMoveSpeed;
int matchStrafeChangeCount;
int matchPerfectStrafeCount;
int nullStrafeCount;
// SOCD

float shownick_time; // used to force centerprint is off at desired time
clientType_t ct; // client type for client edicts
// { timing
Expand Down
61 changes: 61 additions & 0 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,16 @@ void ClientConnect()
SendIntermissionToClient();
}

// SOCD
self->socdChecksCount = 0;
self->socdDetected = 0;
self->fStrafeChangeCount = 0;
self->fFramePerfectStrafeChangeCount = 0;
self->fLastSideMoveSpeed = 0;
self->matchStrafeChangeCount = 0;
self->matchPerfectStrafeCount = 0;
self->nullStrafeCount = 0;

// ILLEGALFPS[

// Zibbo's frametime checking code
Expand Down Expand Up @@ -3520,6 +3530,57 @@ void PlayerPreThink()
}
#endif

// SOCD detection
{
float fSideMoveSpeed = self->movement[1];

if ((fSideMoveSpeed != 0) && (fSideMoveSpeed != self->fLastSideMoveSpeed) && (self->nullStrafeCount < 3)) //strafechange
{
self->fStrafeChangeCount += 1;
if (match_in_progress)
self->matchStrafeChangeCount += 1;

if ((fSideMoveSpeed != 0) && (self->fLastSideMoveSpeed != 0))
{
self->fFramePerfectStrafeChangeCount += 1;
if (match_in_progress)
self->matchPerfectStrafeCount += 1;
}

self->nullStrafeCount = 0;
}
else
{
if (0 == fSideMoveSpeed)
self->nullStrafeCount += 1;
else
self->nullStrafeCount = 0;
}

self->fLastSideMoveSpeed = fSideMoveSpeed;

if (self->fStrafeChangeCount >= 16)
{
if (self->fFramePerfectStrafeChangeCount / self->fStrafeChangeCount >= 0.75)
{
int k_allow_socd_warning = cvar("k_allow_socd_warning");

self->socdDetected += 1;

if ((!match_in_progress) && (!self->isBot) && k_allow_socd_warning)
{
G_bprint(PRINT_HIGH,
"Warning! %s: SOCD movement assistance detected. Please disable iDrive or keyboard SOCD features.\n",
self->netname);
}
}

self->socdChecksCount += 1;
self->fStrafeChangeCount = 0;
self->fFramePerfectStrafeChangeCount = 0;
}
}

// ILLEGALFPS[

self->fAverageFrameTime += g_globalvars.frametime;
Expand Down
32 changes: 30 additions & 2 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -8114,16 +8114,44 @@ void fcheck()

if (!is_real_adm(self))
{
if (strneq(arg_x, "f_version") && strneq(arg_x, "f_modified") && strneq(arg_x, "f_server"))
if (strneq(arg_x, "f_version") && strneq(arg_x, "f_modified") && strneq(arg_x, "f_server") && strneq(arg_x, "f_movement"))
{
G_sprint(self, 2, "You are not allowed to check \020%s\021\n"
"available checks are: f_version, f_modified and f_server\n",
"available checks are: f_version, f_modified, f_server and f_movement\n",
arg_x);

return;
}
}

if (streq(arg_x, "f_movement"))
{
G_bprint(2, "%s is checking \020%s\021\n", self->netname, arg_x);

for (i = 1; i <= MAX_CLIENTS; i++)
{
if (!strnull(g_edicts[i].netname))
{
if (g_edicts[i].socdDetected > 0)
{
G_bprint(2, "%s: SOCD movement assistance detected!\n", g_edicts[i].netname);
}
else
{
if (g_edicts[i].socdChecksCount >= 2)
{
G_bprint(2, "%s: no assistance detected.\n", g_edicts[i].netname);
}
else
{
G_bprint(2, "%s: not enough movement to run SOCD detection. Please move around a map.\n", g_edicts[i].netname);
}
}
}
}
return;
}

for (i = 1; i <= MAX_CLIENTS; i++)
{
if (g_edicts[i].f_checkbuf)
Expand Down
8 changes: 8 additions & 0 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,14 @@ void OnePlayerStats(gedict_t *p, int tp)
p->ps.vel_frames > 0 ? p->ps.velocity_sum / p->ps.vel_frames : 0.);
}

if (!p->isBot)
{
G_bprint(2, "%s: %s:%d/%d %s:%d/%d\n", redtext("Movement"), redtext("Perfect strafes"),
p->matchPerfectStrafeCount, p->matchStrafeChangeCount, redtext("SOCD detections"),
p->socdDetected, p->socdChecksCount);
}


// armors + megahealths
if (!lgc_enabled())
{
Expand Down
2 changes: 2 additions & 0 deletions src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ void FirstFrame()

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

RegisterCvar("k_allow_socd_warning"); // socd

// { SP
RegisterCvarEx("k_monster_spawn_time", "20");
// }
Expand Down
34 changes: 26 additions & 8 deletions tools/vs/ktx.vcxproj
Copy link
Collaborator

@dsvensson dsvensson Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof... ought to be deleted instead, but separate PR, Visual Studio can import cmake projects nowadays.

Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>qwprogs.dll</TargetName>
<TargetName>qwprogs</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>qwprogs.dll</TargetName>
<TargetName>qwprogs</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>qwprogs.dll</TargetName>
<TargetName>qwprogs</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>qwprogs.dll</TargetName>
<TargetName>qwprogs</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand All @@ -91,7 +91,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
Expand All @@ -111,7 +111,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
Expand All @@ -131,7 +131,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
Expand All @@ -151,7 +151,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>C:\Users\Toma\source\repos\ktx\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile />
</ClCompile>
<Link>
Expand All @@ -163,6 +163,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\bg_lib.h" />
<ClInclude Include="..\..\include\deathtype.h" />
<ClInclude Include="..\..\include\fb_globals.h" />
<ClInclude Include="..\..\include\g_consts.h" />
Expand All @@ -174,13 +175,23 @@
<ClInclude Include="..\..\include\progdefs.h" />
<ClInclude Include="..\..\include\progs.h" />
<ClInclude Include="..\..\include\q_shared.h" />
<ClInclude Include="..\..\include\rng.h" />
<ClInclude Include="..\..\include\rng_gen_impl.h" />
<ClInclude Include="..\..\include\rng_gen_state.h" />
<ClInclude Include="..\..\include\rng_seed_impl.h" />
<ClInclude Include="..\..\include\stats.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\admin.c" />
<ClCompile Include="..\..\src\arena.c" />
<ClCompile Include="..\..\src\bg_lib.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\bot_aim.c" />
<ClCompile Include="..\..\src\bot_blocked.c" />
<ClCompile Include="..\..\src\bot_botenemy.c" />
Expand Down Expand Up @@ -215,15 +226,19 @@
<ClCompile Include="..\..\src\doors.c" />
<ClCompile Include="..\..\src\fb_globals.c" />
<ClCompile Include="..\..\src\files.c" />
<ClCompile Include="..\..\src\func_bob.c" />
<ClCompile Include="..\..\src\func_laser.c" />
<ClCompile Include="..\..\src\globals.c" />
<ClCompile Include="..\..\src\grapple.c" />
<ClCompile Include="..\..\src\g_cmd.c" />
<ClCompile Include="..\..\src\g_main.c" />
<ClCompile Include="..\..\src\g_mem.c" />
<ClCompile Include="..\..\src\g_spawn.c" />
<ClCompile Include="..\..\src\g_syscalls.c" />
<ClCompile Include="..\..\src\g_syscalls_extra.c" />
<ClCompile Include="..\..\src\g_userinfo.c" />
<ClCompile Include="..\..\src\g_utils.c" />
<ClCompile Include="..\..\src\hiprot.c" />
<ClCompile Include="..\..\src\hoonymode.c" />
<ClCompile Include="..\..\src\items.c" />
<ClCompile Include="..\..\src\logs.c" />
Expand All @@ -244,6 +259,9 @@
<ClCompile Include="..\..\src\player.c" />
<ClCompile Include="..\..\src\q_shared.c" />
<ClCompile Include="..\..\src\race.c" />
<ClCompile Include="..\..\src\rng.c" />
<ClCompile Include="..\..\src\rng_gen_impl.c" />
<ClCompile Include="..\..\src\rng_seed_impl.c" />
<ClCompile Include="..\..\src\route_calc.c" />
<ClCompile Include="..\..\src\route_fields.c" />
<ClCompile Include="..\..\src\route_lookup.c" />
Expand Down