From ec79a9de89a201bb5c52cce1c9615bb377391c2c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 9 May 2020 22:35:53 -0400 Subject: [PATCH] CPlayer: Resolve unused variable warnings --- Runtime/World/CPlayer.cpp | 69 +++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 3e39f57e1..ae83548d3 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -2376,47 +2376,56 @@ bool CPlayer::SetAreaPlayerHint(const CScriptPlayerHint& hint, CStateManager& mg } void CPlayer::AddToPlayerHintRemoveList(TUniqueId id, CStateManager& mgr) { - if (const TCastToConstPtr hint = mgr.ObjectById(id)) { - for (const TUniqueId existId : x93c_playerHintsToRemove) { - if (id == existId) { - return; - } - } + const TCastToConstPtr hint = mgr.ObjectById(id); + if (!hint) { + return; + } - if (x93c_playerHintsToRemove.size() != 32) { - x93c_playerHintsToRemove.push_back(id); + for (const TUniqueId existId : x93c_playerHintsToRemove) { + if (id == existId) { + return; } } + + if (x93c_playerHintsToRemove.size() != 32) { + x93c_playerHintsToRemove.push_back(id); + } } void CPlayer::AddToPlayerHintAddList(TUniqueId id, CStateManager& mgr) { - if (const TCastToConstPtr hint = mgr.ObjectById(id)) { - for (const TUniqueId existId : x980_playerHintsToAdd) { - if (id == existId) { - return; - } - } + const TCastToConstPtr hint = mgr.ObjectById(id); + if (!hint) { + return; + } - if (x980_playerHintsToAdd.size() != 32) { - x980_playerHintsToAdd.push_back(id); + for (const TUniqueId existId : x980_playerHintsToAdd) { + if (id == existId) { + return; } } + + if (x980_playerHintsToAdd.size() != 32) { + x980_playerHintsToAdd.push_back(id); + } } void CPlayer::DeactivatePlayerHint(TUniqueId id, CStateManager& mgr) { - if (TCastToPtr hint = mgr.ObjectById(id)) { - for (const TUniqueId existId : x93c_playerHintsToRemove) { - if (id == existId) { - return; - } - } + const TCastToPtr hint = mgr.ObjectById(id); + if (!hint) { + return; + } - if (x93c_playerHintsToRemove.size() != 32) { - x93c_playerHintsToRemove.push_back(id); - hint->ClearObjectList(); - hint->SetDeactivated(); + for (const TUniqueId existId : x93c_playerHintsToRemove) { + if (id == existId) { + return; } } + + if (x93c_playerHintsToRemove.size() != 32) { + x93c_playerHintsToRemove.push_back(id); + hint->ClearObjectList(); + hint->SetDeactivated(); + } } void CPlayer::UpdatePlayerHints(CStateManager& mgr) { @@ -3233,7 +3242,9 @@ void CPlayer::UpdateGunTransform(const zeus::CVector3f& gunPos, CStateManager& m void CPlayer::UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr) { zeus::CTransform assistXf = xf; - if (TCastToConstPtr target = mgr.GetObjectById(x3f4_aimTarget)) { + const TCastToConstPtr target = mgr.GetObjectById(x3f4_aimTarget); + + if (target) { zeus::CVector3f gunToTarget = x480_assistedTargetAim - xf.origin; zeus::CVector3f gunToTargetFlat = gunToTarget; gunToTargetFlat.z() = 0.f; @@ -4646,7 +4657,7 @@ void CPlayer::UpdateOrbitInput(const CFinalInput& input, CStateManager& mgr) { } break; case EPlayerOrbitState::OrbitObject: - if (const TCastToConstPtr point = mgr.GetObjectById(x310_orbitTargetId)) { + if (TCastToConstPtr(mgr.GetObjectById(x310_orbitTargetId))) { if (ValidateCurrentOrbitTargetId(mgr) == EOrbitValidationResult::OK) { UpdateOrbitPosition(g_tweakPlayer->GetOrbitNormalDistance(int(x308_orbitType)), mgr); } else { @@ -4729,7 +4740,7 @@ void CPlayer::UpdateOrbitInput(const CFinalInput& input, CStateManager& mgr) { case EPlayerOrbitState::NoOrbit: break; case EPlayerOrbitState::OrbitObject: - if (TCastToConstPtr point = mgr.GetObjectById(x310_orbitTargetId)) { + if (TCastToConstPtr(mgr.GetObjectById(x310_orbitTargetId))) { BreakGrapple(EPlayerOrbitRequest::Default, mgr); } else { SetOrbitRequest(EPlayerOrbitRequest::StopOrbit, mgr);