Skip to content

Commit bd9dc78

Browse files
committed
debug2
1 parent 0aec4e3 commit bd9dc78

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

libs/libGamedata/lua/GameDataLoader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "s25util/Log.h"
1616
#include <kaguya/kaguya.hpp>
1717
#include <boost/filesystem.hpp>
18-
#include <stdexcept>
1918
#include <iostream>
19+
#include <stdexcept>
2020

2121
namespace bfs = boost::filesystem;
2222

@@ -41,6 +41,7 @@ bool GameDataLoader::Load()
4141
curFile_ = basePath_ / "default.lua";
4242
curIncludeDepth_ = 0;
4343
errorInIncludeFile_ = false;
44+
std::cerr << "Start loading " << curFile_ << std::endl;
4445
try
4546
{
4647
bool res = loadScript(curFile_);
@@ -99,12 +100,17 @@ void GameDataLoader::Include(const std::string& filepath)
99100
const auto oldCurFile = curFile_;
100101
curFile_ = absFilePath;
101102
++curIncludeDepth_;
103+
std::cerr << "Include " << absFilePath << " LEvel " << curIncludeDepth_ << ' '
104+
<< static_cast<void*>(&errorInIncludeFile_) << '\n';
102105
errorInIncludeFile_ |= !loadScript(absFilePath);
106+
std::cerr << "DONE w/ " << absFilePath << " LEvel " << curIncludeDepth_ << ' '
107+
<< static_cast<void*>(&errorInIncludeFile_) << '\n';
103108
curFile_ = oldCurFile;
104109
RTTR_Assert(curIncludeDepth_ > 0);
105110
--curIncludeDepth_;
106111
} catch(const LuaIncludeError& e)
107112
{
113+
std::cerr << helpers::format("Include file '%1%' cannot be included: %2%", filepath, e.what()) << '\n';
108114
throw std::runtime_error(helpers::format("Include file '%1%' cannot be included: %2%", filepath, e.what()));
109115
}
110116
}

libs/libGamedata/lua/LuaInterfaceBase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <boost/nowide/detail/convert.hpp> // TODO: Remove when requiring Nowide 11 / Boost 1.74
1414
#include <boost/nowide/fstream.hpp>
1515
#include <algorithm>
16+
#include <iostream>
1617

1718
LuaInterfaceBase::LuaInterfaceBase() : lua(kaguya::NoLoadLib()), logger_(LOG), errorOccured_(false)
1819
{
@@ -66,6 +67,7 @@ bool LuaInterfaceBase::loadScript(const boost::filesystem::path& scriptPath)
6667
tmpScript.erase(0, 3);
6768
if(!loadScriptString(tmpScript))
6869
{
70+
std::cerr << "Failed to load " << scriptPath << '\n';
6971
logger_.write(_("Failed to load lua file '%1%'\n")) % scriptPath;
7072
return false;
7173
}
@@ -85,6 +87,7 @@ bool LuaInterfaceBase::loadScriptString(const std::string& script, bool rethrowE
8587
script_ = script;
8688
} catch(const LuaExecutionError&)
8789
{
90+
std::cerr << "LuaExecutionError\n";
8891
if(rethrowError)
8992
throw;
9093
return false;

tests/libGameData/testGameData.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,14 @@ BOOST_AUTO_TEST_CASE(DetectRecursion)
125125
WorldDescription desc;
126126
GameDataLoader loader(desc, tmp);
127127
rttr::test::LogAccessor logAcc;
128+
std::cerr << "Start load\n";
129+
bool res = loader.Load();
130+
BOOST_TEST(!res);
131+
std::cerr << "End load\n";
132+
RTTR_REQUIRE_LOG_CONTAINS("Maximum include depth", false);
133+
std::cerr << "Start load\n";
128134
BOOST_TEST(!loader.Load());
135+
std::cerr << "End load\n";
129136
RTTR_REQUIRE_LOG_CONTAINS("Maximum include depth", false);
130137
}
131138

0 commit comments

Comments
 (0)