Skip to content

Commit d676b58

Browse files
authored
Merge pull request #12 from b1az3/al-merge-2
SOCDv2
2 parents 3dcc346 + 39a6203 commit d676b58

File tree

6 files changed

+42
-19
lines changed

6 files changed

+42
-19
lines changed

src/bot_movement.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ void BotSetCommand(gedict_t *self)
498498
}
499499
else
500500
{
501+
float move_scale;
502+
501503
if (jumping && ((int)self->s.v.flags & FL_ONGROUND))
502504
{
503505
BestJumpingDirection(self);
@@ -507,24 +509,30 @@ void BotSetCommand(gedict_t *self)
507509
ApplyPhysics(self);
508510
}
509511

512+
move_scale = sv_maxspeed * 1.25f;
513+
if (move_scale > 400.0f)
514+
{
515+
move_scale = 400.0f;
516+
}
517+
510518
if (self->s.v.waterlevel <= 1)
511519
{
512520
vec3_t hor;
513521

514522
VectorCopy(self->fb.dir_move_, hor);
515523
hor[2] = 0;
516524
VectorNormalize(hor);
517-
VectorScale(hor, 800, hor);
525+
VectorScale(hor, move_scale, hor);
518526

519527
direction[0] = DotProduct(g_globalvars.v_forward, hor);
520528
direction[1] = DotProduct(g_globalvars.v_right, hor);
521529
direction[2] = 0;
522530
}
523531
else
524532
{
525-
direction[0] = DotProduct (g_globalvars.v_forward, self->fb.dir_move_) * 800;
526-
direction[1] = DotProduct (g_globalvars.v_right, self->fb.dir_move_) * 800;
527-
direction[2] = DotProduct (g_globalvars.v_up, self->fb.dir_move_) * 800;
533+
direction[0] = DotProduct (g_globalvars.v_forward, self->fb.dir_move_) * move_scale;
534+
direction[1] = DotProduct (g_globalvars.v_right, self->fb.dir_move_) * move_scale;
535+
direction[2] = DotProduct (g_globalvars.v_up, self->fb.dir_move_) * move_scale;
528536
}
529537

530538
#ifdef DEBUG_MOVEMENT

src/client.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ void ClientConnect(void)
18381838
SendIntermissionToClient();
18391839
}
18401840

1841-
// SOCD
1841+
// SOCD
18421842
self->socdValidationCount = 0;
18431843
self->socdDetectionCount = 0;
18441844
self->fStrafeChangeCount = 0;
@@ -3867,11 +3867,11 @@ void PlayerPreThink(void)
38673867

38683868
self->socdDetectionCount += 1;
38693869
if ((!match_in_progress) && (!self->isBot) && k_allow_socd_warning && (self->ct == ctPlayer) && (self->socdDetectionCount >= 2))
3870-
{
3871-
G_bprint(PRINT_HIGH,
3872-
"[%s] Warning! %s: Movement assistance detected. Please disable iDrive or keyboard strafe assistance features.\n",
3873-
SOCD_DETECTION_VERSION, self->netname);
3874-
}
3870+
{
3871+
G_bprint(PRINT_HIGH,
3872+
"[%s] Warning! %s: Movement assistance detected. Please disable iDrive or keyboard strafe assistance features.\n",
3873+
SOCD_DETECTION_VERSION, self->netname);
3874+
}
38753875
}
38763876

38773877
self->socdValidationCount += 1;

src/commands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8436,8 +8436,8 @@ void fcheck(void)
84368436
if ((p->ct == ctPlayer) && (!p->isBot))
84378437
{
84388438
G_bprint(2, "[%s] %s: %s:%.1f%% (%d/%d) %s:%d/%d%s\n", SOCD_DETECTION_VERSION, p->netname, redtext("Perfect strafes"),
8439-
p->matchStrafeChangeCount > 0 ? 100.0 * p->matchPerfectStrafeCount / p->matchStrafeChangeCount : 0.0,
8440-
p->matchPerfectStrafeCount, p->matchStrafeChangeCount, redtext("SOCD detections"),
8439+
p->totalStrafeChangeCount > 0 ? 100.0 * p->totalPerfectStrafeCount / p->totalStrafeChangeCount : 0.0,
8440+
p->totalPerfectStrafeCount, p->totalStrafeChangeCount, redtext("SOCD detections"),
84418441
p->socdDetectionCount, p->socdValidationCount,
84428442
socd_movement_assisted(p) ? ". SOCD movement assistance detected!" : "");
84438443
}

