From 03ff328b5bfad61e5bd776e298ca4b305d470e89 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 23 Feb 2024 23:28:10 +0100 Subject: [PATCH] Core/ApplicationBase: Fix GetComponent --- include/Nazara/Core/ApplicationBase.inl | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Core/ApplicationBase.inl b/include/Nazara/Core/ApplicationBase.inl index 2751c74cd..4ac9e5928 100644 --- a/include/Nazara/Core/ApplicationBase.inl +++ b/include/Nazara/Core/ApplicationBase.inl @@ -61,7 +61,7 @@ namespace Nz constexpr UInt64 typeHash = FNV1a64(TypeName()); auto it = m_components.find(typeHash); - if (it != m_components.end()) + if (it == m_components.end()) throw std::runtime_error("component not found"); return static_cast(*it->second); @@ -73,7 +73,7 @@ namespace Nz constexpr UInt64 typeHash = FNV1a64(TypeName()); auto it = m_components.find(typeHash); - if (it != m_components.end()) + if (it == m_components.end()) throw std::runtime_error("component not found"); return static_cast(*it->second); @@ -83,12 +83,7 @@ namespace Nz bool ApplicationBase::HasComponent() const { constexpr UInt64 typeHash = FNV1a64(TypeName()); - - auto it = m_components.find(typeHash); - if (it != m_components.end()) - return false; - - return it->second != nullptr; + return m_components.contains(typeHash); } inline void ApplicationBase::Quit()