diff options
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.cpp | 20 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.h | 2 |
2 files changed, 9 insertions, 13 deletions
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index d26ccd1e90..34ee40256c 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -18,12 +18,16 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path) lua_pop(L, 1);
}
-void CLuaScriptLoader::LoadScript(const TCHAR *path, int iGroup)
+void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file, int iGroup)
{
+ TCHAR fullPath[MAX_PATH], path[MAX_PATH];
+ mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, file);
+ PathToRelativeT(fullPath, path);
+
CMLuaScript *script = new CMLuaScript(L, path, iGroup);
g_mLua->Scripts.insert(script);
- if (script->Load())
+ if (db_get_b(NULL, MODULE, _T2A(file), 1) && script->Load())
{
TCHAR buf[4096];
mir_sntprintf(buf, _T("%s:OK"), path);
@@ -42,22 +46,14 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir, int iGroup) TCHAR searchMask[MAX_PATH];
mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
- TCHAR fullPath[MAX_PATH], path[MAX_PATH];
-
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(searchMask, &fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
- {
if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
- PathToRelativeT(fullPath, path);
- if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
- LoadScript(fullPath, iGroup);
- }
- } while (FindNextFile(hFind, &fd));
+ LoadScript(scriptDir, fd.cFileName, iGroup);
+ while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
diff --git a/plugins/MirLua/src/mlua_script_loader.h b/plugins/MirLua/src/mlua_script_loader.h index 7510b167c7..e7844b6e76 100644 --- a/plugins/MirLua/src/mlua_script_loader.h +++ b/plugins/MirLua/src/mlua_script_loader.h @@ -10,7 +10,7 @@ private: void RegisterScriptsFolder(const char *path);
- void LoadScript(const TCHAR *path, int iGroup = 0);
+ void LoadScript(const TCHAR *scriptDir, const TCHAR *file, int iGroup = 0);
void LoadScripts(const TCHAR *scriptDir, int iGroup = 0);
public:
|