mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
Use new coding style in game modules
Lots of refactoring and changes Remove docs folder
This commit is contained in:
@@ -70,6 +70,13 @@ bool Module::load()
|
||||
if(m_sandboxed)
|
||||
g_lua.resetGlobalEnvironment();
|
||||
|
||||
// add to package.loaded
|
||||
g_lua.getGlobalField("package", "loaded");
|
||||
g_lua.getRef(m_sandboxEnv);
|
||||
g_lua.setField(m_name);
|
||||
g_lua.pop();
|
||||
|
||||
m_loaded = true;
|
||||
g_logger.debug(stdext::format("Loaded module '%s'", m_name));
|
||||
} catch(stdext::exception& e) {
|
||||
if(m_sandboxed)
|
||||
@@ -78,7 +85,6 @@ bool Module::load()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_loaded = true;
|
||||
g_modules.updateModuleLoadOrder(asModule());
|
||||
|
||||
for(const std::string& modName : m_loadLaterModules) {
|
||||
@@ -119,6 +125,12 @@ void Module::unload()
|
||||
g_lua.clearTable();
|
||||
g_lua.pop();
|
||||
|
||||
// remove from package.loaded
|
||||
g_lua.getGlobalField("package", "loaded");
|
||||
g_lua.pushNil();
|
||||
g_lua.setField(m_name);
|
||||
g_lua.pop();
|
||||
|
||||
m_loaded = false;
|
||||
//g_logger.info(stdext::format("Unloaded module '%s'", m_name));
|
||||
g_modules.updateModuleLoadOrder(asModule());
|
||||
|
@@ -930,18 +930,21 @@ void LuaInterface::setTable(int index)
|
||||
void LuaInterface::clearTable(int index)
|
||||
{
|
||||
assert(hasIndex(index) && isTable(index));
|
||||
pushNil();
|
||||
pushNil(); // table, nil
|
||||
bool stop = false;
|
||||
while(!stop && next(index-1)) {
|
||||
pop();
|
||||
pushValue();
|
||||
if(next(index-2))
|
||||
pop();
|
||||
else
|
||||
stop = true;
|
||||
insert(-2);
|
||||
pushNil();
|
||||
rawSet(index-3);
|
||||
while(next(index-1)) { // table, key, value
|
||||
pop(); // table, key
|
||||
pushValue(); // table, key, key
|
||||
if(next(index-2)) { // table, key, nextkey, value
|
||||
pop(); // table, key, nextkey
|
||||
insert(-2); // table, nextkey, key
|
||||
pushNil(); // table, nextkey, key, nil
|
||||
rawSet(index-3); // table, nextkey
|
||||
} else { // table, key
|
||||
pushNil(); // table, key, nil
|
||||
rawSet(index-2); // table
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -191,10 +191,8 @@ void OTMLParser::parseNode(const std::string& data)
|
||||
if(boost::starts_with(value, "[") && boost::ends_with(value, "]")) {
|
||||
std::string tmp = value.substr(1, value.length()-2);
|
||||
boost::tokenizer<boost::escaped_list_separator<char>> tokens(tmp);
|
||||
for(std::string v : tokens) {
|
||||
stdext::trim(v);
|
||||
node->writeIn(v);
|
||||
}
|
||||
for(std::string v : tokens)
|
||||
node->writeIn(stdext::trim(v));
|
||||
} else
|
||||
node->setValue(value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user