mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna fix load order
_ext in file name and .ext as extension can both be used to mark files as extensions that are loaded first. Otherwise all is loaded alphabetically. Everything is loaded as modules, which means that they cant be loaded twice with require. closes #85
This commit is contained in:
@@ -32,7 +32,7 @@ void Eluna::Initialize()
|
|||||||
lua_folderpath.replace(0, 1, home);
|
lua_folderpath.replace(0, 1, home);
|
||||||
#endif
|
#endif
|
||||||
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", lua_folderpath.c_str());
|
ELUNA_LOG_INFO("[Eluna]: Searching scripts from `%s`", lua_folderpath.c_str());
|
||||||
GetScripts(lua_folderpath + "/extensions", lua_extensions);
|
// GetScripts(lua_folderpath + "/extensions", lua_extensions);
|
||||||
GetScripts(lua_folderpath, lua_scripts);
|
GetScripts(lua_folderpath, lua_scripts);
|
||||||
|
|
||||||
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size()), GetTimeDiff(oldMSTime));
|
ELUNA_LOG_DEBUG("[Eluna]: Loaded %u scripts in %u ms", uint32(lua_scripts.size()), GetTimeDiff(oldMSTime));
|
||||||
@@ -183,7 +183,9 @@ void Eluna::GetScripts(std::string path, ScriptList& scripts)
|
|||||||
filename = filename.substr(0, extDot);
|
filename = filename.substr(0, extDot);
|
||||||
|
|
||||||
// check extension and add path to scripts to load
|
// check extension and add path to scripts to load
|
||||||
if (ext != ".lua" && ext != ".dll")
|
bool luascript = ext == ".lua" || ext == ".dll";
|
||||||
|
bool extension = ext == ".ext" || (filename.length() >= 4 && filename.find_last_of("_ext") == filename.length() - 4);
|
||||||
|
if (!luascript && !extension)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LuaScript script;
|
LuaScript script;
|
||||||
@@ -191,7 +193,10 @@ void Eluna::GetScripts(std::string path, ScriptList& scripts)
|
|||||||
script.filename = filename;
|
script.filename = filename;
|
||||||
script.filepath = fullpath;
|
script.filepath = fullpath;
|
||||||
script.modulepath = fullpath.substr(0, fullpath.length() - ext.length());
|
script.modulepath = fullpath.substr(0, fullpath.length() - ext.length());
|
||||||
scripts.push_back(script);
|
if (extension)
|
||||||
|
lua_extensions.push_back(script);
|
||||||
|
else
|
||||||
|
scripts.push_back(script);
|
||||||
ELUNA_LOG_DEBUG("[Eluna]: GetScripts add path `%s`", fullpath.c_str());
|
ELUNA_LOG_DEBUG("[Eluna]: GetScripts add path `%s`", fullpath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user