Skip to content

Commit

Permalink
[#111]: Fix issue with loading when there's already one loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Apr 24, 2023
1 parent 9bfcc90 commit 1b14d54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 8 additions & 9 deletions editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ Editor::SetupPathfinderNodes()
}

void
Editor::CreateLevel(const std::string& name, const glm::ivec2& size)
Editor::FreeLevelData()
{
if (m_levelLoaded)
{
Expand All @@ -773,6 +773,12 @@ Editor::CreateLevel(const std::string& name, const glm::ivec2& size)

renderer::VulkanRenderer::FreeData(renderer::ApplicationType::EDITOR, false);
}
}

void
Editor::CreateLevel(const std::string& name, const glm::ivec2& size)
{
FreeLevelData();

m_currentLevel = std::make_shared< Level >();
m_currentLevel->Create(this, name, size);
Expand All @@ -792,14 +798,7 @@ Editor::CreateLevel(const std::string& name, const glm::ivec2& size)
void
Editor::LoadLevel(const std::string& levelPath)
{
if (m_levelLoaded)
{
UnselectEditorObject();
UnselectGameObject();
m_currentLevel.reset();
m_editorObjects.clear();
pathfinderNodes_.clear();
}
FreeLevelData();

renderer::VulkanRenderer::SetAppMarker(renderer::ApplicationType::EDITOR);

Expand Down
3 changes: 3 additions & 0 deletions editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ class Editor : public Application
void
SetupPathfinderNodes();

void
FreeLevelData();

std::unique_ptr< Game > m_game = {};

std::string m_levelFileName = {};
Expand Down

0 comments on commit 1b14d54

Please sign in to comment.