mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-18 09:41:06 +00:00
- Move gi->getCrouchState()
into DCorePlayer
.
This commit is contained in:
parent
8705afc223
commit
4d7094b63b
14 changed files with 42 additions and 73 deletions
|
@ -40,6 +40,7 @@ public:
|
||||||
// All overridable methods.
|
// All overridable methods.
|
||||||
virtual DCoreActor* GetActor() = 0;
|
virtual DCoreActor* GetActor() = 0;
|
||||||
virtual const bool canSlopeTilt() const { return false; }
|
virtual const bool canSlopeTilt() const { return false; }
|
||||||
|
virtual const unsigned getCrouchFlags() const = 0;
|
||||||
virtual const DVector2& GetInputVelocity() const { return actor->vel.XY(); }
|
virtual const DVector2& GetInputVelocity() const { return actor->vel.XY(); }
|
||||||
virtual const double GetMaxInputVel() const = 0;
|
virtual const double GetMaxInputVel() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -48,18 +48,6 @@ GameInput gameInput{};
|
||||||
bool crouch_toggle = false;
|
bool crouch_toggle = false;
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Clears crouch toggle state for new games.
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GameInput::resetCrouchToggle()
|
|
||||||
{
|
|
||||||
crouch_toggle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Default player movement function for the games. Can be overridden.
|
// Default player movement function for the games. Can be overridden.
|
||||||
|
@ -72,6 +60,18 @@ void GameInterface::doPlayerMovement()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Clears crouch toggle state for new games.
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GameInput::resetCrouchToggle()
|
||||||
|
{
|
||||||
|
crouch_toggle = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Player's movement function, called from game's ticker or from gi->doPlayerMovement() as required.
|
// Player's movement function, called from game's ticker or from gi->doPlayerMovement() as required.
|
||||||
|
@ -248,7 +248,7 @@ void GameInput::processInputBits()
|
||||||
}
|
}
|
||||||
else dpad_lock = 0;
|
else dpad_lock = 0;
|
||||||
|
|
||||||
const auto crouchState = gi->getCrouchState();
|
const auto crouchFlags = PlayerArray[myconnectindex]->getCrouchFlags();
|
||||||
inputBuffer.actions |= ActionsToSend;
|
inputBuffer.actions |= ActionsToSend;
|
||||||
ActionsToSend = 0;
|
ActionsToSend = 0;
|
||||||
|
|
||||||
|
@ -266,12 +266,12 @@ void GameInput::processInputBits()
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
||||||
{
|
{
|
||||||
const bool canCrouch = crouchState & CS_CANCROUCH;
|
const bool canCrouch = crouchFlags & CS_CANCROUCH;
|
||||||
crouch_toggle = !crouch_toggle && canCrouch;
|
crouch_toggle = !crouch_toggle && canCrouch;
|
||||||
if (canCrouch) buttonMap.ClearButton(gamefunc_Toggle_Crouch);
|
if (canCrouch) buttonMap.ClearButton(gamefunc_Toggle_Crouch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump) || (crouchState & CS_DISABLETOGGLE))
|
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Jump) || (crouchFlags & CS_DISABLETOGGLE))
|
||||||
crouch_toggle = false;
|
crouch_toggle = false;
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || crouch_toggle)
|
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || crouch_toggle)
|
||||||
|
|
|
@ -111,7 +111,6 @@ struct GameInterface
|
||||||
virtual bool WantEscape() { return false; }
|
virtual bool WantEscape() { return false; }
|
||||||
virtual void StartSoundEngine() = 0;
|
virtual void StartSoundEngine() = 0;
|
||||||
virtual void doPlayerMovement();
|
virtual void doPlayerMovement();
|
||||||
virtual unsigned getCrouchState() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GameInterface* gi;
|
extern GameInterface* gi;
|
||||||
|
|
|
@ -362,7 +362,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 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 RemoveQAVInterpProps(const int res_id) override;
|
||||||
void StartSoundEngine() override;
|
void StartSoundEngine() override;
|
||||||
unsigned getCrouchState() override;
|
|
||||||
void FinalizeSetup() override;
|
void FinalizeSetup() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,12 @@ public:
|
||||||
const int florhit = pActor->hit.florhit.type;
|
const int florhit = pActor->hit.florhit.type;
|
||||||
return pActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0);
|
return pActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned getCrouchFlags() const override
|
||||||
|
{
|
||||||
|
const bool swimming = posture == kPostureSwim;
|
||||||
|
return (CS_CANCROUCH * !swimming) | (CS_DISABLETOGGLE * swimming);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DBloodPlayer* getPlayer(int index)
|
inline DBloodPlayer* getPlayer(int index)
|
||||||
|
|
|
@ -1520,18 +1520,6 @@ int ActionScan(DBloodPlayer* pPlayer, HitInfo* out)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned GameInterface::getCrouchState()
|
|
||||||
{
|
|
||||||
const bool swimming = getPlayer(myconnectindex)->posture == kPostureSwim;
|
|
||||||
return (CS_CANCROUCH * !swimming) | (CS_DISABLETOGGLE * swimming);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void ProcessInput(DBloodPlayer* pPlayer)
|
void ProcessInput(DBloodPlayer* pPlayer)
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -38,7 +38,6 @@ struct GameInterface : public ::GameInterface
|
||||||
void ExitFromMenu() override;
|
void ExitFromMenu() override;
|
||||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||||
void doPlayerMovement() override;
|
void doPlayerMovement() override;
|
||||||
unsigned getCrouchState() override;
|
|
||||||
void UpdateSounds() override;
|
void UpdateSounds() override;
|
||||||
void Startup() override;
|
void Startup() override;
|
||||||
void DrawBackground() override;
|
void DrawBackground() override;
|
||||||
|
|
|
@ -486,21 +486,6 @@ void hud_input(DDukePlayer* const p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
unsigned GameInterface::getCrouchState()
|
|
||||||
{
|
|
||||||
const auto p = getPlayer(myconnectindex);
|
|
||||||
const int sectorLotag = p->insector() ? p->cursector->lotag : 0;
|
|
||||||
const int crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || p->spritebridge) && !p->jetpack_on;
|
|
||||||
const int disableToggle = (!crouchable && p->on_ground) || p->jetpack_on || (isRRRA() && (p->OnMotorcycle || p->OnBoat));
|
|
||||||
return (CS_CANCROUCH * crouchable) | (CS_DISABLETOGGLE * disableToggle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// External entry point
|
// External entry point
|
||||||
|
|
|
@ -419,6 +419,14 @@ public:
|
||||||
{
|
{
|
||||||
cmd.ucmd.setItemUsed(num - 1);
|
cmd.ucmd.setItemUsed(num - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned getCrouchFlags() const override
|
||||||
|
{
|
||||||
|
const int sectorLotag = insector() ? cursector->lotag : 0;
|
||||||
|
const int crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || spritebridge) && !jetpack_on;
|
||||||
|
const int disableToggle = (!crouchable && on_ground) || jetpack_on || (isRRRA() && (OnMotorcycle || OnBoat));
|
||||||
|
return (CS_CANCROUCH * crouchable) | (CS_DISABLETOGGLE * disableToggle);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Cycler
|
struct Cycler
|
||||||
|
|
|
@ -238,7 +238,6 @@ struct GameInterface : public ::GameInterface
|
||||||
void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
|
void processSprites(tspriteArray& tsprites, const DVector3& view, DAngle viewang, double interpfrac) override;
|
||||||
int GetCurrentSkill() override;
|
int GetCurrentSkill() override;
|
||||||
void StartSoundEngine() override;
|
void StartSoundEngine() override;
|
||||||
unsigned getCrouchState() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1199,18 +1199,6 @@ static void updatePlayerWeapon(DExhumedPlayer* const pPlayer)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned GameInterface::getCrouchState()
|
|
||||||
{
|
|
||||||
const bool swimming = getPlayer(nLocalPlayer)->bUnderwater;
|
|
||||||
return (CS_CANCROUCH * !swimming) | (CS_DISABLETOGGLE * swimming);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void updatePlayerAction(DExhumedPlayer* const pPlayer)
|
static void updatePlayerAction(DExhumedPlayer* const pPlayer)
|
||||||
{
|
{
|
||||||
const auto pPlayerActor = pPlayer->GetActor();
|
const auto pPlayerActor = pPlayer->GetActor();
|
||||||
|
|
|
@ -123,6 +123,11 @@ public:
|
||||||
{
|
{
|
||||||
return 15.25;
|
return 15.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned getCrouchFlags() const override
|
||||||
|
{
|
||||||
|
return (CS_CANCROUCH * !bUnderwater) | (CS_DISABLETOGGLE * bUnderwater);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int PlayerCount;
|
extern int PlayerCount;
|
||||||
|
|
|
@ -1875,6 +1875,13 @@ public:
|
||||||
{
|
{
|
||||||
GetActor()->spr.pos.Z = val - GetActor()->viewzoffset;
|
GetActor()->spr.pos.Z = val - GetActor()->viewzoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned getCrouchFlags() const override
|
||||||
|
{
|
||||||
|
const bool crouchable = true;
|
||||||
|
const bool disableToggle = (Flags & (PF_JUMPING|PF_FALLING|PF_CLIMBING|PF_DIVING|PF_DEAD)) || sop;
|
||||||
|
return (CS_CANCROUCH * crouchable) | (CS_DISABLETOGGLE * disableToggle);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DSWPlayer* getPlayer(int index)
|
inline DSWPlayer* getPlayer(int index)
|
||||||
|
@ -1920,7 +1927,6 @@ struct GameInterface : public ::GameInterface
|
||||||
void ExitFromMenu() override;
|
void ExitFromMenu() override;
|
||||||
int GetCurrentSkill() override;
|
int GetCurrentSkill() override;
|
||||||
void StartSoundEngine() override;
|
void StartSoundEngine() override;
|
||||||
unsigned getCrouchState() override;
|
|
||||||
void doPlayerMovement() override
|
void doPlayerMovement() override
|
||||||
{
|
{
|
||||||
const auto pp = getPlayer(myconnectindex);
|
const auto pp = getPlayer(myconnectindex);
|
||||||
|
|
|
@ -5882,20 +5882,6 @@ void DoPlayerRun(DSWPlayer* pp)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned GameInterface::getCrouchState()
|
|
||||||
{
|
|
||||||
const auto pp = getPlayer(myconnectindex);
|
|
||||||
const bool crouchable = true;
|
|
||||||
const bool disableToggle = (pp->Flags & (PF_JUMPING|PF_FALLING|PF_CLIMBING|PF_DIVING|PF_DEAD)) || pp->sop;
|
|
||||||
return (CS_CANCROUCH * crouchable) | (CS_DISABLETOGGLE * disableToggle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void PlayerStateControl(DSWActor* actor)
|
void PlayerStateControl(DSWActor* actor)
|
||||||
{
|
{
|
||||||
if (actor == nullptr || !actor->hasU()) return;
|
if (actor == nullptr || !actor->hasU()) return;
|
||||||
|
|
Loading…
Reference in a new issue