mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #312 from lioncash/explicit
MkCastTo: Make operator bool instances explicit
This commit is contained in:
commit
a3e0c42794
|
@ -14,15 +14,15 @@ namespace urde {
|
|||
|
||||
CActorList::CActorList() : CObjectList(EGameObjectList::Actor) {}
|
||||
|
||||
bool CActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CActor>(ent); }
|
||||
bool CActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CActor>(ent).IsValid(); }
|
||||
|
||||
CPhysicsActorList::CPhysicsActorList() : CObjectList(EGameObjectList::PhysicsActor) {}
|
||||
|
||||
bool CPhysicsActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CPhysicsActor>(ent); }
|
||||
bool CPhysicsActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CPhysicsActor>(ent).IsValid(); }
|
||||
|
||||
CGameCameraList::CGameCameraList() : CObjectList(EGameObjectList::GameCamera) {}
|
||||
|
||||
bool CGameCameraList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CGameCamera>(ent); }
|
||||
bool CGameCameraList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CGameCamera>(ent).IsValid(); }
|
||||
|
||||
CListeningAiList::CListeningAiList() : CObjectList(EGameObjectList::ListeningAi) {}
|
||||
|
||||
|
@ -41,12 +41,14 @@ CPlatformAndDoorList::CPlatformAndDoorList() : CObjectList(EGameObjectList::Plat
|
|||
|
||||
bool CPlatformAndDoorList::IsQualified(const CEntity& ent) const { return IsDoor(ent) || IsPlatform(ent); }
|
||||
|
||||
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) const { return TCastToConstPtr<CScriptDoor>(ent); }
|
||||
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) const { return TCastToConstPtr<CScriptDoor>(ent).IsValid(); }
|
||||
|
||||
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) const { return TCastToConstPtr<CScriptPlatform>(ent); }
|
||||
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) const {
|
||||
return TCastToConstPtr<CScriptPlatform>(ent).IsValid();
|
||||
}
|
||||
|
||||
CGameLightList::CGameLightList() : CObjectList(EGameObjectList::GameLight) {}
|
||||
|
||||
bool CGameLightList::IsQualified(const CEntity& lt) const { return TCastToConstPtr<CGameLight>(lt); }
|
||||
bool CGameLightList::IsQualified(const CEntity& lt) const { return TCastToConstPtr<CGameLight>(lt).IsValid(); }
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -600,7 +600,7 @@ void CSamusHud::UpdateCameraDebugSettings() {
|
|||
}
|
||||
|
||||
void CSamusHud::UpdateEnergyLow(float dt, const CStateManager& mgr) {
|
||||
bool cineCam = TCastToConstPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr));
|
||||
const bool cineCam = TCastToConstPtr<CCinematicCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr)).IsValid();
|
||||
float oldTimer = x57c_energyLowTimer;
|
||||
|
||||
x57c_energyLowTimer = std::fmod(x57c_energyLowTimer + dt, 0.5f);
|
||||
|
|
|
@ -132,7 +132,8 @@ headerf.write('''
|
|||
operator T*() const { return GetPtr(); }
|
||||
T& operator*() const { return *GetPtr(); }
|
||||
T* operator->() const { return GetPtr(); }
|
||||
operator bool() const { return ptr != nullptr; }
|
||||
bool IsValid() const { return ptr != nullptr; }
|
||||
explicit operator bool() const { return IsValid(); }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@ -147,7 +148,8 @@ public:
|
|||
operator const T*() const { return GetPtr(); }
|
||||
const T& operator*() const { return *GetPtr(); }
|
||||
const T* operator->() const { return GetPtr(); }
|
||||
operator bool() const { return TCastToPtr<T>::ptr != nullptr; }
|
||||
bool IsValid() const { return TCastToPtr<T>::ptr != nullptr; }
|
||||
explicit operator bool() const { return IsValid(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -3323,7 +3323,7 @@ void CPlayer::UpdateAimTargetPrediction(const zeus::CTransform& xf, const CState
|
|||
return;
|
||||
}
|
||||
|
||||
x9c6_27_aimingAtProjectile = TCastToConstPtr<CGameProjectile>(target.GetPtr());
|
||||
x9c6_27_aimingAtProjectile = TCastToConstPtr<CGameProjectile>(target.GetPtr()).IsValid();
|
||||
const zeus::CVector3f instantTarget = target->GetAimPosition(mgr, 0.f);
|
||||
const zeus::CVector3f gunToTarget = instantTarget - xf.origin;
|
||||
const float timeToTarget = gunToTarget.magnitude() / x490_gun->GetBeamVelocity();
|
||||
|
@ -5076,7 +5076,7 @@ bool CPlayer::ValidateOrbitTargetIdAndPointer(TUniqueId uid, CStateManager& mgr)
|
|||
if (uid == kInvalidUniqueId) {
|
||||
return false;
|
||||
}
|
||||
return TCastToConstPtr<CActor>(mgr.GetObjectById(uid));
|
||||
return TCastToConstPtr<CActor>(mgr.GetObjectById(uid)).IsValid();
|
||||
}
|
||||
|
||||
zeus::CVector3f CPlayer::GetBallPosition() const {
|
||||
|
|
Loading…
Reference in New Issue