src/g_utils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,8 +2844,8 @@ char* make_dots(char *dots, size_t dots_len, int cmd_max_len, char *cmd)
28442844
int len = cmd_max_len - strlen(cmd);
28452845
len = bound(0, len, dots_len - 1);
28462846
memset((void*) dots, (int)'.', len);
2847-
dots[len] = 0;
2848-
return dots;
2847+
dots[len] = 0;
2848+
return dots;
28492849
}
28502850

28512851
qbool socd_movement_assisted(gedict_t *p)
@@ -2854,17 +2854,17 @@ qbool socd_movement_assisted(gedict_t *p)
28542854
{
28552855
return false;
28562856
}
2857-
2857+
28582858
if ((float)p->totalPerfectStrafeCount / p->totalStrafeChangeCount > 0.58f)
28592859
{
28602860
return true;
28612861
}
2862-
2862+
28632863
if (p->socdValidationCount > 0 &&
28642864
((float)p->socdDetectionCount / p->socdValidationCount) >= 0.10f)
28652865
{
28662866
return true;
28672867
}
2868-
2868+
28692869
return false;
28702870
}

src/match.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ void HideSpawnPoints(void);
11611161
void StartMatch(void)
11621162
{
11631163
char date[64];
1164+
gedict_t *p;
11641165

11651166
// reset bloodfest vars.
11661167
bloodfest_reset();
@@ -1202,6 +1203,20 @@ void StartMatch(void)
12021203

12031204
SM_PrepareClients(); // put clients in server and reset some params
12041205

1206+
for (p = world; (p = find_client(p));)
1207+
{
1208+
p->socdDetectionCount = 0;
1209+
p->socdValidationCount = 0;
1210+
p->fStrafeChangeCount = 0;
1211+
p->fFramePerfectStrafeChangeCount = 0;
1212+
p->fLastSideMoveSpeed = 0;
1213+
p->matchStrafeChangeCount = 0;
1214+
p->matchPerfectStrafeCount = 0;
1215+
p->totalStrafeChangeCount = 0;
1216+
p->totalPerfectStrafeCount = 0;
1217+
p->nullStrafeCount = 0;
1218+
}
1219+
12051220
if (!QVMstrftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S %Z", 0))
12061221
{
12071222
date[0] = 0;

src/stats.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,11 @@ void OnePlayerStats(gedict_t *p, int tp)
766766
// movement
767767
if (!p->isBot)
768768
{
769-
G_bprint(2, "[%s] %s: %s:%.1f%% (%d/%d) %s:%d/%d%s\n", SOCD_DETECTION_VERSION, redtext("Movement"), redtext("Perfect strafes"),
769+
G_bprint(2, "%s: %s:%.1f%% (%d/%d) %s:%d/%d%s [%s]\n", redtext("Movement"), redtext("Perfect strafes"),
770770
p->matchStrafeChangeCount > 0 ? 100.0 * p->matchPerfectStrafeCount / p->matchStrafeChangeCount : 0.0,
771771
p->matchPerfectStrafeCount, p->matchStrafeChangeCount, redtext("SOCD detections"),
772772
p->socdDetectionCount, p->socdValidationCount,
773-
socd_movement_assisted(p) ? ". SOCD movement assistance detected!" : "");
773+
socd_movement_assisted(p) ? ". SOCD movement assistance detected!" : "", SOCD_DETECTION_VERSION);
774774
}
775775

776776

0 commit comments

Comments
 (0)