Skip to content

Commit

Permalink
- Move repeated input code algorithm into an inline function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjr4077au committed Jun 6, 2022
1 parent e86899e commit 0359d49
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/core/gameinput.h
Expand Up @@ -21,6 +21,12 @@ inline double getTicrateScale(double const value)
return value / GameTicRate;
}

inline double getPushScale(double const scaleAdjust)
{
return (2. / 9.) * ((scaleAdjust < 1.) ? ((1. - scaleAdjust * 0.5) * 1.5) : (1.));
}



struct PlayerHorizon
{
Expand Down Expand Up @@ -72,7 +78,7 @@ struct PlayerHorizon
if (object.asq16())
{
auto sgn = Sgn(object.asq16());
object -= getscaledhoriz(value, scaleAdjust, &object, push == DBL_MAX ? sgn * (2. / 9.) * (scaleAdjust < 1. ? (1. - scaleAdjust * 0.5) * 1.5 : 1.) : push);
object -= getscaledhoriz(value, scaleAdjust, &object, push == DBL_MAX ? sgn * getPushScale(scaleAdjust) : push);
if (sgn != Sgn(object.asq16())) object = q16horiz(0);
}
}
Expand Down Expand Up @@ -190,7 +196,7 @@ struct PlayerAngle
if (object.asbam())
{
auto sgn = Sgn(object.signedbam());
object -= getscaledangle(value, scaleAdjust, &object, push == DBL_MAX ? sgn * (2. / 9.) * (scaleAdjust < 1. ? (1. - scaleAdjust * 0.5) * 1.5 : 1.) : push);
object -= getscaledangle(value, scaleAdjust, &object, push == DBL_MAX ? sgn * getPushScale(scaleAdjust) : push);
if (sgn != Sgn(object.signedbam())) object = bamang(0);
}
}
Expand Down

0 comments on commit 0359d49

Please sign in to comment.