mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- Do some small tidying up in gameinput.cpp
and change how some constants are stored.
This commit is contained in:
parent
1906491129
commit
ea17352aea
1 changed files with 31 additions and 18 deletions
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
|
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
|
||||||
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
|
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// code fron gameexec/conrun
|
// code fron gameexec/conrun
|
||||||
|
@ -148,6 +149,7 @@ void resetTurnHeldAmt()
|
||||||
turnheldtime = 0;
|
turnheldtime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
||||||
|
@ -177,12 +179,10 @@ SW: 3 * 1.40625 * 40 = 168.75; // Precisely, ((((3 * 12) + ((3 * 12) / 4)) * 3
|
||||||
Average: 234.375;
|
Average: 234.375;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum
|
static constexpr double RUNNINGTURNBASE = 1548.75;
|
||||||
{
|
static constexpr double NORMALTURNBASE = 890.625;
|
||||||
RUNNINGTURNBASE = 1549,
|
static constexpr double PREAMBLEBASE = 234.375;
|
||||||
NORMALTURNBASE = 891,
|
static constexpr double PREAMBLESCALE = PREAMBLEBASE / NORMALTURNBASE;
|
||||||
PREAMBLEBASE = 234,
|
|
||||||
};
|
|
||||||
|
|
||||||
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
|
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
|
||||||
{
|
{
|
||||||
|
@ -195,14 +195,14 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
|
||||||
|
|
||||||
// process mouse and initial controller input.
|
// process mouse and initial controller input.
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
|
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
|
||||||
currInput->svel -= xs_CRoundToInt(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
|
currInput->svel -= int16_t(((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove)) * hidprescale);
|
||||||
else
|
else
|
||||||
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale));
|
currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale));
|
||||||
|
|
||||||
if (!(inputBuffer->actions & SB_AIMMODE))
|
if (!(inputBuffer->actions & SB_AIMMODE))
|
||||||
currInput->horz -= hidInput->mouseturny;
|
currInput->horz -= hidInput->mouseturny;
|
||||||
else
|
else
|
||||||
currInput->fvel -= xs_CRoundToInt(hidInput->mousemovey * mousevelscale * hidprescale);
|
currInput->fvel -= int16_t(hidInput->mousemovey * mousevelscale * hidprescale);
|
||||||
|
|
||||||
if (invertmouse)
|
if (invertmouse)
|
||||||
currInput->horz = -currInput->horz;
|
currInput->horz = -currInput->horz;
|
||||||
|
@ -212,8 +212,8 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
|
||||||
|
|
||||||
// process remaining controller input.
|
// process remaining controller input.
|
||||||
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
|
currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed);
|
||||||
currInput->svel += xs_CRoundToInt(scaleAdjust * hidInput->dx * keymove * hidprescale);
|
currInput->svel += int16_t(scaleAdjust * hidInput->dx * keymove * hidprescale);
|
||||||
currInput->fvel += xs_CRoundToInt(scaleAdjust * hidInput->dz * keymove * hidprescale);
|
currInput->fvel += int16_t(scaleAdjust * hidInput->dz * keymove * hidprescale);
|
||||||
|
|
||||||
// process keyboard turning keys.
|
// process keyboard turning keys.
|
||||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
|
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
|
||||||
|
@ -235,7 +235,7 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
|
||||||
if (turnleft || turnright)
|
if (turnleft || turnright)
|
||||||
{
|
{
|
||||||
updateTurnHeldAmt(scaleAdjust);
|
updateTurnHeldAmt(scaleAdjust);
|
||||||
float const turnamount = float(scaleAdjust * hidspeed * turnscale * (isTurboTurnTime() ? 1. : double(PREAMBLEBASE) / double(NORMALTURNBASE)));
|
float const turnamount = float(scaleAdjust * hidspeed * turnscale * (isTurboTurnTime() ? 1. : PREAMBLESCALE));
|
||||||
|
|
||||||
if (turnleft)
|
if (turnleft)
|
||||||
currInput->avel -= turnamount;
|
currInput->avel -= turnamount;
|
||||||
|
@ -323,7 +323,7 @@ enum
|
||||||
|
|
||||||
void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
|
void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
// Process only if movewment isn't locked.
|
// Process only if movement isn't locked.
|
||||||
if (!movementlocked())
|
if (!movementlocked())
|
||||||
{
|
{
|
||||||
// Test if we have input to process.
|
// Test if we have input to process.
|
||||||
|
@ -374,6 +374,7 @@ void PlayerHorizon::applyinput(float const horz, ESyncBits* actions, double cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
|
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
|
||||||
|
@ -401,9 +402,11 @@ Blood: 128 * 30 = 3840;
|
||||||
Blood: 64 * 30 = 1920;
|
Blood: 64 * 30 = 1920;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static constexpr double ROTRETURNSPEED = (1. / 2.) * 30.;
|
||||||
|
static constexpr double LOOKRETURNSPEED = (1. / 4.) * 30.;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
LOOKROTRETBASE = 15,
|
|
||||||
ROTATESPEED = 720,
|
ROTATESPEED = 720,
|
||||||
LOOKINGSPEED = 4560,
|
LOOKINGSPEED = 4560,
|
||||||
SPINSTAND = 3840,
|
SPINSTAND = 3840,
|
||||||
|
@ -413,8 +416,8 @@ enum
|
||||||
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
|
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
// Process angle return to zeros.
|
// Process angle return to zeros.
|
||||||
scaletozero(rotscrnang, LOOKROTRETBASE, scaleAdjust);
|
scaletozero(rotscrnang, ROTRETURNSPEED, scaleAdjust);
|
||||||
scaletozero(look_ang, +LOOKROTRETBASE * 0.5, scaleAdjust);
|
scaletozero(look_ang, LOOKRETURNSPEED, scaleAdjust);
|
||||||
|
|
||||||
// Process keyboard input.
|
// Process keyboard input.
|
||||||
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
|
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
|
||||||
|
@ -466,6 +469,7 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Player's slope tilt when playing without a mouse and on a slope.
|
// Player's slope tilt when playing without a mouse and on a slope.
|
||||||
|
@ -479,6 +483,8 @@ SW: (1 / 8) * 40 = 5;
|
||||||
Average: 4.375;
|
Average: 4.375;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static constexpr double HORIZOFFSPEED = (1. / 8.) * 35.;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// Values used by Duke/SW, where this function originated from.
|
// Values used by Duke/SW, where this function originated from.
|
||||||
|
@ -518,7 +524,7 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
|
||||||
// accordingly
|
// accordingly
|
||||||
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, x, y) - k) <= (4 << 8)))
|
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, x, y) - k) <= (4 << 8)))
|
||||||
{
|
{
|
||||||
horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
|
horizoff += q16horiz(fixed_t(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,16 +532,23 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
|
||||||
if (climbing)
|
if (climbing)
|
||||||
{
|
{
|
||||||
// tilt when climbing but you can't even really tell it.
|
// tilt when climbing but you can't even really tell it.
|
||||||
if (horizoff.asq16() < IntToFixed(100)) horizoff += getscaledhoriz(4.375, scaleAdjust, buildhoriz(100) - horizoff, 1.);
|
if (horizoff.asq16() < IntToFixed(100)) horizoff += getscaledhoriz(HORIZOFFSPEED, scaleAdjust, buildhoriz(100) - horizoff, 1.);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
||||||
scaletozero(horizoff, 4.375, scaleAdjust, Sgn(horizoff.asq16()));
|
scaletozero(horizoff, HORIZOFFSPEED, scaleAdjust, Sgn(horizoff.asq16()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
|
||||||
{
|
{
|
||||||
if (arc.BeginObject(keyname))
|
if (arc.BeginObject(keyname))
|
||||||
|
|
Loading…
Reference in a new issue