Skip to content

Commit

Permalink
重写数据库连接目录初始化代码解决第一次进入游戏连不上的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tinymins committed Feb 8, 2017
1 parent ea0ba49 commit 53acee0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
12 changes: 11 additions & 1 deletion MY_!Base/src/MY.Sys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 音频文件地址
Expand Down
16 changes: 4 additions & 12 deletions MY_!Base/src/MY.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------------
-- #################################################################################################################################### --
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions MY_BagEx/src/MY_BagStatistics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions MY_Farbnamen/src/MY_Farbnamen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"])
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions MY_MiddleMapMark/src/MY_MiddleMapMark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
---------------------------------------------------------------
-- 数据存储
Expand Down

0 comments on commit 53acee0

Please sign in to comment.