diff --git a/Client/game_sa/CPedSA.cpp b/Client/game_sa/CPedSA.cpp index 6efb0661fb..226f377ad8 100644 --- a/Client/game_sa/CPedSA.cpp +++ b/Client/game_sa/CPedSA.cpp @@ -27,14 +27,8 @@ extern CGameSA* pGame; int g_bOnlyUpdateRotations = false; -CPedSA::CPedSA() : m_pPedIntelligence(NULL), m_pPedInterface(NULL), m_pPedSound(NULL), -m_pDefaultPedSound(NULL), m_iCustomMoveAnim(0) -{ - MemSetFast(m_pWeapons, 0, sizeof(CWeaponSA*) * WEAPONSLOT_MAX); -} - -CPedSA::CPedSA(CPedSAInterface* pPedInterface) : m_pPedIntelligence(NULL), m_pPedInterface(pPedInterface), -m_pPedSound(NULL), m_pDefaultPedSound(NULL), m_iCustomMoveAnim(0) +CPedSA::CPedSA(CPedSAInterface* pPedInterface) noexcept + : m_pPedInterface(pPedInterface) { MemSetFast(m_pWeapons, 0, sizeof(CWeaponSA*) * WEAPONSLOT_MAX); } @@ -50,8 +44,6 @@ CPedSA::~CPedSA() delete m_pPedIntelligence; if (m_pPedSound) delete m_pPedSound; - if (m_pDefaultPedSound) - delete m_pDefaultPedSound; for (int i = 0; i < WEAPONSLOT_MAX; i++) { @@ -94,7 +86,9 @@ void CPedSA::Init() CPedIntelligenceSAInterface* m_pPedIntelligenceInterface = (CPedIntelligenceSAInterface*)(dwPedIntelligence); m_pPedIntelligence = new CPedIntelligenceSA(m_pPedIntelligenceInterface, this); m_pPedSound = new CPedSoundSA(&pedInterface->pedSound); - m_pDefaultPedSound = new CPedSoundSA(&pedInterface->pedSound); + + m_sDefaultVoiceType = m_pPedSound->GetVoiceTypeID(); + m_sDefaultVoiceID = m_pPedSound->GetVoiceID(); for (int i = 0; i < WEAPONSLOT_MAX; i++) m_pWeapons[i] = new CWeaponSA(&(pedInterface->Weapons[i]), this, (eWeaponSlot)i); @@ -953,7 +947,7 @@ void CPedSA::SetVoice(const char* szVoiceType, const char* szVoice) void CPedSA::ResetVoice() { - SetVoice(m_pDefaultPedSound->GetVoiceTypeID(), m_pDefaultPedSound->GetVoiceID()); + SetVoice(m_sDefaultVoiceType, m_sDefaultVoiceID); } // GetCurrentWeaponStat will only work if the game ped context is currently set to this ped diff --git a/Client/game_sa/CPedSA.h b/Client/game_sa/CPedSA.h index 5585e59864..9762fbf3a5 100644 --- a/Client/game_sa/CPedSA.h +++ b/Client/game_sa/CPedSA.h @@ -264,22 +264,23 @@ class CPedSA : public virtual CPed, public virtual CPhysicalSA friend class CPoolsSA; private: - CWeaponSA* m_pWeapons[WEAPONSLOT_MAX]; - CPedIKSA* m_pPedIK; - CPedIntelligenceSA* m_pPedIntelligence; - CPedSAInterface* m_pPedInterface; - CPedSoundSA* m_pPedSound; - CPedSoundSA* m_pDefaultPedSound; + CWeaponSA* m_pWeapons[WEAPONSLOT_MAX]{}; + CPedIKSA* m_pPedIK{}; + CPedIntelligenceSA* m_pPedIntelligence{}; + CPedSAInterface* m_pPedInterface{}; + CPedSoundSA* m_pPedSound{}; + + short m_sDefaultVoiceType; + short m_sDefaultVoiceID; DWORD m_dwType; unsigned char m_ucOccupiedSeat; protected: - int m_iCustomMoveAnim; + int m_iCustomMoveAnim{ 0 }; public: - CPedSA(); - CPedSA(CPedSAInterface* pedInterface); + CPedSA(CPedSAInterface* pedInterface = nullptr) noexcept; ~CPedSA(); void SetInterface(CEntitySAInterface* intInterface); diff --git a/Client/mods/deathmatch/logic/CClientBuilding.h b/Client/mods/deathmatch/logic/CClientBuilding.h index 47587c77b9..f98f8f6413 100644 --- a/Client/mods/deathmatch/logic/CClientBuilding.h +++ b/Client/mods/deathmatch/logic/CClientBuilding.h @@ -41,7 +41,7 @@ class CClientBuilding : public CClientEntity uint16_t GetModel() const noexcept { return m_usModelId; }; void SetModel(uint16_t ulModel); - eClientEntityType GetType() const noexcept { return CCLIENTBUILDING; } + eClientEntityType GetType() const { return CCLIENTBUILDING; } void Create(); void Destroy(); diff --git a/Client/mods/deathmatch/logic/CClientPed.h b/Client/mods/deathmatch/logic/CClientPed.h index 5b8f8e9527..688dba501f 100644 --- a/Client/mods/deathmatch/logic/CClientPed.h +++ b/Client/mods/deathmatch/logic/CClientPed.h @@ -165,16 +165,16 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule CClientPed(CClientManager* pManager, unsigned long ulModelID, ElementID ID); ~CClientPed(); - void Unlink(){}; + void Unlink() {}; virtual eClientEntityType GetType() const { return CCLIENTPED; } - CPlayerPed* GetGamePlayer() { return m_pPlayerPed; } - CEntity* GetGameEntity() { return m_pPlayerPed; } - const CEntity* GetGameEntity() const { return m_pPlayerPed; } + CPlayerPed* GetGamePlayer() noexcept { return m_pPlayerPed; } + CEntity* GetGameEntity() noexcept { return m_pPlayerPed; } + const CEntity* GetGameEntity() const noexcept { return m_pPlayerPed; } - bool IsLocalPlayer() { return m_bIsLocalPlayer; } - bool IsSyncing() { return m_bIsSyncing; } + bool IsLocalPlayer() const noexcept { return m_bIsLocalPlayer; } + bool IsSyncing() const noexcept { return m_bIsSyncing; } void SetSyncing(bool bIsSyncing); bool GetMatrix(CMatrix& Matrix) const; @@ -182,7 +182,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule virtual CSphere GetWorldBoundingSphere(); void GetPosition(CVector& vecPosition) const; - void SetPosition(const CVector& vecPosition) { SetPosition(vecPosition, true, true); } + void SetPosition(const CVector& vecPosition) noexcept { SetPosition(vecPosition, true, true); } void SetPosition(const CVector& vecPosition, bool bResetInterpolation, bool bAllowGroundLoadFreeze = true); void SetInterior(unsigned char ucInterior); @@ -231,19 +231,24 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule void SetTargetTarget(unsigned long ulDelay, const CVector& vecSource, const CVector& vecTarget); - int GetVehicleInOutState() { return m_iVehicleInOutState; }; - void SetVehicleInOutState(int iState) { m_iVehicleInOutState = iState; }; + int GetVehicleInOutState() const noexcept { return m_iVehicleInOutState; }; + void SetVehicleInOutState(int iState) noexcept { m_iVehicleInOutState = iState; }; - unsigned long GetModel() { return m_ulModel; }; + unsigned long GetModel() const noexcept { return m_ulModel; }; bool SetModel(unsigned long ulModel, bool bTemp = false); bool GetCanBeKnockedOffBike(); void SetCanBeKnockedOffBike(bool bCanBeKnockedOffBike); - bool IsInVehicle() { return GetOccupiedVehicle() != NULL; }; - CClientVehicle* GetOccupiedVehicle() { return m_pOccupiedVehicle; }; - unsigned int GetOccupiedVehicleSeat() { return m_uiOccupiedVehicleSeat; }; - CClientVehicle* GetOccupyingVehicle() { return m_pOccupyingVehicle; }; + bool IsInVehicle() const noexcept { return GetOccupiedVehicle() != NULL; }; + + CClientVehicle* GetOccupiedVehicle() noexcept { return m_pOccupiedVehicle; }; + const CClientVehicle* GetOccupiedVehicle() const noexcept { return m_pOccupiedVehicle; }; + + unsigned int GetOccupiedVehicleSeat() const noexcept { return m_uiOccupiedVehicleSeat; }; + + CClientVehicle* GetOccupyingVehicle() noexcept { return m_pOccupyingVehicle; }; + const CClientVehicle* GetOccupyingVehicle() const noexcept { return m_pOccupyingVehicle; }; CClientVehicle* GetRealOccupiedVehicle(); CClientVehicle* GetClosestEnterableVehicle(bool bGetPositionFromClosestDoor, bool bCheckDriverDoor, bool bCheckPassengerDoors, @@ -274,21 +279,21 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule void LockHealth(float fHealth); void LockArmor(float fArmor); - void UnlockHealth() { m_bHealthLocked = false; }; - void UnlockArmor() { m_bArmorLocked = false; }; - bool IsHealthLocked() const { return m_bHealthLocked; }; - bool IsArmorLocked() const { return m_bArmorLocked; }; + void UnlockHealth() noexcept { m_bHealthLocked = false; }; + void UnlockArmor() noexcept { m_bArmorLocked = false; }; + bool IsHealthLocked() const noexcept { return m_bHealthLocked; }; + bool IsArmorLocked() const noexcept { return m_bArmorLocked; }; bool IsDying(); bool IsDead(); - void SetIsDead(bool bDead) { m_bDead = bDead; }; + void SetIsDead(bool bDead) noexcept { m_bDead = bDead; }; void Kill(eWeaponType weaponType, unsigned char ucBodypart, bool bStealth = false, bool bSetDirectlyDead = false, AssocGroupId animGroup = 0, AnimationId animID = 15); void StealthKill(CClientPed* pPed); void BeHit(CClientPed* pClientPedAttacker, ePedPieceTypes hitBodyPart, int hitBodySide, int weaponId); - int GetRespawnState() { return m_pRespawnState; }; - void SetRespawnState(int iRespawnState) { m_pRespawnState = iRespawnState; }; + int GetRespawnState() const noexcept { return m_pRespawnState; }; + void SetRespawnState(int iRespawnState) noexcept { m_pRespawnState = iRespawnState; }; CWeapon* GiveWeapon(eWeaponType weaponType, unsigned int uiAmmo, bool bSetAsCurrent = false); bool SetCurrentWeaponSlot(eWeaponSlot weaponSlot); @@ -328,9 +333,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule } }; CVector GetAim() const; - const CVector& GetAimSource() { return m_shotSyncData->m_vecShotOrigin; }; - const CVector& GetAimTarget() { return m_shotSyncData->m_vecShotTarget; }; - eVehicleAimDirection GetVehicleAimAnim() { return m_shotSyncData->m_cInVehicleAimDirection; }; + const CVector& GetAimSource() const noexcept { return m_shotSyncData->m_vecShotOrigin; }; + const CVector& GetAimTarget() const noexcept { return m_shotSyncData->m_vecShotTarget; }; + eVehicleAimDirection GetVehicleAimAnim() const noexcept { return m_shotSyncData->m_cInVehicleAimDirection; }; void SetAim(float fArmDirectionX, float fArmDirectionY, eVehicleAimDirection cInVehicleAimAnim); void SetAimInterpolated(unsigned long ulDelay, float fArmDirectionX, float fArmDirectionY, bool bAkimboAimUp, eVehicleAimDirection cInVehicleAimAnim); void SetAimingData(unsigned long ulDelay, const CVector& vecTargetPosition, float fArmDirectionX, float fArmDirectionY, @@ -356,7 +361,8 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule float GetStat(unsigned short usStat); void ResetStats(); - CClientPlayerClothes* GetClothes() { return m_pClothes; } + CClientPlayerClothes* GetClothes() noexcept { return m_pClothes; } + const CClientPlayerClothes* GetClothes() const noexcept { return m_pClothes; } // This is kinda hacky, should be private but something depends on this. Should depend on some // streamer func. Perhaps use SetNeverStreamOut, but need something to reset that. @@ -375,13 +381,14 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule bool IsOnGround(); bool IsClimbing(); - bool IsRadioOn() { return m_bRadioOn; }; + bool IsRadioOn() const noexcept { return m_bRadioOn; }; void NextRadioChannel(); void PreviousRadioChannel(); bool SetCurrentRadioChannel(unsigned char ucChannel); - unsigned char GetCurrentRadioChannel() { return m_ucRadioChannel; }; + unsigned char GetCurrentRadioChannel() const noexcept { return m_ucRadioChannel; }; - CTaskManager* GetTaskManager() { return m_pTaskManager; } + CTaskManager* GetTaskManager() noexcept { return m_pTaskManager; } + const CTaskManager* GetTaskManager() const noexcept { return m_pTaskManager; } bool GetShotData(CVector* pvecOrigin, CVector* pvecTarget = NULL, CVector* pvecGunMuzzle = NULL, CVector* pvecFireOffset = NULL, float* fAimX = NULL, float* fAimY = NULL); @@ -399,10 +406,14 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule std::list::iterator ProjectilesEnd() { return m_Projectiles.end(); } unsigned int CountProjectiles(eWeaponType weaponType = WEAPONTYPE_UNARMED); + std::list& GetProjectiles() noexcept { return m_Projectiles; } + const std::list& GetProjectiles() const noexcept { return m_Projectiles; } + void RemoveAllProjectiles(); void DestroySatchelCharges(bool bBlow = true, bool bDestroy = true); - CRemoteDataStorage* GetRemoteData() { return m_remoteDataStorage; } + CRemoteDataStorage* GetRemoteData() noexcept { return m_remoteDataStorage; } + const CRemoteDataStorage* GetRemoteData() const noexcept { return m_remoteDataStorage; } bool IsEnteringVehicle(); bool IsLeavingVehicle(); @@ -416,11 +427,12 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule float GetDistanceFromCentreOfMassToBaseOfModel(); - unsigned char GetAlpha() { return m_ucAlpha; } + unsigned char GetAlpha() const noexcept { return m_ucAlpha; } void SetAlpha(unsigned char ucAlpha); - bool HasTargetPosition() { return (m_interp.pos.ulFinishTime != 0); } - CClientEntity* GetTargetOriginSource() { return m_interp.pTargetOriginSource; } + bool HasTargetPosition() const noexcept { return m_interp.pos.ulFinishTime != 0; } + CClientEntity* GetTargetOriginSource() noexcept { return m_interp.pTargetOriginSource; } + const CClientEntity* GetTargetOriginSource() const noexcept { return m_interp.pTargetOriginSource; } void GetTargetPosition(CVector& vecPosition); void SetTargetPosition(const CVector& vecPosition, unsigned long ulDelay, CClientEntity* pTargetOriginSource = NULL); void RemoveTargetPosition(); @@ -430,8 +442,9 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule CClientEntity* GetTargetedEntity(); CClientPed* GetTargetedPed(); - CClientEntity* GetCurrentContactEntity() { return m_pCurrentContactEntity; } - void SetCurrentContactEntity(CClientEntity* pEntity) { m_pCurrentContactEntity = pEntity; } + CClientEntity* GetCurrentContactEntity() noexcept { return m_pCurrentContactEntity; } + const CClientEntity* GetCurrentContactEntity() const noexcept { return m_pCurrentContactEntity; } + void SetCurrentContactEntity(CClientEntity* pEntity) noexcept { m_pCurrentContactEntity = pEntity; } bool IsSunbathing(); void SetSunbathing(bool bSunbathing, bool bStartStanding = true); @@ -453,14 +466,14 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule bool bOffsetPed = false, bool bHoldLastFrame = false); void KillAnimation(); std::unique_ptr GetAnimationBlock(); - const SAnimationCache& GetAnimationCache() { return m_AnimationCache; } + const SAnimationCache& GetAnimationCache() const noexcept { return m_AnimationCache; } bool IsUsingGun(); - bool IsHeadless() { return m_bHeadless; } + bool IsHeadless() const noexcept { return m_bHeadless; } void SetHeadless(bool bHeadless); - bool IsFrozen() const { return m_bFrozen; } + bool IsFrozen() const noexcept { return m_bFrozen; } void SetFrozen(bool bFrozen); bool IsFrozenWaitingForGroundToLoad() const; void SetFrozenWaitingForGroundToLoad(bool bFrozen); @@ -468,7 +481,7 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule bool IsFootBloodEnabled(); void SetFootBloodEnabled(bool bHasFootBlood); - bool IsBleeding() const { return m_bBleeding; }; + bool IsBleeding() const noexcept { return m_bBleeding; }; void SetBleeding(bool bBleeding); bool IsOnFire(); @@ -502,27 +515,33 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule std::unique_ptr GetFirstAnimation(); void DereferenceCustomAnimationBlock() { m_pCustomAnimationIFP = nullptr; } - std::shared_ptr GetCustomAnimationIFP() { return m_pCustomAnimationIFP; } - bool IsCustomAnimationPlaying() { return ((m_bRequestedAnimation || m_AnimationCache.bLoop) && m_pAnimationBlock && m_bisCurrentAnimationCustom); } - void SetCustomAnimationUntriggerable() + std::shared_ptr GetCustomAnimationIFP() const noexcept { return m_pCustomAnimationIFP; } + bool IsCustomAnimationPlaying() noexcept + { + return (m_bRequestedAnimation || m_AnimationCache.bLoop) + && m_pAnimationBlock && m_bisCurrentAnimationCustom; + } + void SetCustomAnimationUntriggerable() noexcept { m_bRequestedAnimation = false; m_AnimationCache.bLoop = false; } - bool IsNextAnimationCustom() { return m_bisNextAnimationCustom; } + bool IsNextAnimationCustom() const noexcept { return m_bisNextAnimationCustom; } void SetNextAnimationCustom(const std::shared_ptr& pIFP, const SString& strAnimationName); - void SetCurrentAnimationCustom(bool bCustom) { m_bisCurrentAnimationCustom = bCustom; } - bool IsCurrentAnimationCustom() { return m_bisCurrentAnimationCustom; } - CIFPAnimations* GetIFPAnimationsPointer() { return m_pIFPAnimations; } - void SetIFPAnimationsPointer(CIFPAnimations* pIFPAnimations) { m_pIFPAnimations = pIFPAnimations; } + void SetCurrentAnimationCustom(bool bCustom) noexcept { m_bisCurrentAnimationCustom = bCustom; } + bool IsCurrentAnimationCustom() const noexcept { return m_bisCurrentAnimationCustom; } + CIFPAnimations* GetIFPAnimationsPointer() noexcept { return m_pIFPAnimations; } + const CIFPAnimations* GetIFPAnimationsPointer() const noexcept { return m_pIFPAnimations; } + + void SetIFPAnimationsPointer(CIFPAnimations* pIFPAnimations) noexcept { m_pIFPAnimations = pIFPAnimations; } // This will indicate that we have played custom animation, so next animation can be internal GTA animation // You must call this function after playing a custom animation - void SetNextAnimationNormal() { m_bisNextAnimationCustom = false; } - const SString& GetNextAnimationCustomBlockName() { return m_strCustomIFPBlockName; } - const SString& GetNextAnimationCustomName() { return m_strCustomIFPAnimationName; } - const unsigned int& GetCustomAnimationBlockNameHash() { return m_u32CustomBlockNameHash; } - const unsigned int& GetCustomAnimationNameHash() { return m_u32CustomAnimationNameHash; } + void SetNextAnimationNormal() noexcept { m_bisNextAnimationCustom = false; } + const SString& GetNextAnimationCustomBlockName() const noexcept { return m_strCustomIFPBlockName; } + const SString& GetNextAnimationCustomName() const noexcept { return m_strCustomIFPAnimationName; } + const unsigned int& GetCustomAnimationBlockNameHash() const noexcept { return m_u32CustomBlockNameHash; } + const unsigned int& GetCustomAnimationNameHash() const noexcept { return m_u32CustomAnimationNameHash; } void ReplaceAnimation(std::unique_ptr& pInternalAnimHierarchy, const std::shared_ptr& pIFP, CAnimBlendHierarchySAInterface* pCustomAnimHierarchy); @@ -579,13 +598,13 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule void Respawn(CVector* pvecPosition = NULL, bool bRestoreState = false, bool bCameraCut = false); - void SetTaskToBeRestoredOnAnimEnd(bool bSetOnEnd) { m_bTaskToBeRestoredOnAnimEnd = bSetOnEnd; } - bool IsTaskToBeRestoredOnAnimEnd() { return m_bTaskToBeRestoredOnAnimEnd; } - void SetTaskTypeToBeRestoredOnAnimEnd(eTaskType taskType) { m_eTaskTypeToBeRestoredOnAnimEnd = taskType; } - eTaskType GetTaskTypeToBeRestoredOnAnimEnd() { return m_eTaskTypeToBeRestoredOnAnimEnd; } + void SetTaskToBeRestoredOnAnimEnd(bool bSetOnEnd) noexcept { m_bTaskToBeRestoredOnAnimEnd = bSetOnEnd; } + bool IsTaskToBeRestoredOnAnimEnd() const noexcept { return m_bTaskToBeRestoredOnAnimEnd; } + void SetTaskTypeToBeRestoredOnAnimEnd(eTaskType taskType) noexcept { m_eTaskTypeToBeRestoredOnAnimEnd = taskType; } + eTaskType GetTaskTypeToBeRestoredOnAnimEnd() const noexcept { return m_eTaskTypeToBeRestoredOnAnimEnd; } - bool IsWarpInToVehicleRequired() { return m_bWarpInToVehicleRequired; } - void SetWarpInToVehicleRequired(bool warp) { m_bWarpInToVehicleRequired = warp; } + bool IsWarpInToVehicleRequired() const noexcept { return m_bWarpInToVehicleRequired; } + void SetWarpInToVehicleRequired(bool warp) noexcept { m_bWarpInToVehicleRequired = warp; } void NotifyCreate(); void NotifyDestroy();