mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- PlayerHorizon: Change struct functions to declarations and define code in gamecontrol.cpp to reduce binary size.
This commit is contained in:
parent
6a30d6880e
commit
0c55a533be
2 changed files with 80 additions and 66 deletions
|
@ -1436,6 +1436,79 @@ fixed_t getincangleq16(fixed_t a, fixed_t na)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PlayerHorizon struct functions.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void PlayerHorizon::backup()
|
||||
{
|
||||
ohoriz = horiz;
|
||||
ohorizoff = horizoff;
|
||||
}
|
||||
|
||||
void PlayerHorizon::addadjustment(double value)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
adjustment += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz += q16horiz(FloatToFixed(value));
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerHorizon::resetadjustment()
|
||||
{
|
||||
adjustment = 0;
|
||||
}
|
||||
|
||||
void PlayerHorizon::settarget(double value, bool backup)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
target = FloatToFixed(value);
|
||||
if (target == 0) target += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz = q16horiz(FloatToFixed(value));
|
||||
if (backup) ohoriz = horiz;
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerHorizon::processhelpers(double const scaleAdjust)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz.asq16())));
|
||||
|
||||
if (abs(horiz.asq16() - target) < FRACUNIT)
|
||||
{
|
||||
horiz = q16horiz(target);
|
||||
target = 0;
|
||||
}
|
||||
}
|
||||
else if (adjustment)
|
||||
{
|
||||
horiz += q16horiz(FloatToFixed(scaleAdjust * adjustment));
|
||||
}
|
||||
}
|
||||
|
||||
fixedhoriz PlayerHorizon::sum()
|
||||
{
|
||||
return horiz + horizoff;
|
||||
}
|
||||
|
||||
fixedhoriz PlayerHorizon::interpolatedsum(double const smoothratio)
|
||||
{
|
||||
fixedhoriz prev = ohoriz + ohorizoff;
|
||||
fixedhoriz curr = horiz + horizoff;
|
||||
return q16horiz(prev.asq16() + mulscale16(curr.asq16() - prev.asq16(), smoothratio));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
||||
|
|
|
@ -74,72 +74,13 @@ struct PlayerHorizon
|
|||
fixed_t target;
|
||||
double adjustment;
|
||||
|
||||
void backup()
|
||||
{
|
||||
ohoriz = horiz;
|
||||
ohorizoff = horizoff;
|
||||
}
|
||||
|
||||
void addadjustment(double value)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
adjustment += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz += q16horiz(FloatToFixed(value));
|
||||
}
|
||||
}
|
||||
|
||||
void resetadjustment()
|
||||
{
|
||||
adjustment = 0;
|
||||
}
|
||||
|
||||
void settarget(double value, bool backup = false)
|
||||
{
|
||||
if (!cl_syncinput)
|
||||
{
|
||||
target = FloatToFixed(value);
|
||||
if (target == 0) target += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
horiz = q16horiz(FloatToFixed(value));
|
||||
if (backup) ohoriz = horiz;
|
||||
}
|
||||
}
|
||||
|
||||
void processhelpers(double const scaleAdjust)
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
horiz += q16horiz(xs_CRoundToInt(scaleAdjust * (target - horiz.asq16())));
|
||||
|
||||
if (abs(horiz.asq16() - target) < FRACUNIT)
|
||||
{
|
||||
horiz = q16horiz(target);
|
||||
target = 0;
|
||||
}
|
||||
}
|
||||
else if (adjustment)
|
||||
{
|
||||
horiz += q16horiz(FloatToFixed(scaleAdjust * adjustment));
|
||||
}
|
||||
}
|
||||
|
||||
fixedhoriz sum()
|
||||
{
|
||||
return horiz + horizoff;
|
||||
}
|
||||
|
||||
fixedhoriz interpolatedsum(double const smoothratio)
|
||||
{
|
||||
fixedhoriz prev = ohoriz + ohorizoff;
|
||||
fixedhoriz curr = horiz + horizoff;
|
||||
return q16horiz(prev.asq16() + mulscale16(curr.asq16() - prev.asq16(), smoothratio));
|
||||
}
|
||||
void backup();
|
||||
void addadjustment(double value);
|
||||
void resetadjustment();
|
||||
void settarget(double value, bool backup = false);
|
||||
void processhelpers(double const scaleAdjust);
|
||||
fixedhoriz sum();
|
||||
fixedhoriz interpolatedsum(double const smoothratio);
|
||||
};
|
||||
|
||||
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
|
||||
|
|
Loading…
Reference in a new issue