mirror of
https://github.com/edubart/otclient.git
synced 2026-01-17 11:01:30 +01:00
Refactoring and flexibility changes
* Split game module into game and game_interface * Move core_lib to corelib * Move miniwindow to corelib * Introduce init.lua script for initializing the client, giving much more flexibility * OTClient is no longer Application derived and is much simpler
This commit is contained in:
@@ -292,6 +292,17 @@ int LuaInterface::luaObjectCollectEvent(LuaInterface* lua)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
bool LuaInterface::safeRunScript(const std::string& fileName)
|
||||
{
|
||||
try {
|
||||
runScript(fileName);
|
||||
return true;
|
||||
} catch(LuaException& e) {
|
||||
g_logger.error(stdext::format("Failed to load script '%s': %s", fileName, e.what()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void LuaInterface::runScript(const std::string& fileName)
|
||||
{
|
||||
loadScript(fileName);
|
||||
@@ -312,7 +323,7 @@ void LuaInterface::loadScript(const std::string& fileName)
|
||||
filePath = getCurrentSourcePath() + "/" + filePath;
|
||||
|
||||
try {
|
||||
std::string buffer = g_resources.loadFile(filePath);
|
||||
std::string buffer = g_resources.loadFile(fileName);
|
||||
std::string source = "@" + filePath;
|
||||
loadBuffer(buffer, source);
|
||||
} catch(stdext::exception& e) {
|
||||
|
||||
@@ -132,6 +132,9 @@ private:
|
||||
static int luaObjectCollectEvent(LuaInterface* lua);
|
||||
|
||||
public:
|
||||
/// Loads and runs a script, any errors are printed to stdout and returns false
|
||||
bool safeRunScript(const std::string& fileName);
|
||||
|
||||
/// Loads and runs a script
|
||||
/// @exception LuaException is thrown on any lua error
|
||||
void runScript(const std::string& fileName);
|
||||
|
||||
@@ -31,7 +31,7 @@ LuaObject::LuaObject() : m_fieldsTableRef(-1)
|
||||
|
||||
LuaObject::~LuaObject()
|
||||
{
|
||||
assert(!g_app->isTermianted());
|
||||
assert(!g_app.isTermianted());
|
||||
releaseLuaFieldsTable();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user