From e8e93587e9f97c1b43d8461f8cf829498aa741dc Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Mon, 11 Jan 2016 10:38:23 +0100 Subject: [PATCH] Fixed weird behavior when components would register multiple times (Hint: It should never happen in the first place) --- src/Engine/Core/World.cpp | 4 +++- src/Engine/Editor/EditorSystem.cpp | 4 ++-- src/Game/Game.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index ed04f4f3..d947d1fd 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -53,7 +53,9 @@ void World::DeleteEntity(EntityID entity) void World::RegisterComponent(ComponentInfo& ci) { - m_ComponentPools[ci.Name] = new ComponentPool(ci); + if (m_ComponentPools.find(ci.Name) == m_ComponentPools.end()) { + m_ComponentPools[ci.Name] = new ComponentPool(ci); + } } ComponentWrapper World::AttachComponent(EntityID entity, std::string componentType) diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index efef9ccf..75217dfe 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -662,8 +662,8 @@ void EditorSystem::fileImport(World* world) { m_CurrentFile = openDialog(m_DefaultEntityDir); auto file = ResourceManager::Load(m_CurrentFile.string()); - //EntityFilePreprocessor fpp(file); - //fpp.RegisterComponents(world); + EntityFilePreprocessor fpp(file); + fpp.RegisterComponents(world); EntityFileParser fp(file); fp.MergeEntities(world); createWidget(); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8ac4442f..c66d2641 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -52,8 +52,8 @@ Game::Game(int argc, char* argv[]) auto file = ResourceManager::Load(mapToLoad); EntityFilePreprocessor fpp(file); fpp.RegisterComponents(m_World); - //EntityFileParser fp(file); - //fp.MergeEntities(m_World); + EntityFileParser fp(file); + fp.MergeEntities(m_World); } // Create system pipeline