functions_launcher.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. function handler(obj, method)
  2. return function(...)
  3. return method(obj, ...)
  4. end
  5. end
  6. local setmetatableindex_
  7. setmetatableindex_ = function(t, index)
  8. if type(t) == "userdata" then
  9. local peer = tolua.getpeer(t)
  10. if not peer then
  11. peer = {}
  12. tolua.setpeer(t, peer)
  13. end
  14. setmetatableindex_(peer, index)
  15. else
  16. local mt = getmetatable(t)
  17. if not mt then mt = {} end
  18. if not mt.__index then
  19. mt.__index = index
  20. setmetatable(t, mt)
  21. elseif mt.__index ~= index then
  22. setmetatableindex_(mt, index)
  23. end
  24. end
  25. end
  26. setmetatableindex = setmetatableindex_
  27. function clone(object)
  28. local lookup_table = {}
  29. local function _copy(object)
  30. if type(object) ~= "table" then
  31. return object
  32. elseif lookup_table[object] then
  33. return lookup_table[object]
  34. end
  35. local newObject = {}
  36. lookup_table[object] = newObject
  37. for key, value in pairs(object) do
  38. newObject[_copy(key)] = _copy(value)
  39. end
  40. return setmetatable(newObject, getmetatable(object))
  41. end
  42. return _copy(object)
  43. end
  44. function class(classname, ...)
  45. local cls = {__cname = classname}
  46. local supers = {...}
  47. for _, super in ipairs(supers) do
  48. local superType = type(super)
  49. assert(superType == "nil" or superType == "table" or superType == "function",
  50. string.format("class() - create class \"%s\" with invalid super class type \"%s\"",
  51. classname, superType))
  52. if superType == "function" then
  53. assert(cls.__create == nil,
  54. string.format("class() - create class \"%s\" with more than one creating function",
  55. classname));
  56. -- if super is function, set it to __create
  57. cls.__create = super
  58. elseif superType == "table" then
  59. if super[".isclass"] then
  60. -- super is native class
  61. assert(cls.__create == nil,
  62. string.format("class() - create class \"%s\" with more than one creating function or native class",
  63. classname));
  64. cls.__create = function() return super:create() end
  65. else
  66. -- super is pure lua class
  67. cls.__supers = cls.__supers or {}
  68. cls.__supers[#cls.__supers + 1] = super
  69. if not cls.super then
  70. -- set first super pure lua class as class.super
  71. cls.super = super
  72. end
  73. end
  74. else
  75. error(string.format("class() - create class \"%s\" with invalid super type",
  76. classname), 0)
  77. end
  78. end
  79. cls.__index = cls
  80. if not cls.__supers or #cls.__supers == 1 then
  81. setmetatable(cls, {__index = cls.super})
  82. else
  83. setmetatable(cls, {__index = function(_, key)
  84. local supers = cls.__supers
  85. for i = 1, #supers do
  86. local super = supers[i]
  87. if super[key] then return super[key] end
  88. end
  89. end})
  90. end
  91. if not cls.ctor then
  92. -- add default constructor
  93. cls.ctor = function() end
  94. end
  95. cls.new = function(...)
  96. local instance
  97. if cls.__create then
  98. instance = cls.__create(...)
  99. else
  100. instance = {}
  101. end
  102. setmetatableindex(instance, cls)
  103. instance.class = cls
  104. instance:ctor(...)
  105. return instance
  106. end
  107. cls.create = function(_, ...)
  108. return cls.new(...)
  109. end
  110. return cls
  111. end
  112. ------------------------------------------------------
  113. cc = cc or {}
  114. cc.Color3B =
  115. {
  116. WHITE = { r = 255, g = 255, b = 255 },
  117. YELLOW = { r = 255, g = 255, b = 0 },
  118. GREEN = { r = 0, g = 255, b = 0 },
  119. BLUE = { r = 0, g = 0, b = 255 },
  120. RED = { r = 255, g = 0, b = 0 },
  121. MAGENTA = { r = 255, g = 0, b = 255 },
  122. BLACK = { r = 0, g = 0, b = 0 },
  123. ORANGE = { r = 255, g = 127, b = 0 },
  124. GRAY = { r = 166, g = 166, b = 166 },
  125. }
  126. ------------------------------------------------------
  127. -------------------------------------------------------
  128. function Schedule(callback, interval)
  129. return cc.Director:getInstance():getScheduler():scheduleScriptFunc(callback, interval, false)
  130. end
  131. function UnSchedule(scheduleID)
  132. cc.Director:getInstance():getScheduler():unscheduleScriptEntry(scheduleID)
  133. end
  134. function PerformWithDelayGlobal(listener, time)
  135. local handle
  136. handle =
  137. cc.Director:getInstance():getScheduler():scheduleScriptFunc(
  138. function()
  139. cc.Director:getInstance():getScheduler():unscheduleScriptEntry(handle)
  140. listener()
  141. end,
  142. time,
  143. false
  144. )
  145. return handle
  146. end
  147. function ReportBuglyError(tag, content)
  148. local tagStr = tostring(tag)
  149. local contentStr = tostring(content)
  150. if not tagStr or not contentStr then
  151. return
  152. end
  153. local contentLen = string.len(contentStr)
  154. local reportContent = contentLen <= 512 and contentStr or ssub(contentStr, 1, 512)
  155. if cc.PLATFORM_OS_ANDROID == global.Platform then
  156. buglyLog(1, tagStr, reportContent)
  157. buglyReportLuaException(tagStr, tagStr, false)
  158. else
  159. release_print(tagStr .. ":" .. reportContent)
  160. end
  161. end
  162. function RecordBuglyLog(index, value)
  163. if not index or not value then
  164. return
  165. end
  166. if not global.BuglyLogs then
  167. global.BuglyLogs = {}
  168. end
  169. global.BuglyLogs[index] = value
  170. end
  171. function RecordBuglyLogIm(index, value)
  172. if not index or not value then
  173. return
  174. end
  175. if cc.PLATFORM_OS_ANDROID == global.Platform then
  176. buglyLog(1, tostring(index), tostring(value))
  177. else
  178. release_print(tostring(index) .. ":" .. tostring(value))
  179. end
  180. end
  181. function AdjustPath( path )
  182. local len = string.len(path)
  183. if len > 0 and string.byte(path, len) ~= 47 then -- 47 == '/'
  184. path = path .. "/"
  185. end
  186. return path
  187. end
  188. function HTTPRequest(url, callback)
  189. local httpRequest = cc.XMLHttpRequest:new()
  190. httpRequest.responseType = cc.XMLHTTPREQUEST_RESPONSE_JSON
  191. httpRequest.timeout = 100000 -- 10 s
  192. httpRequest:open("GET", url)
  193. if callback then
  194. local function HttpResponseCB()
  195. local code = httpRequest.status
  196. local success = code >= 200 and code < 300
  197. local response = httpRequest.response
  198. release_print("Http Request Code:" .. tostring(code))
  199. callback(success, response, url, code)
  200. end
  201. httpRequest:registerScriptHandler(HttpResponseCB)
  202. end
  203. httpRequest:send()
  204. end
  205. function HTTPRequestPost(url, callback, data, header)
  206. local httpRequest = cc.XMLHttpRequest:new()
  207. httpRequest.responseType = cc.XMLHTTPREQUEST_RESPONSE_JSON
  208. httpRequest.timeout = 100000 -- 10 s
  209. httpRequest:open("POST", url)
  210. if header then
  211. for k, v in pairs(header) do
  212. httpRequest:setRequestHeader(k, v)
  213. end
  214. end
  215. if callback then
  216. local function HttpResponseCB()
  217. local code = httpRequest.status
  218. local success = code >= 200 and code < 300
  219. local response = httpRequest.response
  220. release_print("Http Request Code:" .. tostring(code))
  221. callback(success, response, code)
  222. end
  223. httpRequest:setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  224. httpRequest:registerScriptHandler(HttpResponseCB)
  225. end
  226. --httpRequest:setRequestHeader
  227. httpRequest:send(data)
  228. end
  229. function string.trim(input)
  230. input = string.gsub(input, "^[ \t\n\r]+", "")
  231. return string.gsub(input, "[ \t\n\r]+$", "")
  232. end
  233. function string.split(input, delimiter)
  234. input = tostring(input)
  235. delimiter = tostring(delimiter)
  236. if (delimiter=='') then return false end
  237. local pos,arr = 0, {}
  238. -- for each divider found
  239. for st,sp in function() return string.find(input, delimiter, pos, true) end do
  240. table.insert(arr, string.sub(input, pos, st - 1))
  241. pos = sp + 1
  242. end
  243. table.insert(arr, string.sub(input, pos))
  244. return arr
  245. end
  246. local function dump_value_(v)
  247. if type(v) == "string" then
  248. v = "\"" .. v .. "\""
  249. end
  250. return tostring(v)
  251. end
  252. function dump(value, desciption, nesting)
  253. if not global.isDebugMode then
  254. return
  255. end
  256. if type(nesting) ~= "number" then nesting = 3 end
  257. local lookupTable = {}
  258. local result = {}
  259. local traceback = string.split(debug.traceback("", 2), "\n")
  260. print("dump from: " .. string.trim(traceback[3]))
  261. local function dump_(value, desciption, indent, nest, keylen)
  262. desciption = desciption or "<var>"
  263. local spc = ""
  264. if type(keylen) == "number" then
  265. spc = string.rep(" ", keylen - string.len(dump_value_(desciption)))
  266. end
  267. if type(value) ~= "table" then
  268. result[#result +1 ] = string.format("%s%s%s = %s", indent, dump_value_(desciption), spc, dump_value_(value))
  269. elseif lookupTable[tostring(value)] then
  270. result[#result +1 ] = string.format("%s%s%s = *REF*", indent, dump_value_(desciption), spc)
  271. else
  272. lookupTable[tostring(value)] = true
  273. if nest > nesting then
  274. result[#result +1 ] = string.format("%s%s = *MAX NESTING*", indent, dump_value_(desciption))
  275. else
  276. result[#result +1 ] = string.format("%s%s = {", indent, dump_value_(desciption))
  277. local indent2 = indent.." "
  278. local keys = {}
  279. local keylen = 0
  280. local values = {}
  281. for k, v in pairs(value) do
  282. keys[#keys + 1] = k
  283. local vk = dump_value_(k)
  284. local vkl = string.len(vk)
  285. if vkl > keylen then keylen = vkl end
  286. values[k] = v
  287. end
  288. table.sort(keys, function(a, b)
  289. if type(a) == "number" and type(b) == "number" then
  290. return a < b
  291. else
  292. return tostring(a) < tostring(b)
  293. end
  294. end)
  295. for i, k in ipairs(keys) do
  296. dump_(values[k], k, indent2, nest + 1, keylen)
  297. end
  298. result[#result +1] = string.format("%s}", indent)
  299. end
  300. end
  301. end
  302. dump_(value, desciption, "- ", 1)
  303. for i, line in ipairs(result) do
  304. print(line)
  305. end
  306. end
  307. function ShowLoadingBar(t)
  308. global.L_LoadingBarManager:OpenLayer(t)
  309. end
  310. function HideLoadingBar()
  311. global.L_LoadingBarManager:CloseLayer()
  312. end
  313. function decodeServerInfo( str )
  314. local dictTAB = {
  315. ['0'] = { 'ā','±','ě','ξ' },
  316. ['1'] = { '♂','τ','ο','δ' },
  317. ['2'] = { 'φ','ю','é','ī' },
  318. ['3'] = { 'ш','ō','ē','п' },
  319. ['4'] = { 'б','ь','ǒ','я' },
  320. ['5'] = { '+','á','σ','α' },
  321. ['6'] = { 'ó','∩','ǎ','ε' },
  322. ['7'] = { 'í','ò','ì','°' },
  323. ['8'] = { 'à','○','ψ','♀' },
  324. ['9'] = { 'ζ','ョ','è','ǐ' },
  325. ['"'] = { 'λ','ǘ','ι','ǔ' },
  326. [','] = { 'ǚ','˙','ù','ü' },
  327. ['['] = { 'ǖ','ū','ё','з' },
  328. [']'] = { 'ǜ','ú','ω','э' },
  329. ['a'] = {'ぃ', 'い', 'ぅ', 'う'},
  330. ['b'] = {'ぇ', 'え', 'ぉ', 'お'},
  331. ['c'] = {'か', 'が', 'き', 'ぎ'},
  332. ['d'] = {'く', 'ぐ', 'け', 'げ'},
  333. ['e'] = {'こ', 'ご', 'さ', 'ざ'},
  334. ['f'] = {'し', 'じ', 'す', 'ず'},
  335. ['g'] = {'せ', 'ぜ', 'そ', 'ぞ'},
  336. ['h'] = {'た', 'だ', 'ち', 'ぢ'},
  337. ['i'] = {'っ', 'つ', 'づ', 'て'},
  338. ['j'] = {'で', 'と', 'ど', 'な'},
  339. ['k'] = {'に', 'ぬ', 'ね', 'の'},
  340. ['l'] = {'は', 'ば', 'ぱ', 'ひ'},
  341. ['m'] = {'び', 'ぴ', 'ふ', 'ザ'},
  342. ['n'] = {'シ', 'ジ', 'ス', 'ズ'},
  343. ['o'] = {'セ', 'ゼ', 'ソ', 'ゾ'},
  344. ['p'] = {'タ', 'ダ', 'チ', 'ヂ'},
  345. ['q'] = {'ッ', 'バ', 'ポ', 'ㄛ'},
  346. ['r'] = {'ツ', 'パ', 'マ', 'ㄜ'},
  347. ['s'] = {'ヅ', 'ヒ', 'ミ', 'ㄝ'},
  348. ['t'] = {'テ', 'ビ', 'ム', 'ㄞ'},
  349. ['u'] = {'デ', 'ピ', 'メ', 'ㄟ'},
  350. ['v'] = {'ト', 'フ', 'モ', 'ㄠ'},
  351. ['w'] = {'ド', 'ブ', 'ャ', 'ㄡ'},
  352. ['x'] = {'ナ', 'プ', 'ヤ', 'ㄢ'},
  353. ['y'] = {'ニ', 'ヘ', 'ュ', 'ㄣ'},
  354. ['z'] = {'ヌ', 'ベ', 'ユ', 'ㄤ'},
  355. ['.'] = {'ネ', 'ペ', 'ㄧ', 'ㄥ'},
  356. [':'] = {'ノ', 'ホ', 'ヨ', 'ㄦ'},
  357. ['/'] = {'ハ', 'ボ', 'ㄚ', 'ㄨ'},
  358. }
  359. for k,v in pairs(dictTAB) do
  360. for _,v1 in pairs(v) do
  361. str = string.gsub(str, v1, k)
  362. end
  363. end
  364. return str
  365. end
  366. function requireExport_launcher(path)
  367. return requireLauncher("export/" .. path)
  368. end
  369. function CreateExport_launcher(fileName)
  370. local ui = requireExport_launcher(fileName).create()
  371. if ui.root then
  372. local new_widget = ccui.Widget:create()
  373. new_widget:setAnchorPoint({x=0, y=0})
  374. local children = ui.root:getChildren()
  375. for _, child in pairs(children) do
  376. child:removeFromParent()
  377. end
  378. for _, child in pairs(children) do
  379. new_widget:addChild(child)
  380. end
  381. local name = ui.root:getName()
  382. -- 自适应代码
  383. if name ~= "Layer" and name ~= "Node" then
  384. local visible = cc.Director:getInstance():getVisibleSize()
  385. new_widget:setContentSize(visible)
  386. ccui.Helper:doLayout(new_widget)
  387. else
  388. new_widget:setContentSize(ui.root:getContentSize())
  389. end
  390. return new_widget
  391. end
  392. return nil
  393. end
  394. function ui_delegate(nativeUI)
  395. if (nativeUI == nil) then
  396. return nil
  397. end
  398. local showLanguage = global.L_GameEnvManager:GetEnvDataByKey("showLanguage")
  399. local isFix = false
  400. if showLanguage and string.len( showLanguage ) > 0 then
  401. isFix = true
  402. end
  403. -- fixWidget text: ccui.Button ccui.Text
  404. local function fixNewString( fixWidget )
  405. if not isFix or not fixWidget then
  406. return
  407. end
  408. if tolua.type( fixWidget ) == "ccui.Button" then
  409. local btnTitleStr = fixWidget:getTitleText()
  410. btnTitleStr = fixNewLanguageString( btnTitleStr )
  411. fixWidget:setTitleText( btnTitleStr )
  412. elseif tolua.type( fixWidget ) == "ccui.Text" then
  413. local textStr = fixWidget:getString()
  414. textStr = fixNewLanguageString( textStr )
  415. fixWidget:setString( textStr )
  416. end
  417. end
  418. local function getChildInSubNodes(nodeTable, key)
  419. if #nodeTable == 0 then
  420. return nil
  421. end
  422. local child = nil
  423. local subNodeTable = {}
  424. for _, v in ipairs(nodeTable) do
  425. child = v:getChildByName(key)
  426. if (child) then
  427. fixNewString( child )
  428. return child
  429. end
  430. end
  431. for _, v in ipairs(nodeTable) do
  432. local subNodes = v:getChildren()
  433. if #subNodes ~= 0 then
  434. for _, v1 in ipairs(subNodes) do
  435. fixNewString( child )
  436. table.insert(subNodeTable, v1)
  437. end
  438. end
  439. end
  440. return getChildInSubNodes(subNodeTable, key)
  441. end
  442. local function getChildByKey(parent, key)
  443. return getChildInSubNodes({parent}, key)
  444. end
  445. local tt = {
  446. __index = function(t, k)
  447. local u = getChildByKey(t.nativeUI, k)
  448. rawset(t, k, u)
  449. return u
  450. end
  451. }
  452. local r = {["nativeUI"] = nativeUI}
  453. setmetatable(r, tt)
  454. return r
  455. end
  456. function g_OnEnterForColor(sender)
  457. end
  458. function getNewFoldername(foldername)
  459. if nil == LuaBridgeCtl:Inst().GetNewFoldername then
  460. return foldername
  461. end
  462. return LuaBridgeCtl:Inst():GetNewFoldername(foldername)
  463. end
  464. function decodeXK( str )
  465. local function hex2dec( hexStr )
  466. hexStr = "0x" .. hexStr
  467. return tonumber(hexStr)
  468. end
  469. local dict =
  470. {
  471. [0x00] = "0", -- 0
  472. [0x01] = "1", -- 1
  473. [0x02] = "2", -- 2
  474. [0x03] = "3", -- 3
  475. [0x04] = "4", -- 4
  476. [0x05] = "5", -- 5
  477. [0x06] = "6", -- 6
  478. [0x07] = "7", -- 7
  479. [0x08] = "8", -- 8
  480. [0x09] = "9", -- 9
  481. [0x0a] = "a", -- 10
  482. [0x0b] = "b", -- 11
  483. [0x0c] = "c", -- 12
  484. [0x0d] = "d", -- 13
  485. [0x0e] = "e", -- 14
  486. [0x0f] = "f", -- 15
  487. [0x10] = "g",
  488. [0x11] = "h",
  489. [0x12] = "i",
  490. [0x13] = "j",
  491. [0x14] = "k",
  492. [0x15] = "l",
  493. [0x16] = "m",
  494. [0x17] = "n",
  495. [0x18] = "o",
  496. [0x19] = "p",
  497. [0x1a] = "q",
  498. [0x1b] = "r",
  499. [0x1c] = "s",
  500. [0x1d] = "t",
  501. [0x1e] = "u",
  502. [0x1f] = "v",
  503. [0x20] = "w",
  504. [0x21] = "x",
  505. [0x22] = "y",
  506. [0x23] = "z",
  507. [0x24] = "A",
  508. [0x25] = "B",
  509. [0x26] = "C",
  510. [0x27] = "D",
  511. [0x28] = "E",
  512. [0x29] = "F",
  513. [0x2a] = "G",
  514. [0x2b] = "H",
  515. [0x2c] = "I",
  516. [0x2d] = "J",
  517. [0x2e] = "K",
  518. [0x2f] = "L",
  519. [0x30] = "M",
  520. [0x31] = "N",
  521. [0x32] = "O",
  522. [0x33] = "P",
  523. [0x34] = "Q",
  524. [0x35] = "R",
  525. [0x36] = "S",
  526. [0x37] = "T",
  527. [0x38] = "U",
  528. [0x39] = "V",
  529. [0x3a] = "W",
  530. [0x3b] = "X",
  531. [0x3c] = "Y",
  532. [0x3d] = "Z",
  533. [0x3e] = "!",
  534. [0x3f] = "@",
  535. [0x40] = "#",
  536. [0x41] = "$",
  537. [0x42] = "%",
  538. [0x43] = "^",
  539. [0x44] = "&",
  540. [0x45] = "*",
  541. [0x46] = "(",
  542. [0x47] = ")",
  543. [0x48] = "_",
  544. [0x49] = "+",
  545. [0x4a] = "-",
  546. [0x4b] = "[",
  547. [0x4c] = "]",
  548. [0x4d] = "{",
  549. [0x4e] = "}",
  550. [0x4f] = "|",
  551. }
  552. if not str or "" == str then
  553. return nil
  554. end
  555. -- 解密 1 次
  556. str = decodeServerInfo( str )
  557. -- 长度是否是 偶数
  558. local len = string.len(str)
  559. if 0 ~= len%2 then
  560. return nil
  561. end
  562. -- 截取,计算出正确的密钥
  563. local key = ""
  564. local tmp = ""
  565. while string.len(str) > 0 do
  566. tmp = string.sub(str, 1, 2)
  567. str = string.len(str) > 2 and string.sub(str, 3, string.len(str)) or ""
  568. key = key .. dict[hex2dec(tmp)]
  569. end
  570. return key
  571. end
  572. function GetHTTPSign(data, key)
  573. return get_str_MD5("key="..key .. "&time="..os.time())
  574. end
  575. function GetCdnSign(gameId, time, key)
  576. -- dump(string.format("gameId=%s&time=%s&key=%ssh", gameId, time, key),"签名原串")
  577. return get_str_MD5(string.format("gameId=%s&time=%s&key=%ssh", gameId, time, key))
  578. end
  579. function GetModListServerTime(isLauncher, subMod)
  580. global.modListSrvTime = os.time()
  581. if not subMod then
  582. if not global or not global.L_ModuleManager or not global.L_ModuleManager:GetCurrentModule() then
  583. return
  584. end
  585. local module = global.L_ModuleManager:GetCurrentModule()
  586. if not module then
  587. return
  588. end
  589. subMod = module:GetCurrentSubMod()
  590. end
  591. if not subMod then
  592. return
  593. end
  594. local TimeCallBacks = function ()
  595. if global.modListSrvTimeCallFuncs then
  596. for i, func in ipairs(global.modListSrvTimeCallFuncs) do
  597. func()
  598. end
  599. end
  600. end
  601. -- dump(subMod,"subMod___")
  602. local subModInfo = subMod:GetSubModInfo()
  603. local gameid = subMod:GetOperID()
  604. local xk = subMod:GetXK() or ""
  605. local xkDomain = subModInfo.xkDomain
  606. if not xkDomain or xkDomain == "" then
  607. releasePrint( "xkDomain: empty" )
  608. TimeCallBacks()
  609. return
  610. end
  611. local serverTimeUrlOri = xkDomain .. "/server_time"
  612. local serverTimeData = serverTimeUrlOri
  613. serverTimeData = string.gsub(serverTimeData, "http://", "")
  614. serverTimeData = string.gsub(serverTimeData, "https://", "")
  615. serverTimeData = string.gsub(serverTimeData, "/gsl/auth/mod_list_auth", "")
  616. serverTimeData = string.gsub(serverTimeData, "/gsl/main", "")
  617. local s = string.find(serverTimeData, "/")
  618. serverTimeData = string.sub(serverTimeData, s+1, string.len(serverTimeData))
  619. local signKey = global.L_GameEnvManager:GetModlistSignKey()
  620. local timestamp = os.time()
  621. local sign = get_str_MD5("data=" .. serverTimeData .. "&key=" .. signKey .. "&time="..os.time())
  622. local serverTimeUrl = serverTimeUrlOri .. string.format("?time=%s&sign=%s", timestamp, sign)
  623. releasePrint( "serverTimeUrl1:" ..serverTimeUrl )
  624. if isLauncher then
  625. ShowLoadingBar(1)
  626. end
  627. HTTPRequest(serverTimeUrl,function (success, response)
  628. if isLauncher then
  629. HideLoadingBar()
  630. end
  631. releasePrint( "time:" )
  632. releasePrint( response)
  633. if success then
  634. global.modListSrvTime = tonumber(response) or os.time()
  635. end
  636. TimeCallBacks()
  637. end)
  638. end