diff --git a/MY_!Base/src/MY.Sys.lua b/MY_!Base/src/MY.Sys.lua index 6c5c2294e..892d14b17 100644 --- a/MY_!Base/src/MY.Sys.lua +++ b/MY_!Base/src/MY.Sys.lua @@ -4,7 +4,7 @@ -- @Date : 2014-12-17 17:24:48 -- @Email : admin@derzh.com -- @Last modified by: Emil Zhai --- @Last modified time: 2016-12-19 16:13:13 +-- @Last modified time: 2017-02-08 17:56:29 -- @Ref: 借鉴大量海鳗源码 @haimanchajian.com -------------------------------------------- local srep, tostring, string2byte = string.rep, tostring, string.byte @@ -187,6 +187,16 @@ function MY.GetGlobalValue(szVarPath) return tVariable end +function MY.CreateDataRoot(ePathType) + if ePathType == MY_DATA_PATH.ROLE then + CPath.MakeDir(MY.FormatPath({'$name/', MY_DATA_PATH.ROLE})) + end + CPath.MakeDir(MY.FormatPath({'cache/', ePathType})) + CPath.MakeDir(MY.FormatPath({'config/', ePathType})) + CPath.MakeDir(MY.FormatPath({'export/', ePathType})) + CPath.MakeDir(MY.FormatPath({'userdata/', ePathType})) +end + -- 播放声音 -- MY.PlaySound(szFilePath[, szCustomPath]) -- szFilePath 音频文件地址 diff --git a/MY_!Base/src/MY.lua b/MY_!Base/src/MY.lua index 5dcad049e..07821138d 100644 --- a/MY_!Base/src/MY.lua +++ b/MY_!Base/src/MY.lua @@ -4,7 +4,7 @@ -- @Date : 2014-11-24 08:40:30 -- @Email : admin@derzh.com -- @Last modified by: Emil Zhai --- @Last modified time: 2017-02-06 10:38:19 +-- @Last modified time: 2017-02-08 17:56:35 -- @Ref: 借鉴大量海鳗源码 @haimanchajian.com -------------------------------------------- -- #################################################################################################################################### -- @@ -364,17 +364,9 @@ local function OnInit() if not INIT_FUNC_LIST then return end - for _, ePathType in ipairs({ - MY_DATA_PATH.GLOBAL, - MY_DATA_PATH.ROLE, - MY_DATA_PATH.SERVER, - }) do - CPath.MakeDir(MY.FormatPath({'cache/', ePathType})) - CPath.MakeDir(MY.FormatPath({'config/', ePathType})) - CPath.MakeDir(MY.FormatPath({'export/', ePathType})) - CPath.MakeDir(MY.FormatPath({'userdata/', ePathType})) - end - CPath.MakeDir(MY.FormatPath({'$name/', MY_DATA_PATH.ROLE})) + MY.CreateDataRoot(MY_DATA_PATH.ROLE) + MY.CreateDataRoot(MY_DATA_PATH.GLOBAL) + MY.CreateDataRoot(MY_DATA_PATH.SERVER) for szKey, fnAction in pairs(INIT_FUNC_LIST) do local nStartTick = GetTickCount() diff --git a/MY_BagEx/src/MY_BagStatistics.lua b/MY_BagEx/src/MY_BagStatistics.lua index 8aec46f49..39d05960f 100644 --- a/MY_BagEx/src/MY_BagStatistics.lua +++ b/MY_BagEx/src/MY_BagStatistics.lua @@ -4,10 +4,11 @@ -- @Email: root@derzh.com -- @Project: JX3 UI -- @Last modified by: Emil Zhai --- @Last modified time: 2017-02-06 14:59:18 +-- @Last modified time: 2017-02-08 17:58:05 -- -- these global functions are accessed all the time by the event handler -- so caching them is worth the effort +MY.CreateDataRoot(MY_DATA_PATH.GLOBAL) local XML_LINE_BREAKER = XML_LINE_BREAKER local ipairs, pairs, next, pcall = ipairs, pairs, next, pcall local tinsert, tremove, tconcat = table.insert, table.remove, table.concat @@ -20,7 +21,7 @@ local GetClientPlayer, GetPlayer, GetNpc, GetClientTeam, UI_GetClientPlayerID = local setmetatable = setmetatable local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "MY_BagEx/lang/") - DB = SQLite3_Open(MY.FormatPath({"userdata/bagstatistics.db", MY_DATA_PATH.GLOBAL})) +local DB = SQLite3_Open(MY.FormatPath({"userdata/bagstatistics.db", MY_DATA_PATH.GLOBAL})) if not DB then return MY.Sysmsg({_L['Cannot connect to database!!!'], r = 255, g = 0, b = 0}, _L["MY_BagStatistics"]) end diff --git a/MY_Farbnamen/src/MY_Farbnamen.lua b/MY_Farbnamen/src/MY_Farbnamen.lua index e1a607244..e12896f82 100644 --- a/MY_Farbnamen/src/MY_Farbnamen.lua +++ b/MY_Farbnamen/src/MY_Farbnamen.lua @@ -11,12 +11,8 @@ local tinsert, tconcat, tremove = table.insert, table.concat, table.remove --------------------------------------------------------------- -- 设置和数据 --------------------------------------------------------------- -MY_Farbnamen = MY_Farbnamen or { - bEnabled = true, -} -RegisterCustomData("MY_Farbnamen.bEnabled") +MY.CreateDataRoot(MY_DATA_PATH.SERVER) local SZ_CONFIG_PATH = "config/player_force_color.jx3dat" -local SZ_DB_ROOT = MY.FormatPath({"cache/", MY_DATA_PATH.SERVER}) local SZ_DB_PATH = MY.FormatPath({"cache/player_info.db", MY_DATA_PATH.SERVER}) local Config_Default = { tForceColor = MY.LoadLUAData({SZ_CONFIG_PATH, MY_DATA_PATH.GLOBAL}) or { @@ -36,7 +32,6 @@ local Config_Default = { [FORCE_TYPE.BA_DAO ] = {106 ,108, 189}, -- 霸刀 }, } -CPath.MakeDir(SZ_DB_ROOT) local DB = SQLite3_Open(SZ_DB_PATH) if not DB then return MY.Sysmsg({_L['Cannot connect to database!!!'], r = 255, g = 0, b = 0}, _L["MY_Farbnamen"]) @@ -50,6 +45,11 @@ DB:Execute("CREATE TABLE IF NOT EXISTS TongCache (id INTEGER PRIMARY KEY, name V local DBT_W = DB:Prepare("REPLACE INTO TongCache (id, name) VALUES (?, ?)") local DBT_RI = DB:Prepare("SELECT id, name FROM InfoCache WHERE id = ?") +MY_Farbnamen = MY_Farbnamen or { + bEnabled = true, +} +RegisterCustomData("MY_Farbnamen.bEnabled") + do if IsDebugClient() then -- 旧版缓存转换 local SZ_IC_PATH = MY.FormatPath("cache/PLAYER_INFO/$relserver/") if IsLocalFileExist(SZ_IC_PATH) then diff --git a/MY_MiddleMapMark/src/MY_MiddleMapMark.lua b/MY_MiddleMapMark/src/MY_MiddleMapMark.lua index 26cf17410..230286a3e 100644 --- a/MY_MiddleMapMark/src/MY_MiddleMapMark.lua +++ b/MY_MiddleMapMark/src/MY_MiddleMapMark.lua @@ -5,9 +5,9 @@ -- @Date : 2014-12-04 11:51:31 -- @Email : admin@derzh.com -- @Last modified by: Emil Zhai --- @Last modified time: 2017-01-17 10:16:27 +-- @Last modified time: 2017-02-08 17:59:40 ----------------------------------------------- -MY_MiddleMapMark = {} +MY.CreateDataRoot(MY_DATA_PATH.GLOBAL) local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "MY_MiddleMapMark/lang/") local l_szKeyword = "" local SZ_DB_PATH = MY.FormatPath({"cache/npc_doodad_rec.db", MY_DATA_PATH.GLOBAL}) @@ -30,6 +30,7 @@ local DBD_RI = DB:Prepare("SELECT templateid, poskey, mapid, x, y, name FROM Doo local DBD_RN = DB:Prepare("SELECT templateid, poskey, mapid, x, y, name FROM DoodadInfo WHERE name LIKE ?") local DBD_RNM = DB:Prepare("SELECT templateid, poskey, mapid, x, y, name FROM DoodadInfo WHERE name LIKE ? AND mapid = ?") +MY_MiddleMapMark = {} do --------------------------------------------------------------- -- 数据存储