Skip to content

Commit

Permalink
Merge pull request #112 from JacobDomagala/111-fix-issue-when-loading…
Browse files Browse the repository at this point in the history
…-level-when-theres-already-one-loaded

[#111]: Fix issue with loading `Level` when there's already one loaded
  • Loading branch information
JacobDomagala authored Apr 24, 2023
2 parents 9bfcc90 + 1b14d54 commit 9f98d9b
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 9f98d9b

Please sign in to comment.