Skip to content

Commit 7f36be5

Browse files
FlamefireFlow86
authored andcommitted
Ensure include depth is decreased on error
1 parent 5c6db98 commit 7f36be5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

libs/libGamedata/lua/GameDataLoader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ void GameDataLoader::Include(const std::string& filepath)
8484
const auto oldCurFile = curFile_;
8585
curFile_ = absFilePath;
8686
++curIncludeDepth_;
87-
if(!loadScript(absFilePath))
88-
throw std::runtime_error(helpers::format("Include file '%1%' cannot be included", filepath));
87+
const bool fileLoaded = loadScript(absFilePath);
8988
curFile_ = oldCurFile;
9089
RTTR_Assert(curIncludeDepth_ > 0);
9190
--curIncludeDepth_;
91+
if(!fileLoaded)
92+
throw std::runtime_error(helpers::format("Include file '%1%' cannot be included", filepath));
9293
} catch(const LuaIncludeError& e)
9394
{
9495
throw std::runtime_error(helpers::format("Include file '%1%' cannot be included: %2%", filepath, e.what()));

0 commit comments

Comments
 (0)