----------------------- 根据权重选择资源服务器下载地址start ---------- GW_ZIP_URL_RECORD = "" GW_ZIP_URL_VER = 0 GW_ZIP_URL_List = { {url="http://175.41.165.56/online_google_mianwen/online_google_mianwen_700", ver=40, weight = 1}, {url="http://175.41.165.56/online_google_mianwen/online_google_mianwen_700", ver=41, weight = 0}, } function gw_webFunc_get_zip_url() if GW_ZIP_URL_RECORD ~= nil and GW_ZIP_URL_RECORD ~= "" and GW_ZIP_URL_VER ~= 0 then --Debug.info("1") --Debug.info(GW_ZIP_URL_RECORD) --Debug.info(GW_ZIP_URL_VER) return GW_ZIP_URL_RECORD end local default_url = "http://175.41.165.56/online_google_mianwen/online_google_mianwen_700" local default_ver = 40 if GW_ZIP_URL_List == nil and next(GW_ZIP_URL_List) == nil then GW_ZIP_URL_RECORD = default_url GW_ZIP_URL_VER = default_ver --Debug.info("2") --Debug.info(GW_ZIP_URL_RECORD) --Debug.info(GW_ZIP_URL_VER) return GW_ZIP_URL_RECORD end --总权重 local max_weight = 0 for i,v in ipairs(GW_ZIP_URL_List) do max_weight = max_weight + v.weight end if max_weight <= 1 then GW_ZIP_URL_RECORD = GW_ZIP_URL_List[1].url GW_ZIP_URL_VER = GW_ZIP_URL_List[1].ver --Debug.info("3") --Debug.info(GW_ZIP_URL_RECORD) --Debug.info(GW_ZIP_URL_VER) return GW_ZIP_URL_RECORD end --拿当前时间做种子.. math.randomseed(os.time()) --随机数 local num = math.random(1, max_weight) local cur_weight = 0 for i,v in ipairs(GW_ZIP_URL_List) do --随机数落谁家 if num > cur_weight and num <= (cur_weight + v.weight) then GW_ZIP_URL_RECORD = v.url GW_ZIP_URL_VER = v.ver --Debug.info("4") --Debug.info(GW_ZIP_URL_RECORD) --Debug.info(GW_ZIP_URL_VER) return GW_ZIP_URL_RECORD end cur_weight = cur_weight + v.weight end GW_ZIP_URL_RECORD = GW_ZIP_URL_List[1].url GW_ZIP_URL_VER = GW_ZIP_URL_List[1].ver --Debug.info("5") --Debug.info(GW_ZIP_URL_RECORD) --Debug.info(GW_ZIP_URL_VER) return GW_ZIP_URL_RECORD end ----------------------- 根据权重选择资源服务器下载地址end ---------- --UPDATE_TRY_VERSION_MAX = 0 --wavepay支付是否使用blueplanet GW_IS_WAVEPAY_USE_BLUEPLANET = true GW_UPDATE_VERSION_FULL = false UPDATE_VERSION_MAX = 731 VerPath = { ["707"] = {name="ZeroInWork_707_20230420_1_706", size=146166195}, ["708"] = {name="ZeroInWork_708_20230420_1", size=7100}, ["709"] = {name="ZeroInWork_709_20230427_1", size=2594039}, ["710"] = {name="ZeroInWork_710_20230427_1", size=2613}, ["711"] = {name="ZeroInWork_711_20230508_1", size=56047793}, ["712"] = {name="ZeroInWork_712_20230511_1", size=4710400}, ["713"] = {name="ZeroInWork_713_20230511_1", size=1371}, ["714"] = {name="ZeroInWork_713_20230511_1", size=1371}, ["715"] = {name="ZeroInWork_715_20230511_1", size=294912}, ["716"] = {name="ZeroInWork_716_20230518_1", size=17766782}, ["717"] = {name="ZeroInWork_717_20230518_1", size=1199}, ["718"] = {name="ZeroInWork_718_20230518_1", size=7335}, ["719"] = {name="ZeroInWork_719_20230518_1", size=1198}, ["720"] = {name="ZeroInWork_720_20230525_1", size=1534594}, ["721"] = {name="ZeroInWork_721_20230525_1", size=2477}, ["722"] = {name="ZeroInWork_722_20230601_1", size=3229522}, ["723"] = {name="ZeroInWork_723_20230601_1", size=2720}, ["724"] = {name="ZeroInWork_724_20230601_1", size=2683}, ["725"] = {name="ZeroInWork_725_20230608_1", size=4863057}, ["726"] = {name="ZeroInWork_726_20230608_1", size=6415}, ["727"] = {name="ZeroInWork_726_20230608_1", size=3855109}, ["728"] = {name="ZeroInWork_727_20230615_1", size=3855109}, ["729"] = {name="ZeroInWork_729_20230615_1", size=35707}, ["730"] = {name="ZeroInWork_730_20230621_1", size=4734676}, ["731"] = {name="ZeroInWork_731_20230621_1", size=15837} } VerMergePath = { } ----------------------- 公共函数 ---------- -- CDN_URL = "http://cdnres.jstm.shiyuegame.com" -- CDN_URL = "https://cdn.huanxiang.shiyue.cn" CDN_URL = "http://192.168.3.26" REG_URL = "http://192.168.3.26" DOWN_APK_URL = "http://192.168.3.26:81/index.php/ChannelBag/bag" GW_NEW_LOGIN_URL = "http://login.eternalheroesmm.com:83/api/WebService/Handle" -- 新登录流程登录URL--外网(正式) --GW_NEW_LOGIN_URL = "http://testlogin.eternalheroesmm.com:83/api/WebService/Handle" -- 新登录流程登录URL--外网(开发服) --登录平台 GW_NEW_LOGIN_PLATFORM = "android" --是否维护中 GW_IS_SYSTEM_MAINTENANCE = false --维护中显示文字内容 GW_SYSTEM_MAINTENANCE_CONTENT = "A server maintenance is scheduled 2023-06-29 6:30A.M. and it expected to be down for approximately 3 hours to allow for adequate testing" --是否同步资源 GW_NEED_SYNC_SERVER_RES = true --资源路径 --GW_SERVER_RES_URL = "http://175.41.165.56/online_google_mianwen/online_google_mianwen_700" --GW_SERVER_RES_URL = "https://art.eternalheroesmm.com/online_google_mianwen/online_google_mianwen_3" --GW_SERVER_RES_URL = "http://res.eternalheroesmm.com/v4" GW_SERVER_RES_URL = gw_webFunc_get_zip_url() --是否需要强制版本更新 GW_NEED_FORCE_UPDATE_VERSION = true --版本更新地址 GW_UPDATE_VERSION_URL = "https://play.google.com/store/apps/details?id=com.microplaymm.wycardgame1" --是否开启facebook登录 GW_NEW_LOGIN_IS_FACEBOOK_OPEN = true -- --------------------------------------------------+ -- 非打包热更新处理 -- @author whjing2011@gmail.com -- --------------------------------------------------*/ -- urlConfig加载完成调用 function webFunc_urlConfigEnd() end -- 加载模块完成 初始化instance调用开始时调用 function webFunc_initInstanceStart() end -- 加载模块完成 初始化instance调用完成时调用 function webFunc_initInstanceEnd() end -- 游戏开时完毕时调用 function webFunc_GameStart() end CDN_URL="http://192.168.3.26" CDN_PATH_BASE = CDN_URL.."/update/update_all/" URL_PATH_ALL = {} URL_PATH_ALL.google = { update = CDN_URL.."/update/update_android_demo", register = CDN_URL } URL_PATH_ALL.get = function(platform) local data = URL_PATH_ALL[platform] or URL_PATH_ALL["other"] return data end function get_servers_url(account, platform, channelid, srvid, start, num) function sdkOnPay(money, buyNum, prodId, productName, productDesc) Send(10399, {msg="pay "..prodId}) end return string.format("%s/api/role.php?account=%s&platform=%s&chanleId=%s&srvid=%s", URL_PATH.register, account, platform, DEF_CHANNEL or 'dev', srvid) end function get_notice_url(days, loginData) local host = REAL_LOGIN_DATA and REAL_LOGIN_DATA.host or loginData.host return string.format("http://%s/api.php/local/local/notice/?%s", host, os.time()) end --获取公告显示图片url,若返回nil时不显示图片 function gw_get_notice_img_url(days) return nil --return string.format("https://art.eternalheroesmm.com/notice/img/%s.png", 1) --return string.format("http://47.241.254.0:6342/notice/img/%s.png", days) end --获取公告显示内容url,若返回nil时不显示文字内容 function gw_get_notice_content_url(days) return string.format("https://art.eternalheroesmm.com/notice/content/%s.txt", 1) --return string.format("https://47.241.254.0/notice/content/%s.txt", days) end --获取公告显示图片url,若返回nil时不显示图片--维护中公告内容 function gw_get_notice_img_url_under_maintenance(days) return nil --return string.format("https://art.eternalheroesmm.com/WHNotice/img/%s.png", 1) --return string.format("http://47.241.254.0:6342/WHNotice/img/%s.png", days) end --获取公告显示内容url,若返回nil时不显示文字内容--维护中公告内容 function gw_get_notice_content_url_under_maintenance(days) return string.format("https://art.eternalheroesmm.com/notice/content/%s.txt", 1) --return string.format("https://47.241.254.0/WHNotice/content/%s.txt", days) end -- require("cli_log") GW_NEW_LOGIN_USER_AGREEMENT_URL = "https://privacy.eternalheroesmm.com/policy.html" --用户协议链接 GW_NEW_LOGIN_PRIVACY_GUIDELINES_URL = "https://privacy.eternalheroesmm.com/policy.html" --隐私保护指引链接 WY_FACEBOOK_SHARE_URL = "https://share.eternalheroesmm.com" --屏蔽此行直接领奖,不调用facebook接口(Facebook分享) --GW_CLIENT_APP_VER = "v1.0.1" --gw新增资源包打点start GW_RES_DOWNLOAD_RECORD_URL = "http://47.241.101.3:8087/FirstLoad" --zip资源包下载打点记录提交URL-内网 --开始资源包下载打点 function gw_resDownloadLogStart(total_size) if gw_resDownloadLogIsFinished() == true then return end local count_time = gw_resDownloadLogStartCount() count_time = count_time + 1 gw_resDownloadLogSendData(1, 0, 0, 0, total_size, count_time) cc.UserDefault:getInstance():setIntegerForKey("gw_zip_download_record_mark_start", count_time) cc.UserDefault:getInstance():flush() --print("gw_resDownloadLogStart") end function gw_resDownloadLogTimer(time, per, downloaded_size, total_size) if gw_resDownloadLogIsFinished() == true then return end local count_time = gw_resDownloadLogStartCount() if count_time <= 0 then return end gw_resDownloadLogSendData(2, time, per, downloaded_size, total_size, count_time) --print("gw_resDownloadLogTimer") end function gw_resDownloadLogEnd(time, per, downloaded_size, total_size) if gw_resDownloadLogIsFinished() == true then return end local count_time = gw_resDownloadLogStartCount() if count_time <= 0 then return end gw_resDownloadLogSendData(3, time, per, downloaded_size, total_size, count_time) cc.UserDefault:getInstance():setIntegerForKey("gw_zip_download_record_mark_finished", 1) cc.UserDefault:getInstance():flush() --print("gw_resDownloadLogEnd") end function gw_resDownloadLogStartCount() return cc.UserDefault:getInstance():getIntegerForKey("gw_zip_download_record_mark_start", 0) end function gw_resDownloadLogIsFinished() if nil == GW_RES_DOWNLOAD_RECORD_URL then return true end local zip_download_record_mark_finished = cc.UserDefault:getInstance():getIntegerForKey("gw_zip_download_record_mark_finished", 0) if zip_download_record_mark_finished == 1 then return true else return false end end --step:步骤 1开始下载;2下载中;3下载完成 --time:从开始下载开始计时,每经过1秒加1 --per:已下载百分比 --downloaded_size:已下载大小 --total_size:总下载大小 function gw_resDownloadLogSendData(step, pass_time, per, downloaded_size, total_size, start_count) --print(string.format("gw_resDownloadLogSendData(step:%s, pass_time:%s, per:%s, downloaded_size:%s, total_size:%s, start_count:%s)", step, pass_time, per, downloaded_size, total_size, start_count)) if nil == GW_RES_DOWNLOAD_RECORD_URL then return end local body = {} --body.ActionId = 14 body.Ver = GW_ZIP_URL_VER--(int)协议版本号 body.MachineCode = getIdFa()--(string)机器码 body.Channel = 1--(int)渠道:1谷歌;2官方;3IOS body.ClientVersion = 1--(int)客户端版本 body.Platform = 1--(int)平台:1android;2ios;3pc if device.isWifiState() == true then body.NetType = 1--(int)网络制式:wifi--1 else body.NetType = 2--(int)网络制式:数据--2 end body.Step = step or 1--(int)步骤 1开始下载;2下载中;3下载完成 body.StartCount = start_count--(int)重试下载次数(首次为1) body.PassTime = pass_time or 0--(int)从开始下载开始计时,经过的时间(秒)(开始下载为0) body.DownloadedSize = math.ceil(downloaded_size)--(int)已下载大小(byte)(开始下载为0) body.TotalSize = total_size--(int)总下载大小(Kb) local json_str = json.encode(body) local xhr = cc.XMLHttpRequest:new() xhr:setRequestHeader("Content-Type","application/json") xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_STRING xhr:open("POST", GW_RES_DOWNLOAD_RECORD_URL) xhr:registerScriptHandler(function() end) xhr:send(json_str) end --gw新增资源包打点end GW_FORCE_PASS_FOREWORD = false --强制跳过序章