Skip to content

Commit 32b29a3

Browse files
authored
Merge pull request #291 from taysta/shelper-fix
Strafehelper Fixup
2 parents d5aa0d6 + d007aac commit 32b29a3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

codemp/cgame/hud_strafehelper.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void DF_DrawStrafeHUD(centity_t* cent)
354354
//main strafehelper function, sets states and then calls drawstrafeline function for each keypress
355355
void DF_StrafeHelper() {
356356
qboolean checkForW = state.m_iVehicleNum ?
357-
(qboolean)state.moveDir == KEY_W :
357+
(qboolean)(state.moveDir == KEY_W) :
358358
(qboolean)(state.moveDir == KEY_W || state.moveDir == KEY_WA || state.moveDir == KEY_DW);
359359
//set strafehelper settings struct
360360
DF_SetStrafeHelper(); //state.strafehelper.
@@ -529,7 +529,7 @@ int DF_SetPlayerState(centity_t* cent)
529529
{
530530
state.moveStyle = DF_GetMovePhysics();
531531
state.m_iVehicleNum = cg.predictedPlayerState.m_iVehicleNum;
532-
state.onGround = (qboolean)cent->currentState.groundEntityNum == ENTITYNUM_WORLD;
532+
state.onGround = (qboolean)(cent->currentState.groundEntityNum == ENTITYNUM_WORLD);
533533
state.groundEntityNum = cent->currentState.groundEntityNum;
534534

535535
if(state.m_iVehicleNum) {
@@ -692,6 +692,9 @@ void DF_SetFrameTime() {
692692
else {
693693
frameTime = 1.0f / cg_strafeHelper_FPS.value;
694694
}
695+
if (frameTime <= 0.0f) {
696+
frameTime = 0.001f; //1ms floor, equivalent to 1000fps cap
697+
}
695698
state.cgaz.frametime = frameTime;
696699
}
697700

@@ -848,10 +851,10 @@ dfsline DF_GetLine(int moveDir, const qboolean rear, const int gazLine, const qb
848851
}
849852

850853
//Here we do some checks that determine the moveDir line should be drawn
851-
if(DF_CenterOnly() == qtrue && moveDir == KEY_CENTER
852-
|| DF_CenterOnly() == qfalse && moveDir != KEY_CENTER
853-
|| state.strafeHelper.rear && moveDir == KEY_S
854-
|| state.physics.hasAirControl)
854+
if((DF_CenterOnly() == qtrue && moveDir == KEY_CENTER)
855+
|| (DF_CenterOnly() == qfalse && moveDir != KEY_CENTER)
856+
|| (state.strafeHelper.rear && moveDir == KEY_S)
857+
|| (state.physics.hasAirControl))
855858
{
856859
draw = qtrue;
857860
}
@@ -1405,7 +1408,6 @@ void DF_DrawStrafehelperWeze(const int moveDir) {
14051408
const float g_speed = state.speed;
14061409
float accel = g_speed;
14071410
accel *= state.cgaz.frametime;
1408-
accel /= 1000;
14091411
float optiangle = (g_speed - accel) / length;
14101412
if (optiangle <= 1 && optiangle >= -1)
14111413
optiangle = acosf(optiangle);
@@ -1502,7 +1504,7 @@ void DF_DrawZone(const float start, const float end) {
15021504
}
15031505

15041506
void CG_AddSpeedGraphFrameInfo(void) { //CG_DrawSpeedGraph
1505-
speedgraph.frameSamples[speedgraph.frameCount & SPEED_SAMPLES - 1] = (int)state.cgaz.v;
1507+
speedgraph.frameSamples[speedgraph.frameCount & (SPEED_SAMPLES - 1)] = (int)state.cgaz.v;
15061508
speedgraph.frameCount++;
15071509
}
15081510

@@ -1629,7 +1631,7 @@ void DF_DrawSpeedGraphOld(void) {
16291631
const float vscale = range / 3000;
16301632

16311633
for (int a = 0; a < aw; a++) {
1632-
const int i = speedgraph.frameCount - 1 - a & SPEED_SAMPLES - 1;
1634+
const int i = (speedgraph.frameCount - 1 - a) & (SPEED_SAMPLES - 1);
16331635
float v = (float) speedgraph.frameSamples[i];
16341636
if (v > 0) {
16351637
trap->R_SetColor(g_color_table[ColorIndex(COLOR_GREEN)]);
@@ -1925,7 +1927,7 @@ japro - Draw the speedometer
19251927
jumpsCounter = 0;
19261928
clearOnNextJump = qfalse;
19271929
}
1928-
cg.lastGroundSpeeds[++jumpsCounter] = cg.lastGroundSpeed; //add last ground speed to the array
1930+
cg.lastGroundSpeeds[jumpsCounter++] = cg.lastGroundSpeed; //add last ground speed to the array
19291931
}
19301932
}
19311933

@@ -2031,10 +2033,10 @@ qboolean DF_IsSlickSurf(void) {
20312033
down[2] -= 128;
20322034
CG_Trace(&tr, state.viewOrg, NULL, NULL, down, state.clientnum, MASK_SOLID);
20332035

2034-
if (state.groundEntityNum == ENTITYNUM_WORLD && tr.surfaceFlags & SURF_SLICK
2035-
|| state.moveStyle == MV_SLICK && !(state.cmd.buttons & BUTTON_WALKING)
2036-
|| state.moveStyle == MV_TRIBES && state.cmd.buttons & BUTTON_WALKING
2037-
|| cg.predictedPlayerState.pm_flags & PMF_TIME_KNOCKBACK)
2036+
if ((state.groundEntityNum == ENTITYNUM_WORLD && tr.surfaceFlags & SURF_SLICK)
2037+
|| (state.moveStyle == MV_SLICK && !(state.cmd.buttons & BUTTON_WALKING))
2038+
|| (state.moveStyle == MV_TRIBES && (state.cmd.buttons & BUTTON_WALKING))
2039+
|| (cg.predictedPlayerState.pm_flags & PMF_TIME_KNOCKBACK))
20382040
onSlick = qtrue;
20392041

20402042
return onSlick;

0 commit comments

Comments
 (0)