mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 20:40:39 +00:00
- Remove GameInput
friendships inside PlayerAngles
in lieu of a local inline function.
This commit is contained in:
parent
23dd0bab87
commit
bdf566b348
7 changed files with 29 additions and 18 deletions
|
@ -60,10 +60,15 @@ bool crouch_toggle = false;
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Input scale helper functions.
|
||||
// Input helper functions.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
inline void addCameraAngles(const DRotator& input)
|
||||
{
|
||||
PlayerArray[myconnectindex]->Angles.CameraAngles += input;
|
||||
}
|
||||
|
||||
static inline DAngle getscaledangle(const DAngle angle, const double scale, const double push)
|
||||
{
|
||||
return (angle.Normalized180() * getTicrateScale(scale)) + DAngle::fromDeg(push);
|
||||
|
@ -94,13 +99,25 @@ void GameInput::resetCrouchToggle()
|
|||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Default player movement function for the games. Can be overridden.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::doPlayerMovement(const double scaleAdjust)
|
||||
{
|
||||
gameInput.processMovement(scaleAdjust);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Player's movement function, called from game's ticker or from gi->doPlayerMovement() as required.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processMovement(PlayerAngles* const plrAngles, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
void GameInput::processMovement(const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
{
|
||||
// set up variables.
|
||||
InputPacket thisInput{};
|
||||
|
@ -173,7 +190,7 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const double scal
|
|||
// directly update player angles if we can.
|
||||
if (scaleAdjust < 1)
|
||||
{
|
||||
plrAngles->CameraAngles += thisInput.ang;
|
||||
addCameraAngles(thisInput.ang);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +201,7 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const double scal
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processVehicle(PlayerAngles* const plrAngles, const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags)
|
||||
void GameInput::processVehicle(const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags)
|
||||
{
|
||||
// open up input packet for this session.
|
||||
InputPacket thisInput{};
|
||||
|
@ -237,7 +254,7 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const double scale
|
|||
// directly update player angles if we can.
|
||||
if (scaleAdjust < 1)
|
||||
{
|
||||
plrAngles->CameraAngles += thisInput.ang;
|
||||
addCameraAngles(thisInput.ang);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ public:
|
|||
}
|
||||
|
||||
// Prototypes for large member functions.
|
||||
void processMovement(PlayerAngles* const plrAngles, const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1.);
|
||||
void processVehicle(PlayerAngles* const plrAngles, const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags);
|
||||
void processMovement(const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1.);
|
||||
void processVehicle(const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags);
|
||||
void getInput(const double scaleAdjust, InputPacket* packet = nullptr);
|
||||
void resetCrouchToggle();
|
||||
};
|
||||
|
@ -102,8 +102,7 @@ struct PlayerAngles
|
|||
DAngle YawSpin;
|
||||
|
||||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def);
|
||||
friend void GameInput::processMovement(PlayerAngles* const plrAngles, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale);
|
||||
friend void GameInput::processVehicle(PlayerAngles* const plrAngles, const double scaleAdjust, const double baseVel, const double velScale, const unsigned flags);
|
||||
friend void addCameraAngles(const DRotator& input);
|
||||
|
||||
// Prototypes.
|
||||
void doPitchInput(InputPacket* const input);
|
||||
|
|
|
@ -6,7 +6,6 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
|
|||
#include "vectors.h"
|
||||
#include "engineerrors.h"
|
||||
#include "stats.h"
|
||||
#include "packet.h"
|
||||
#include "serializer.h"
|
||||
#include "inputstate.h"
|
||||
#include "maptypes.h"
|
||||
|
@ -15,9 +14,7 @@ class FSerializer;
|
|||
struct FRenderViewpoint;
|
||||
struct sectortype;
|
||||
struct tspritetype;
|
||||
class DCoreActor;
|
||||
struct MapRecord;
|
||||
struct PlayerAngles;
|
||||
|
||||
struct GameStats
|
||||
{
|
||||
|
@ -115,7 +112,7 @@ struct GameInterface
|
|||
virtual void RemoveQAVInterpProps(const int res_id) { }
|
||||
virtual bool WantEscape() { return false; }
|
||||
virtual void StartSoundEngine() = 0;
|
||||
virtual void doPlayerMovement(const double scaleAdjust) = 0;
|
||||
virtual void doPlayerMovement(const double scaleAdjust);
|
||||
virtual unsigned getCrouchState() = 0;
|
||||
|
||||
virtual FString statFPS()
|
||||
|
|
|
@ -135,7 +135,6 @@ struct GameInterface : public ::GameInterface
|
|||
void AddQAVInterpProps(const int res_id, const FString& interptype, const bool loopable, const TMap<int, TArray<int>>&& ignoredata) override;
|
||||
void RemoveQAVInterpProps(const int res_id) override;
|
||||
void StartSoundEngine() override;
|
||||
void doPlayerMovement(const double scaleAdjust) override { gameInput.processMovement(&getPlayer(myconnectindex)->Angles, scaleAdjust); }
|
||||
unsigned getCrouchState() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -529,11 +529,11 @@ void GameInterface::doPlayerMovement(const double scaleAdjust)
|
|||
baseVel = VEHICLETURN * velScale;
|
||||
}
|
||||
|
||||
gameInput.processVehicle(&p->Angles, scaleAdjust, baseVel, velScale, vehFlags);
|
||||
gameInput.processVehicle(scaleAdjust, baseVel, velScale, vehFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameInput.processMovement(&p->Angles, scaleAdjust, p->drink_amt, true, (p->psectlotag != ST_2_UNDERWATER) ? 1. : 0.875);
|
||||
gameInput.processMovement(scaleAdjust, p->drink_amt, true, (p->psectlotag != ST_2_UNDERWATER) ? 1. : 0.875);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,6 @@ struct GameInterface : public ::GameInterface
|
|||
void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
|
||||
int GetCurrentSkill() override;
|
||||
void StartSoundEngine() override;
|
||||
void doPlayerMovement(const double scaleAdjust) override { gameInput.processMovement(&getPlayer(nLocalPlayer)->Angles, scaleAdjust); }
|
||||
unsigned getCrouchState() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -1904,7 +1904,7 @@ struct GameInterface : public ::GameInterface
|
|||
void doPlayerMovement(const double scaleAdjust) override
|
||||
{
|
||||
const auto pp = getPlayer(myconnectindex);
|
||||
gameInput.processMovement(&pp->Angles, scaleAdjust, 0, !pp->sop, pp->sop_control ? (3. / 1.40625) : 1.);
|
||||
gameInput.processMovement(scaleAdjust, 0, !pp->sop, pp->sop_control ? (3. / 1.40625) : 1.);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue