From b004c67cff61e0fa772cc06b3bed515b5e05d68d Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 21 Oct 2015 18:43:27 +0000 Subject: MirLua: fixed disabled script loading git-svn-id: http://svn.miranda-ng.org/main/trunk@15587 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_script_loader.cpp | 20 ++++++++------------ 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: -- cgit v1.2.3