diff --git a/src/SWBF2/Core.cpp b/src/SWBF2/Core.cpp index 54c1ad1..d029dd2 100644 --- a/src/SWBF2/Core.cpp +++ b/src/SWBF2/Core.cpp @@ -50,16 +50,18 @@ namespace SWBF2 void Core::LoadLevel(const godot::String &mapName) { - m_curMapName = mapName; - if (mapName.is_empty()) { remove_child(find_child("Level", false)); - // TODO reset + GameData::Instance()->ClearMapData(); + + m_curMapName = mapName; return; } + m_curMapName = mapName; + Level *lvl = memnew(Level); add_child(lvl); lvl->set_owner(this); diff --git a/src/SWBF2/GameData.cpp b/src/SWBF2/GameData.cpp index 9381307..daea0a0 100644 --- a/src/SWBF2/GameData.cpp +++ b/src/SWBF2/GameData.cpp @@ -40,8 +40,14 @@ namespace SWBF2 const GameData::SGameData &GameData::GetMapData() { - std::string mapName{ DefaultGameMaps.at(Core::Instance()->GetMapName().ascii().get_data()) }; - return m_gameData[mapName]; + std::string mapPath{ DefaultGameMaps.at(Core::Instance()->GetMapName().ascii().get_data()) }; + return m_gameData[mapPath]; + } + + void GameData::ClearMapData() + { + std::string mapPath{ DefaultGameMaps.at(Core::Instance()->GetMapName().ascii().get_data()) }; + m_gameData[mapPath] = {}; } void GameData::_bind_methods() diff --git a/src/SWBF2/GameData.hpp b/src/SWBF2/GameData.hpp index 5f9b74a..9e88240 100644 --- a/src/SWBF2/GameData.hpp +++ b/src/SWBF2/GameData.hpp @@ -49,6 +49,7 @@ namespace SWBF2 void ReadLevelFile(const std::string &file); const SGameData &GetMapData(); + void ClearMapData(); void _ready() override;