local Login_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local Login_Implement = require("Modules/Login/Login_Implement") local LocalizationCfg = require "Localization/LocalizationCfg" local JSON = require("cjson") local LAST_LOGIN_TIME_KEY = "LAST_LOGIN_TIME" local HIGH_LEVEL_SYMBOL = "HIGH_LEVEL_SYMBOL" --servername:QA4 local serverName = nil --真实的serverId:120004 local serverId = nil --真实的serverId,合服后的真实的服务器id,例:120004合并到120002,则为120002 local realServerId = 0 --用来显示的服务器Id,例:4 local serverShowId = nil --虚拟大区Id,服务器发过来的 local virtualDistrictId = 0 private.isFirstLoginToday = true --是否首日初次登陆 private.isFirstEnterLevel = false --无论是战斗恢复还是第一次进场景 Login_Model.isReConnect = false --客户端和服务器时间相差超过5秒 Login_Model.HasClientServerTimeDiffErrorReported = false --是不是连接的提审服务器 Login_Model.IsReviewService = false --是否成功获取到了公告的信息(主要判断是否设置过提审服的开关) Login_Model.IsGetAnnouncementCfg = false Login_Model.ShardShowState = { ShowState_NewSer= 0, --新服 ShowState_Fluent= 1, --流畅 ShowState_Hot= 2, --火爆 ShowState_Crowd= 3, --拥挤 ShowState_Maintenance= 4, --维护 ShowState_Count= 5 } Login_Model.LoginConstKey = { KEY_LOGIN_USERNAME = "LoginUserName", KEY_LOGIN_PASSWORD = "LoginPassword", } Login_Model.LoginBGTypeEnum = { Texture = 1, Video = 2, } -- v_gid 国内服务器大区 Login_Model.ServerType = { Official= 2, --官网 Channel= 3, --渠道 Fierce= 4, --激战 } Login_Model.LoginBGTypeCfgValue = DataSheetManager.ConstData:GetDataByID("LoginShowType").IntValue --cdn包配置 private.PackageCfgUrlList = nil --网络检测url配置 private.SDKUrlMonitorList = nil private.curPackageCfgUrlIndex = 1 --从PackageCfgUrl拉下来的配置,可能有多个baseurl进行切换 private.CDNBaseUrlList = nil --当前CDNUrl的索引 private.curCDNBaseUrlIndex = 1 --cdn+packageType+packagePostType --Login_Model.CDNFileCfgUrlFormat = "https://%s/%s/%s/gonggao_v1.json?v=%s" Login_Model.CDNFileCfgUrlFormat = "%s/%s/%s/gonggao_v1.json?v=%s" Login_Model.NoticeCfgUrlFormat = "%s/notice/v1/getnotice.txt"; Login_Model.ForceUpdateURL = nil; Login_Model.NormalShardListUrl = "%s/login/v2/shards/%s?deviceId=%s&language=%s&ver=%s&at=%s&channel=%s" Login_Model.WhiteListShardListUrl = "%s/login/v2/shards/%s?deviceId=%s&sp=%s&language=%s&ver=%s&at=%s&channel=%s" Login_Model.WhiteListPwd = nil; --此处是比较短的CG function Login_Model.GetLoginShowPath() if GameAppInfo.IsChinesePackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningLoopCG_CN").StringValue elseif GameAppInfo.IsJapanesePackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningLoopCG_JP").StringValue elseif GameAppInfo.IsVietnamPackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningLoopCG_VN").StringValue else return DataSheetManager.ConstData:GetDataByID("GameOpeningLoopCG_HMT").StringValue end end function Login_Model.GetGameCGMusic(isShortCG) if GameAppInfo.IsChinesePackage() then return isShortCG and "MUSIC_Login" or "MUSIC_Distinguished" elseif GameAppInfo.IsJapanesePackage() then return isShortCG and "MUSIC_Login" or "MUSIC_Distinguished" elseif GameAppInfo.IsOverseaPackage() then return isShortCG and "MUSIC_Login" or "MUSIC_Distinguished" elseif GameAppInfo.IsVietnamPackage() then return isShortCG and "MUSIC_Login" or "MUSIC_Distinguished" end end function Login_Model.GetLoginShowCGPath() if GameAppInfo.IsChinesePackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningCG_CN").StringValue elseif GameAppInfo.IsJapanesePackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningCG_JP").StringValue elseif GameAppInfo.IsVietnamPackage() then return DataSheetManager.ConstData:GetDataByID("GameOpeningCG_VN").StringValue else return DataSheetManager.ConstData:GetDataByID("GameOpeningCG_HMT").StringValue end end function Login_Model.GetLoginShowCGTimeLinePath() if Localization.IsTraditional() then return ConstAssetPathConfig.AssetPath5 elseif Localization.IsChinese() then return ConstAssetPathConfig.AssetPath4 elseif Localization.IsJapanese() then return ConstAssetPathConfig.AssetPath6 elseif GameAppInfo.IsOverseaPackage() then return ConstAssetPathConfig.Path11 elseif GameAppInfo.IsVietnamPackage() then return "Assets/TimeLine/Prefabs/StagePlay/StagePlay_99_99_009.prefab" else return "" end end function Login_Model.InitPackageCfgUrlList() if DEF.Package_PostType == "dev" then private.PackageCfgUrlList = { --"https://jws2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", --"https://dl2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", --"http://10.3.37.105:8001/cdn/%s/packagecfg.json?v=%s", --"http://10.3.37.105:8001/cdn/%s/packagecfg.json?v=%s", "http://103.206.216.106:8022/jws2/cdn/%s/packagecfg.json?v=%s", "http://103.206.216.106:8022/jws2/cdn/%s/packagecfg.json?v=%s", } private.SDKUrlMonitorList = { "103.206.216.106", "103.206.216.106", } elseif GameAppInfo.IsChinesePackage() then private.PackageCfgUrlList = { "https://jws2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", "https://dl2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", } private.SDKUrlMonitorList = { "jws2-global.taiplat.com", "dl2-global.taiplat.com", } else private.PackageCfgUrlList = { "https://dl2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", "https://jws2-global.taiplat.com/cdn/%s/packagecfg.json?v=%s", } private.SDKUrlMonitorList = { "dl2-global.taiplat.com", "jws2-global.taiplat.com", } end EventSystem.Dispatch(EventID.SDKUrlMonitor_RegistMonitorUrl, LuaConst.SDKMonitorType.PackageCfgUrl, private.SDKUrlMonitorList[private.curPackageCfgUrlIndex]) end function Login_Model.GetPackageCfgUrl() return private.PackageCfgUrlList[private.curPackageCfgUrlIndex] end function Login_Model.SwitchPackageCfgUrl() if private.curPackageCfgUrlIndex >= #private.PackageCfgUrlList then private.curPackageCfgUrlIndex = 1 else private.curPackageCfgUrlIndex = private.curPackageCfgUrlIndex+1 end EventSystem.Dispatch(EventID.SDKUrlMonitor_RegistMonitorUrl, LuaConst.SDKMonitorType.PackageCfgUrl, private.SDKUrlMonitorList[private.curPackageCfgUrlIndex]) logging.crit(LTAG.CRIT, "切换PackageCfgUrl", Login_Model.GetPackageCfgUrl()) end function Login_Model.SetCDNBaseUrlList(cdnBaseUrlList) private.CDNBaseUrlList = cdnBaseUrlList private.curCDNBaseUrlIndex = 1 EventSystem.Dispatch(EventID.SDKUrlMonitor_RegistMonitorUrl, LuaConst.SDKMonitorType.CDN, cdnBaseUrlList) end function Login_Model.GetCDNBaseUrl() return private.CDNBaseUrlList[private.curCDNBaseUrlIndex] end function Login_Model.GetCDNBaseUrlList() return private.CDNBaseUrlList end function Login_Model.SwitchCDNBaseUrl() if private.curCDNBaseUrlIndex >= #private.CDNBaseUrlList then private.curCDNBaseUrlIndex = 1 else private.curCDNBaseUrlIndex = private.curCDNBaseUrlIndex+1 end logging.crit(LTAG.CRIT, "切换CDN", Login_Model.GetCDNBaseUrl()) EventSystem.Dispatch(EventID.Base_SwitchBaseCDNUrl) end local ShardInfo = { _shardId = 0, _shardName = "", _shardState = Login_Model.ShardShowState.ShowState_NewSer, _virtualDistrictId = 0, } local announceList = nil function Login_Model.GetShardInfo(shardId, shardName, shardState, shardVirtualDistrictId) local shardInfo = ShardInfo shardInfo._shardId = shardId shardInfo._shardName = shardName shardInfo._shardState = shardState shardInfo._virtualDistrictId = shardVirtualDistrictId return shardInfo end function Login_Model.GetIsFirstLoginToday() return private.isFirstLoginToday end --设置登陆的时间戳,判断是否为今日首次登陆 function private.SetFirstLogin(force) if force then private.isFirstLoginToday = true else local lastTime = PersistentData.PlayerData:Get(LAST_LOGIN_TIME_KEY,0) if lastTime > 0 and UTL.Time.IsTimestampCrossDay(lastTime) == false then private.isFirstLoginToday = false else private.isFirstLoginToday = true end end PersistentData.PlayerData:Set(LAST_LOGIN_TIME_KEY, UTL.Time.GetServerTimestamp(),true) end --登录请求 function Login_Model.AuthInfoRequest(tmpUserName,tmpPassword) if string.len(tmpPassword) == 0 or string.len(tmpUserName) == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERROR_NETWORK_AUTH_20000"]) return end Login_Implement.AuthInfoRequest(tmpUserName,tmpPassword) end --SDK登录请求 function Login_Model.SDKAuthInfoRequest(username) Login_Implement.SDKAuthInfoRequest("quick", username) end --进入游戏 function Login_Model.ClickStartGame(shardInfo) private.startGameShardInfo = shardInfo if DEF.OPEN_STAGE_DOWNLOAD then if LoginProxy.Get_IfAllDownload() == false then local shard = Login_Model.GetShardInfoByID(shardInfo._shardId) if shard and not string.isNilOrEmpty(shard.mainline_level) then --已经过了该分包的进度却没有这个分包,需要全部下完 local tarLevel = DataSheetManager.ConstData:GetDataByID("ResourceDownloadNode").IntValue local tarStage = DataSheetManager.ConstData:GetDataByID("StageEnumID").IntValue if (tonumber(shard.mainline_level) >= tarLevel and LoginProxy.GetCurStage() < CTL.HotFix.GetGroupMaxStage(tarStage)) or PersistentData.DeviceData:Get(HIGH_LEVEL_SYMBOL,0) > 0 then logging.warn(LTAG.WARN,"High Level,Need Download Full Stage") --大号标识存到本地 PersistentData.DeviceData:Set(HIGH_LEVEL_SYMBOL, 1, true) CTL.HotFix.ForceOpenStageDownload(private.OnClickStartGame, true) BIManager.DispatchBIClientEvent(BIManager.EventName.ClickStartGameBtn, "ClickInfo", "High Level,Need Download Full Stage", "mainlineLevel", shard.mainline_level, "curStage", LoginProxy.GetCurStage()) return end end else PersistentData.DeviceData:Set(HIGH_LEVEL_SYMBOL, 0, true) end end BIManager.DispatchBIClientEvent(BIManager.EventName.ClickStartGameBtn,"needDownload", 0, "ClickInfo", "StartGame") private.OnClickStartGame() end function private.OnClickStartGame() PersistentData.DeviceData:Set(HIGH_LEVEL_SYMBOL, 0, true) local shardInfo = private.startGameShardInfo Login_Implement.ClickStartGame(shardInfo._shardId, shardInfo._shardName, shardInfo._shardState) serverName = shardInfo._shardName serverId = shardInfo._shardId virtualDistrictId = shardInfo._virtualDistrictId private.startGameShardInfo = nil end function Login_Model.GetServerName() return serverName end --所在的真实服务器Id,例如:120004 string function Login_Model.GetServerId() return serverId end --获取服务器展示id,比如当前是120004,返回4 function Login_Model.GetServerShowId() return serverShowId end --获取真实的服务器id,比如合服后的id function Login_Model.GetRealServerId() return realServerId > 0 and realServerId or serverId end --获取服务器所在的虚拟大区Id function Login_Model.GetVirtualDistrictId() if not virtualDistrictId then logging.error(LTAG.ERROR, "拉取的服务器信息shardInfo中没有虚拟大区相关的字段v_gid,如没有虚拟大区则该字段应为默认值0,而不是没有该字段,请服务器同学检查!!!") end return virtualDistrictId or 0 end --注册账号 function Login_Model.RegisterRequest(tmpUserName,tmpPassword) Login_Implement.RegisterRequest(tmpUserName,tmpPassword) end --账号格式检查 账号只能为英文字母开头,且只能包含英文和数字,长度在6-12之间 function Login_Model.CheckUsername(username) local len = string.len(username) if len<6 or len>12 then return false end local temp = string.match(username, "^%a%w+") if temp~=nil and temp == username then return true end return false end --密码格式检查 密码只能为数字,长度在1-12之间 function Login_Model.CheckPassword(password) local len = string.len(password) if len<1 or len>12 then return false end local temp = string.match(password, "^%d+") if temp~=nil and temp == password then return true end return false end function Login_Model.GetServerListInfo(index) return LoginProxy.GetServerListInfo(index) end function Login_Model.DispatchEvents(eventID,parm1,parm2,parm3,parm4) EventSystem.Dispatch(eventID,parm1,parm2,parm3,parm4) end function private.SortAnnounce(a, b) return a.Priority < b.Priority end -- Kind = 0 -- LocationType = 0 -- Index = 3 -- Body = {"Title":"虚B","Content":"只能看到8服之后的服\n\n如果想要看到1-7服,请调整渠道号变成18或者56"} -- End = 1824912000 -- Title = 虚B -- Priority = 1 -- Type = 1 -- ShowOpenTime = 0 -- time_zone = 8 -- CornerMark = 0 -- SendTime = 0 -- Begin = 1661961600 function Login_Model.SyncAnnouncementList(json) local lua_value = JSON.decode(json) announceList = lua_value -- 处理日服专属下载 MDL.PreDownloadJP.SyncJapanUpdate(nil) -- 先清空一下当前保存的日服更新内容 for _, v in ipairs(announceList) do if v.Kind == CTL.Login.AnnouncementKind.SystemNoticeKind_JapanUpdate then MDL.PreDownloadJP.SyncJapanUpdate(v) end end --Priority table.sort(announceList, private.SortAnnounce) return announceList end function Login_Model.GetAnnouncementList() return announceList end --enterWorld之后,公告列表可以清理掉 function Login_Model.ClearAnnouncementList() announceList = nil end function Login_Model.GetForceUpdateInfo() if announceList ~= nil then for i, v in ipairs(announceList) do if v.Kind == CTL.Login.AnnouncementKind.SystemNoticeKind_Forceupdate then return v end end end return nil end --isBattle : 如果传false,服务器会把玩家踢回主城;如果传true,则不会踢。所以如果是在单机战斗关卡通常要传true,如果是在主城或者联机关卡则传false。 function Login_Model.SendEnterWorld(isBattle,endFrameLen) local msg = NetManager.GetPB("enter_world_pb").EnterWorldReq() msg.EndFrameLen = endFrameLen msg.IsInBattle = isBattle msg.Language = Localization.GetLanguage2Server() NetManager.SendMessage(MessageEnums.MessageEnterWorld,msg) end function Login_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageEnterWorld, private.EnterWorldResponse) NetManager.RegisterMsgCB(MessageEnums.MessageOnConnection, private.ForceHotUpdateCheck) NetManager.RegisterMsgCB(MessageEnums.MessageG2CDailyRefresh,private.G2CDailyRefreshResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushCreateProfile,private.OnCreateRole) EventSystem.Regist(EventID.Level_RealEnterLevel, private.OnRealEnterLevel) EventSystem.Regist(EventID.UI_Login_RefreshLoginServerInfo, private.OnRefreshLoginServerInfo) end local shardList = {} --我的经典区所有角色 local fierceShardList = {} --我的激战区所有角色 local serverList = {} --所有经典服 local fierceServerList = {} --所有激战服 local allServerMap = {} --所有服 k-name(shard)具体服 v-v_gid大区(官网2、渠道3、激战4) function Login_Model.InitServerListInfo(json) private.ResetLoginData() local lua_value = JSON.decode(json) local allServerList = lua_value["shards"] for _, server in ipairs(allServerList) do allServerMap[server["name"]] = server["v_gid"] if server["v_gid"] == Login_Model.ServerType.Fierce then table.insert(fierceServerList,server) else table.insert(serverList,server) end end private.InitShardListInfo() Login_Model.UpdateShardListSS() table.sort(serverList, private.SortServerList) if CTL.Login.IsFierceServerOpen() then Login_Model.UpdateFierceShardListSS() private.lastLoginServerInfo = Login_Model.GetLastLoginServerInfo() table.sort(fierceServerList, private.SortServerList) else if DEF.USE_BATCH_MODE then private.lastLoginServerInfo = BatchAgent.GetShardInfo() or private.lastLoginServerInfo end end if private.lastLoginServerInfo == nil then private.lastLoginServerInfo = Login_Model.GetRecommendServer() end EventSystem.Dispatch(EventID.UI_Login_GetCurShardInfo, private.lastLoginServerInfo["name"], Login_Model.GetFirstAndServerNameByInfo(private.lastLoginServerInfo), private.lastLoginServerInfo["ss"], private.lastLoginServerInfo["v_gid"]) end function private.OnRefreshLoginServerInfo(shardId, shardName, shardState, shardVirtualDistrictId) local shard = Login_Model.GetShardInfoByID(shardId) if DEF.OPEN_STAGE_DOWNLOAD then if LoginProxy.Get_IfAllDownload() == false then if shard and not string.isNilOrEmpty(shard.mainline_level) then --已经过了该分包的进度却没有这个分包,需要全部下完 local tarLevel = DataSheetManager.ConstData:GetDataByID("ResourceDownloadNode").IntValue local tarStage = DataSheetManager.ConstData:GetDataByID("StageEnumID").IntValue if (tonumber(shard.mainline_level) >= tarLevel and LoginProxy.GetCurStage() < CTL.HotFix.GetGroupMaxStage(tarStage)) or PersistentData.DeviceData:Get(HIGH_LEVEL_SYMBOL,0) > 0 then --大号卸载重装的埋点 BIManager.DispatchBIClientEvent(BIManager.EventName.ClickSelectLoginServer, "needDownload", 1, "mainlineLevel", shard.mainline_level, "curStage", LoginProxy.GetCurStage(), "serverId", shardId) return end end end end if shard then --有角色的埋点 BIManager.DispatchBIClientEvent(BIManager.EventName.ClickSelectLoginServer, "needDownload", 0, "mainlineLevel", shard.mainline_level, "curStage", LoginProxy.GetCurStage(), "serverId", shardId) else --无角色的埋点 BIManager.DispatchBIClientEvent(BIManager.EventName.ClickSelectLoginServer, "serverId", shardId) end end function private.ResetLoginData() table.clear(shardList) table.clear(fierceShardList) table.clear(serverList) table.clear(fierceServerList) table.clear(allServerMap) private.lastLoginClassicalShardInfo = nil private.lastLoginFierceShardInfo = nil private.lastLoginServerInfo = nil end function Login_Model.GetLastLoginServerInfo() if CTL.Login.IsFierceServerOpen() then if CTL.Login.IsFierceServerRegion() then if private.lastLoginFierceShardInfo then return Login_Model.GetServerInfoByID(private.lastLoginFierceShardInfo.shard) end else if private.lastLoginClassicalShardInfo then return Login_Model.GetServerInfoByID(private.lastLoginClassicalShardInfo.shard) end end else return private.lastLoginServerInfo end end function Login_Model.GetShardInfoByID(shardId) for i,v in ipairs(shardList) do if v.shard == shardId then return v end end for i,v in ipairs(fierceShardList) do if v.shard == shardId then return v end end return nil end function Login_Model.GetServerInfoByID(id) for i,v in ipairs(serverList) do if v["name"] == id then return v end end for i,v in ipairs(fierceServerList) do if v["name"] == id then return v end end end --当前是否是激战区 function Login_Model.IsFierceServerRegion() return private.isFierceServerRegion or false end -- 获取服务器名称 带区服显示 -- string.find (s, pattern [, init [, plain]]) plain默认为false, 为true时表示关闭匹配机制, 即此时函数仅做直接的 “查找子串”的操作 -- 如果给定了 plain ,就必须写上 init -- info 的格式 -- { -- multi_lang -- 暂时没有赋值,问过服务器暂时没有作用 -- recmd = 1 -- 该服的推荐值,推荐值越高该服的推荐度越高 -- st = 1654462800 -- 该服的开启时间 -- ss = 1 -- 该服的展示状态 -- lang -- 暂时没有赋值,问过服务器暂时没有作用 -- name = 220007 -- 22大区0007服 -- dn = 7.S7-杨琢瑀 -- 该服的展示名字,.前的是几服,-后的是具体名字 -- v_gid = 1 -- 服务器所属的虚拟大区Id -- } function Login_Model.GetFirstAndServerNameByInfo(info) local nameData = info["dn"] local outName = nameData if string.find(nameData, ".", 1, true) then outName = string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, string.split(nameData, ".")[1]) .. " " end if string.find(nameData,"-", 1, true) then outName = outName .. string.split(nameData,"-")[2] end return outName end function Login_Model.GetServerNameByInfo(info) if string.find(info["dn"], "-", 1, true) then return string.split( info["dn"],"-")[2] end return info["dn"] end function Login_Model.GetFirstName(info) if string.find(info["dn"], ".", 1, true) then return string.split( info["dn"],".")[1] end return info["dn"] end local allShardRoleList function Login_Model.InitShardInfo(json) local lua_value = JSON.decode(json) allShardRoleList = lua_value["shardrole"] CTL.Login.ResetInitFierceServerRegion() EventSystem.Dispatch(EventID.UI_Login_OnAuthComplete) end function private.InitShardListInfo() if not allShardRoleList or #allShardRoleList <= 0 then if UNITY_EDITOR and #fierceServerList <= 0 then CTL.Login.InitFierceServerRegionStatus(false) return end if CTL.Login.IsFierceServerOpen() then CTL.Login.InitFierceServerRegionStatus(true) end return end if CTL.Login.IsFierceServerOpen() then for _, shard in ipairs(allShardRoleList) do if allServerMap[shard["shard"]] == Login_Model.ServerType.Fierce then if not private.lastLoginFierceShardInfo then private.lastLoginFierceShardInfo = shard end table.insert(fierceShardList, shard) else if not private.lastLoginClassicalShardInfo then private.lastLoginClassicalShardInfo = shard end table.insert(shardList, shard) end end if private.lastLoginClassicalShardInfo and private.lastLoginFierceShardInfo then if private.lastLoginFierceShardInfo["llt"] < private.lastLoginClassicalShardInfo["llt"] then CTL.Login.InitFierceServerRegionStatus(false) private.lastLoginServerInfo = Login_Model.GetServerInfoByID(private.lastLoginClassicalShardInfo.shard) else CTL.Login.InitFierceServerRegionStatus(true) private.lastLoginServerInfo = Login_Model.GetServerInfoByID(private.lastLoginFierceShardInfo.shard) end elseif private.lastLoginClassicalShardInfo then CTL.Login.InitFierceServerRegionStatus(false) private.lastLoginServerInfo = Login_Model.GetServerInfoByID(private.lastLoginClassicalShardInfo.shard) elseif private.lastLoginFierceShardInfo then CTL.Login.InitFierceServerRegionStatus(true) private.lastLoginServerInfo = Login_Model.GetServerInfoByID(private.lastLoginFierceShardInfo.shard) end else for _, shard in ipairs(allShardRoleList) do if allServerMap[shard["shard"]] ~= Login_Model.ServerType.Fierce then if not private.lastLoginServerInfo then private.lastLoginServerInfo = Login_Model.GetServerInfoByID(shard.shard) end if not private.lastLoginClassicalShardInfo then private.lastLoginClassicalShardInfo = shard end table.insert(shardList, shard) end end end end function Login_Model.UpdateShardListSS() for _, shard in ipairs(shardList) do for _, server in ipairs(serverList) do if shard.shard == server.name then shard.ss = server.ss end end end end function Login_Model.UpdateFierceShardListSS() for _, shard in ipairs(fierceShardList) do for _, server in ipairs(fierceServerList) do if shard.shard == server.name then shard.ss = server.ss end end end end function Login_Model.GetHaveRoleShardList() return shardList end function Login_Model.GetHaveRoleFierceShardList() return fierceShardList end function Login_Model.GetRoleNameAndServerId() if CTL.Login.IsFierceServerOpen() and CTL.Login.IsFierceServerRegion() then if private.lastLoginFierceShardInfo then return private.lastLoginFierceShardInfo.name , private.lastLoginFierceShardInfo.shard end else if private.lastLoginClassicalShardInfo then return private.lastLoginClassicalShardInfo.name , private.lastLoginClassicalShardInfo.shard end end end function Login_Model.GetServerList() return serverList end function Login_Model.GetFierceServerList() return fierceServerList end function Login_Model.GetRencentList(tmpServerList) if not tmpServerList then tmpServerList = serverList end local list = {} for i,v in ipairs(tmpServerList) do local serverState = tonumber(v.ss) if v.recmd > 0 and (serverState == MDL.Login.ShardShowState.ShowState_NewSer or serverState == MDL.Login.ShardShowState.ShowState_Fluent or serverState == MDL.Login.ShardShowState.ShowState_Count) then table.insert(list,v) end end if #list > 0 then local language = LocalizationCfg.GameToSdkLanguage(Localization.GetLanguage()) table.sort(list, function(a, b) if a.recmd == b.recmd then if a.recmd_lang == language then return true elseif b.recmd_lang == language then return false end end return a.recmd > b.recmd end) else table.insert(list, tmpServerList[#tmpServerList]) end return list end function Login_Model.GetRecommendServer() local server = nil local rencentList if CTL.Login.IsFierceServerOpen() and CTL.Login.IsFierceServerRegion() then rencentList = Login_Model.GetRencentList(fierceServerList) else rencentList = Login_Model.GetRencentList(serverList) end if UNITY_EDITOR and #rencentList <= 0 then rencentList = Login_Model.GetRencentList(serverList) end local randomNum = 0 --推荐值最高且有多个一致的,需要随机取,而不是固定第一个 local lastRecmd = rencentList[1].recmd for i,v in ipairs(rencentList) do if i > 1 and lastRecmd == v.recmd then randomNum = randomNum + 1 end end if not server then if randomNum > 0 then local randomId = math.random(randomNum + 1) server = rencentList[randomId] else server = rencentList[1] end end return server end function private.EnterWorldErrorMsg(msg) logging.error(LTAG.ERROR, "EnterWorldResponse执行失败", msg) end --只会在第一次进入场景的时候调用,现在只可能是进入主城场景 --设置数据与执行逻辑尽量分开,同步数据时,只设置本模块的数据即可,不应该有任何的事件派发等,如果需要和其他模块交互,监听InitServerDataOver function private.EnterWorldResponse(msgResp) --收到EnterWorld重置为false状态 private.isFirstEnterLevel = false Login_Model.ClearAnnouncementList() local roleDetailInfo = msgResp.DetailInfo realServerId = roleDetailInfo.realServerID or 0 serverShowId = roleDetailInfo.serName or 0 xpcall(PersistentData.SetPlayerAccid, private.EnterWorldErrorMsg, roleDetailInfo.acid) -- ---【注意】----初始化信息时优先初始化公用信息,角色信息、任务相关的靠前放,功能类的放在后面---------------------- --------基础角色类信息---------------------- xpcall(MDL.Name.SetLastNamedTime, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.lastNamedTime) xpcall(MDL.Name.SetNamedFreeNums, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.NamedFreeNums) xpcall(MDL.Player.SetRoleId, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.player_id) xpcall(MDL.Player.SetSelfGender, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.sex) xpcall(MDL.Player.SetRoleInfo, private.EnterWorldErrorMsg, roleDetailInfo.RoleInfo.TeamLevel, msgResp.DetailInfo.RoleInfo.TeamLevelExp, msgResp.DetailInfo.RoleInfo.TeamRankID, msgResp.DetailInfo.RoleInfo.attr, msgResp.DetailInfo.RoleInfo.Gs) xpcall(MDL.Player.SetHeroLineUpInfo, private.EnterWorldErrorMsg, roleDetailInfo.HeroLineUp.LineUpHeroIds, msgResp.DetailInfo.HeroLineUp.LineUpHeroGs, msgResp.DetailInfo.HeroLineUp.ThreeTeamGs) --这里的HeroLineUp是上阵的缩略信息,不能用于战斗初始化,因为信息量不够 xpcall(MDL.Player.SetServerDay, private.EnterWorldErrorMsg, roleDetailInfo.serverDay) xpcall(MDL.Player.SetServerOpenTs, private.EnterWorldErrorMsg, roleDetailInfo.srv_open_ts) xpcall(MDL.Player.UpdateLineUpGs, private.EnterWorldErrorMsg, roleDetailInfo.HeroLineUp.LineUpGs, true) xpcall(MDL.Player.SetEnergyInfo, private.EnterWorldErrorMsg, roleDetailInfo.energyInfo) xpcall(MDL.Player.SetCurShowId, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.HeroId) xpcall(NotSyncBattleSetter.SetPlayerInfo, private.EnterWorldErrorMsg, roleDetailInfo.acid, roleDetailInfo.baseInfo.name) xpcall(MDL.ChannelChat.InitChannelSettingMsgFlag, private.EnterWorldErrorMsg) AuxUtil.SetRoleInfo(roleDetailInfo.acid, roleDetailInfo.baseInfo.HeroId, roleDetailInfo.baseInfo.name) logging.crit(LTAG.CRIT, "玩家Id", roleDetailInfo.acid, roleDetailInfo.baseInfo.player_id) AuxUtil.BuglyAgentSetUserId(roleDetailInfo.acid) if CTL.WinLogin.IsUsePCNtSdk() then SDKUtil.EnterGame(roleDetailInfo.RoleInfo.TeamLevel, roleDetailInfo.createTime) elseif GameAppInfo.IsPCPackageWithSdk() then CTL.WinLogin.UploadRoleInfo() else SDKUtil.EnterGame(roleDetailInfo.RoleInfo.TeamLevel, roleDetailInfo.createTime) end xpcall(MDL.DailySignin.SyncCanRepairTime, private.EnterWorldErrorMsg, roleDetailInfo.createTime) xpcall(MDL.Player.SetCreatePlayerTime, private.EnterWorldErrorMsg, roleDetailInfo.createTime) BIManager.OnEnterWorldResponse() --是否首次建号,英雄首次建号就发创建账号信息,我们的游戏是起完名字才算真正的建号,创角和登录放到前面,提前点好 if msgResp.isNewRole then if not GameAppInfo.IsVietnamPackage() then --越南这里不要打下面的埋点,否则会导致中台多埋一个空埋点。 SDKUtil.CreateNewRole() end EventSystem.Dispatch(EventID.BI_ClientEvent,BIManager.EventName.BDC_CreateRole,BIManager.BDCEventParam.creat_role_state_key, BIManager.BDCEventParamValue.Creat_Role_State_Send , BIManager.BDCEventParam.creat_fail_reason_key, "") end BIManager.DispatchBIClientEvent(BIManager.EventName.BDC_RoleLogin,BIManager.BDCEventParam.role_login_state, BIManager.BDCEventParamValue.Role_Login_State_Success, BIManager.BDCEventParam.role_login_reason, "", "ads_json", "1") --数数和AppsFlyer绑定 if not GameAppInfo.IsPCPackage() and GameAppInfo.IsOverseaPackage() and GameAppInfo.IsVersionGreaterThan110000() then SDKUtil.TEEnableThirdPartySharing(roleDetailInfo.acid) end xpcall(MDL.HeroSelect.InitHeroesInfoInit, private.EnterWorldErrorMsg, roleDetailInfo.heroList) xpcall(MDL.HeroSelect.InitRelationInfo, private.EnterWorldErrorMsg, roleDetailInfo.heroRelations) xpcall(MDL.Currency.UpdateSoftTokenList, private.EnterWorldErrorMsg, MessageEnums.MessageEnterWorld, roleDetailInfo.SCInfos, true) xpcall(MDL.Currency.UpdateHardTokenList, private.EnterWorldErrorMsg, MessageEnums.MessageEnterWorld, roleDetailInfo.HCInfos, true) xpcall(MDL.Currency.SyncRechargeAmount, private.EnterWorldErrorMsg, roleDetailInfo.rechargeInfo) xpcall(MDL.RedPoint.SetOneTimeRedPointInfo, private.EnterWorldErrorMsg, roleDetailInfo.redRotAllInfo.infos) xpcall(MDL.Unlock.InitDebugUnlock, private.EnterWorldErrorMsg, msgResp.DebugSwitchInfo) xpcall(MDL.Unlock.InitServerUnlock, private.EnterWorldErrorMsg, msgResp.GameFunctionSwitchInfo) xpcall(MDL.Bag.SetBagInfo, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.materials, roleDetailInfo.bagInfo.shreds, roleDetailInfo.bagInfo.consumables, roleDetailInfo.bagInfo.pets) xpcall(MDL.Bag.SetBagHeroSubstituteItemInfo, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.heroSubstituteItemExtra) xpcall(MDL.Equipment.SetEquipInfo, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.equips, roleDetailInfo.bagInfo.equipExtras, roleDetailInfo.bagInfo.equipShreds) xpcall(MDL.Treasure.SyncBagSoulCrystal, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.soulCrystals, roleDetailInfo.bagInfo.soulCrystalExtras) xpcall(MDL.HorseSoul.InitBagSoulPearl, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.soulPearls, roleDetailInfo.bagInfo.soulPearlExtras) xpcall(MDL.HorseEquip.InitHorseEquipBag, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.horseEquip) xpcall(MDL.GemCompose.SetGemBagInfo, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.jewelry) xpcall(MDL.Task.SetRingRound, private.EnterWorldErrorMsg, roleDetailInfo.ringTaskNum) xpcall(MDL.Task.InitTaskInfo, private.EnterWorldErrorMsg, roleDetailInfo.taskInfo.finishedTaskLine, roleDetailInfo.taskInfo.doingTasks, roleDetailInfo.taskInfo.finishNoCommit) xpcall(MDL.PlayerGuide.SetFinishInfo, private.EnterWorldErrorMsg, roleDetailInfo.finishedGuide) xpcall(MDL.Task.SetTreasureRewardInfo, private.EnterWorldErrorMsg, roleDetailInfo.digTreasureRewardInfo) xpcall(MDL.Team.SetTeamInfo, private.EnterWorldErrorMsg, roleDetailInfo.teamInfo) xpcall(MDL.SpecialTeam.InitTeamInfo, private.EnterWorldErrorMsg, roleDetailInfo.teamWarInfo) xpcall(MDL.Team.ReloadApplicantsInfo, private.EnterWorldErrorMsg, roleDetailInfo.applicants) xpcall(MDL.SpecialTeam.ReloadApplicantsInfo, private.EnterWorldErrorMsg, roleDetailInfo.teamWarApplicants) xpcall(MDL.LevelSelect.SetStoryInfo, private.EnterWorldErrorMsg, roleDetailInfo.levelInfos, true) xpcall(MDL.Player.UpdateHeroInfDict, private.EnterWorldErrorMsg, roleDetailInfo.HeroLineUp.LineUpHeroIds) -- 神兽 xpcall(MDL.GodBeast.SyncGodBeastInfo, private.EnterWorldErrorMsg, roleDetailInfo.godBeastInfo) -- 坐骑 xpcall(MDL.WarHorse.SyncHorseInfo, private.EnterWorldErrorMsg, roleDetailInfo.horseInfoList, roleDetailInfo.heroList) -- 坐骑皮肤 xpcall(MDL.WarHorse.SyncHorseAppearanceInfo, private.EnterWorldErrorMsg, roleDetailInfo.horseAppearance, roleDetailInfo.horseInfoList) -- 坐骑魂珠-聚魂(抽卡) xpcall(MDL.HorseSoul.SyncDrawHorseSoulInfo, private.EnterWorldErrorMsg, roleDetailInfo.drawHorseSoulInfo) xpcall(MDL.Treasure.UpdateActiveTreasureInfo, private.EnterWorldErrorMsg, MessageEnums.MessageEnterWorld, roleDetailInfo.treasureInfo,roleDetailInfo.heroList) xpcall(MDL.Formation.UpdateSlotHeroIds, private.EnterWorldErrorMsg, roleDetailInfo.HeroLineUp.FormationSlotHeroIds) xpcall(MDL.OperationActivity.SetOAInfo, private.EnterWorldErrorMsg, roleDetailInfo.hotActivityData, roleDetailInfo.operActivityInfo) xpcall(MDL.Activities.SetActiveData, private.EnterWorldErrorMsg, roleDetailInfo.activityInfo) xpcall(MDL.OfficialPrivilege.SyncPrivilegeInfo, private.EnterWorldErrorMsg, roleDetailInfo.privilegeInfo) xpcall(MDL.OfficialPosition.SyncOfficialInfo, private.EnterWorldErrorMsg, roleDetailInfo.officialInfo, true) xpcall(MDL.FairPlay.UpdateFairPlayInfo, private.EnterWorldErrorMsg, roleDetailInfo.fairplayInfo) xpcall(MDL.CustomRoom.SetRoomInfo, private.EnterWorldErrorMsg, roleDetailInfo.customRoomInfo) xpcall(MDL.SyncTeamPVP.UpdateTVTSeasonInfo, private.EnterWorldErrorMsg, roleDetailInfo.fairPlaySeasonInfo.tvtSeasonInfo) xpcall(MDL.SyncSolo.UpdateSyncSoloSeasonInfo, private.EnterWorldErrorMsg, roleDetailInfo.fairPlaySeasonInfo.soloSeasonInfo) xpcall(MDL.BossChallenge.UpdateBossChallengeSeasonInfo, private.EnterWorldErrorMsg, roleDetailInfo.bosschallengeSeasonInfo) xpcall(MDL.BossChallenge.SetBossDifficultScore, private.EnterWorldErrorMsg, roleDetailInfo.bossChallengeInfos.infos) xpcall(MDL.Biography.SetBiographyInfoMsg, private.EnterWorldErrorMsg, roleDetailInfo.heroBiographyInfo) xpcall(MDL.HomeMain.SyncCapitalBuff, private.EnterWorldErrorMsg, roleDetailInfo.capitalBuffInfos) xpcall(MDL.ChannelChat.SetFirstPassLevelForNew, private.EnterWorldErrorMsg, roleDetailInfo.guideStep) xpcall(MDL.RebelStrike.SyncAwardTimes, private.EnterWorldErrorMsg, roleDetailInfo.rebelStrikeInfo) xpcall(MDL.Title.SyncTitleInfo, private.EnterWorldErrorMsg, roleDetailInfo.titleInfos, true) xpcall(MDL.SoloFight.SetSoloFightInfo, private.EnterWorldErrorMsg, roleDetailInfo.soloFightInfo) if roleDetailInfo.fighterInfo then xpcall(MDL.SyncTeamPVP.InitFighterProperties, private.EnterWorldErrorMsg, roleDetailInfo.fighterInfo) end if (IsServerDataNotNil(roleDetailInfo.climbTowerInfos)) then xpcall(MDL.ClimbTower.SyncClimbTowerInfo, private.EnterWorldErrorMsg, roleDetailInfo.climbTowerInfos) end xpcall(MDL.NationClimbTower.SyncFourNationClimbTowerInfo, private.EnterWorldErrorMsg, roleDetailInfo.fourNationTowerInfo, true) -- 四国爬塔 xpcall(MDL.DrawCard.RefreshCardInfoByServer, private.EnterWorldErrorMsg, roleDetailInfo.drawCardInfo) xpcall(MDL.WorldBoss.InitData, private.EnterWorldErrorMsg, roleDetailInfo.worldbossInfo) -- 世界Boss xpcall(MDL.CountryWorldBoss.SyncCountryWorldBossBossInfo, private.EnterWorldErrorMsg, roleDetailInfo.warZoneBossInfo) -- 战区Boss xpcall(MDL.PersonalBoss.SyncPersonalBossInfo, private.EnterWorldErrorMsg, roleDetailInfo.personalBossInfo) xpcall(MDL.DemonGod.EnterDemonGodInfoRequest, private.EnterWorldErrorMsg, roleDetailInfo.demonGodInfo) xpcall(MDL.Setting.SyncSettingInfo, private.EnterWorldErrorMsg, roleDetailInfo.settingInfo) xpcall(MDL.HotFix.SyncStagePackageAward, private.EnterWorldErrorMsg, roleDetailInfo.receiveStagePackageAward) xpcall(MDL.HotFix.SyncAwardPackageStage, private.EnterWorldErrorMsg, roleDetailInfo.awardPackageStage) xpcall(MDL.Questionnaire.SetQuestionnaireReward, private.EnterWorldErrorMsg, roleDetailInfo.questionnairAwards, false) xpcall(MDL.OnlineReward.SetOnlineRewardInfo, private.EnterWorldErrorMsg, roleDetailInfo.onlineRewardInfo) xpcall(MDL.Guild.SetMyGuildInfo, private.EnterWorldErrorMsg, MessageEnums.MessageEnterWorld, roleDetailInfo.guildInfo, true) xpcall(MDL.GuildTarget.InitGuildTargetData, private.EnterWorldErrorMsg, roleDetailInfo.guildTargetInfo) -- 金将活动 xpcall(MDL.GoldenHeroMain.SetGoldHeroEnergyInfo, private.EnterWorldErrorMsg, roleDetailInfo.goldHeroEnergy) xpcall(MDL.GoldenHeroMain.SetActivityConsumeList, private.EnterWorldErrorMsg, roleDetailInfo.activityStores) xpcall(MDL.GoldenHeroStory.SyncPullGoldHeroSecretInfo, private.EnterWorldErrorMsg, roleDetailInfo.goldHeroSecretInfos) -- 金将活动-秘闻 xpcall(MDL.GoldenHeroAnecdote.RefreshAnecdoteInfo, private.EnterWorldErrorMsg, roleDetailInfo.GoldHeroAnecdotes) xpcall(MDL.FightThrone.SyncFightThroneInfo, private.EnterWorldErrorMsg, roleDetailInfo.fightThroneInfo) xpcall(MDL.DragonArtery.SyncEnterInfo, private.EnterWorldErrorMsg, roleDetailInfo.dragonEnterInfo) xpcall(MDL.TeamDungeon.SyncLeftAwardCount, private.EnterWorldErrorMsg, roleDetailInfo.teamPVEInfo) xpcall(MDL.Cutscene.SyncCutsceneInfo, private.EnterWorldErrorMsg, roleDetailInfo.timeLineAwardList) xpcall(MDL.MultiplayerDungeon.SyncMultiplayerDungeonInfo, private.EnterWorldErrorMsg, roleDetailInfo.multiPlayerDungeonInfo) -- 登录同步多人副本剩余奖励次数 xpcall(MDL.GuildCultivation.SetGuildCultivationInfo, private.EnterWorldErrorMsg, roleDetailInfo.guildCultivateInfo) xpcall(MDL.MaterialLevel.SetInfo, private.EnterWorldErrorMsg, roleDetailInfo.resourceLevelInfo) xpcall(MDL.FirstCharge.SyncFirstChargeInfo, private.EnterWorldErrorMsg, roleDetailInfo.firstChargeGiftInfo) xpcall(CompareSyncLogManager.SetNeedSendToServerLog, private.EnterWorldErrorMsg, MDL.Unlock.GetDebugSwitchState(MDL.Unlock.DebugSwitchType.TypeUploadBattleLog3v3)) --势力驻地活动经验次数 xpcall(MDL.GuildParty.SetLeftActivityExpTimes, private.EnterWorldErrorMsg, roleDetailInfo.guildPartyInfo); -- 拍卖行 xpcall(MDL.GuildAuction.SetShowGuildAuctionTypes, private.EnterWorldErrorMsg, roleDetailInfo.personalAuctionHouse) -- 成就 xpcall(MDL.Achievement.SetAchievementInfos, private.EnterWorldErrorMsg, roleDetailInfo.achievementSystemInfo, true) -- 阵位共鸣 xpcall(MDL.FormationResonance.SetResonanceInfo, private.EnterWorldErrorMsg, roleDetailInfo.resonanceInfo) -- 武将图鉴 xpcall(MDL.HeroLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --神兵图鉴 xpcall(MDL.WeaponLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --坐骑图鉴 xpcall(MDL.HorseLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --宝物图鉴 xpcall(MDL.TreasureLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --计略图鉴 xpcall(MDL.StratagemLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --这enterWorld里不用放stratagemPictorialInfo信息了,下面计略系统会获取 -- 神兽图鉴 xpcall(MDL.GodBeastLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --光效图鉴 xpcall(MDL.EffectLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --皮肤图鉴 xpcall(MDL.AppearanceLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) --染色图鉴 xpcall(MDL.DyeLibrary.SetLibraryInfo, private.EnterWorldErrorMsg, roleDetailInfo.pictorialBookInfo) xpcall(CTL.Title.ShowOfflineMsg, private.EnterWorldErrorMsg, roleDetailInfo.loginTitleInfos) --离线的一些变化,需要上线做表现 if roleDetailInfo.onLoginGs > 0 then xpcall(MDL.Player.ShowGSChangeExp, private.EnterWorldErrorMsg, roleDetailInfo.HeroLineUp.LineUpGs, roleDetailInfo.onLoginGs) end xpcall(MDL.Nobility.EnterWorldSyncNobilityInfo, private.EnterWorldErrorMsg, roleDetailInfo.nobilityInfo) -- 登录同步爵位进度信息 -- 阵位助战 if IsServerDataNotNil(roleDetailInfo.assistanceData) then xpcall(MDL.AssistanceFight.SetSlotInfos, private.EnterWorldErrorMsg, roleDetailInfo.assistanceData.slotInfos) xpcall(MDL.AssistanceFight.SetFormationSlotHeroAttrDatas, private.EnterWorldErrorMsg, roleDetailInfo.assistanceData.lineups) end -- 等级礼包 xpcall(MDL.Reward.UpdateLevelGiftClaim, private.EnterWorldErrorMsg, roleDetailInfo.levelGiftInfo) -- 累充礼包 xpcall(MDL.MultilevelRecharge.SetMultilevelChargeGiftInfo, private.EnterWorldErrorMsg, roleDetailInfo.multilevelChargeGiftInfo) xpcall(CTL.Notification.InitNotification, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.appPushRewardState) --战区id,加入战区聊天 xpcall(MDL.ChannelChat.SetWarZoneId, private.EnterWorldErrorMsg, roleDetailInfo.warZoneId) --region ************** 福利 ************** -- 每日礼包 xpcall(MDL.DailyGift.SyncDailyGiftInfo, private.EnterWorldErrorMsg, roleDetailInfo.dailyGift) -- 月卡 xpcall(MDL.MonthCard.SetMonthCardInfo, private.EnterWorldErrorMsg, roleDetailInfo.monthCardInfos) xpcall(MDL.MonthCard.SetHadAllMonthCardActive, private.EnterWorldErrorMsg, roleDetailInfo.baseInfo.hadAllMonthCardActive) -- 基金 xpcall(MDL.GrowthFund.SyncFundInfo, private.EnterWorldErrorMsg, roleDetailInfo.fundInfos) -- 名将之路 xpcall(MDL.HeroFund.SyncHeroFundInfo, private.EnterWorldErrorMsg, roleDetailInfo.heroFundInfo) -- 奖励找回 xpcall(MDL.RewardsRetrieve.SyncRewardRecoveryInfo, private.EnterWorldErrorMsg, roleDetailInfo.ResourceInfos) -- 充值返利 xpcall(MDL.RechargeReturn.InitRechargeReturnCount, private.EnterWorldErrorMsg, roleDetailInfo.payRewardInfo) -- 预约豪礼,服务器下发是否弹窗 xpcall(MDL.ReservedGift.SyncReservedGiftState, private.EnterWorldErrorMsg, roleDetailInfo.reservedGiftState) -- 每日签到 xpcall(MDL.DailySignin.SyncSigninInfo, private.EnterWorldErrorMsg, roleDetailInfo.dailySigninInfo) -- 大包更新提示 xpcall(MDL.VersionUpdate.SetUpdateInfos, private.EnterWorldErrorMsg, roleDetailInfo.versionUpdateInfo) -- 休沐祭礼 xpcall(MDL.WeekendReward.SyncWeekendRewardInfo, private.EnterWorldErrorMsg, roleDetailInfo.weekendRewardInfo) -- 国服公测福利功能(仅公测使用,之后会将整个功能移除掉) xpcall(MDL.TestWelfare.SyncTestWelfareInfo, private.EnterWorldErrorMsg, roleDetailInfo.loginRankRewardInfo) --endregion ************** 福利 ************** -- 商城 xpcall(MDL.PayMall.SetStoreInfos, private.EnterWorldErrorMsg, roleDetailInfo.storeInfos) -- 武将外观 if IsServerDataNotNil(roleDetailInfo.appearanceInfos) then xpcall(MDL.Appearance.SyncRefreshAppearanceList, private.EnterWorldErrorMsg, roleDetailInfo.appearanceInfos, true) end -- 红包状态 xpcall(MDL.RedPacket.SyncRedPacketReceiveTimesAndRedPoint, private.EnterWorldErrorMsg, roleDetailInfo.redEnvelopInfo) -- 仇人系统——设置 And 恩怨簿红点 xpcall(MDL.Rival.SyncRivalBriefInfo, private.EnterWorldErrorMsg, roleDetailInfo.rivalBriefInfo) -- 头像 xpcall(MDL.Character.SyncPortraitsList, private.EnterWorldErrorMsg, roleDetailInfo.portraitInfos) -- 头像框 xpcall(MDL.Character.SyncFramesList, private.EnterWorldErrorMsg, roleDetailInfo.frameInfos) -- 开放金品质列表 xpcall(MDL.HideGolden.SetOpenGoldenList, private.EnterWorldErrorMsg, roleDetailInfo.goldenInfo) -- 外观_光效 xpcall(MDL.LightEffect.SyncLightEffectInfoDic, private.EnterWorldErrorMsg, roleDetailInfo.lightEffectInfos) xpcall(MDL.LightEffect.SyncLightEffectPictorialInfo, private.EnterWorldErrorMsg, roleDetailInfo.lightEffectPictorial, true) xpcall(MDL.RedPoint.SetEnterWorldRedPointList, private.EnterWorldErrorMsg, roleDetailInfo.redPoints) -- 系统登录红点列表 -- 排行榜点赞信息 xpcall(MDL.Rank.SyncRankThumbsUpInfo, private.EnterWorldErrorMsg, roleDetailInfo.RankThumbsUpInfo) -- 势力战跨服预告 xpcall(MDL.GuildWar.SyncGuildWarCrossOpen, private.EnterWorldErrorMsg, roleDetailInfo.guildWarCrossOpen) -- 押镖 xpcall(MDL.GuildEscort.SyncEscortBase, private.EnterWorldErrorMsg, roleDetailInfo.escortBase) xpcall(MDL.GuildEscort.SyncEscortCart, private.EnterWorldErrorMsg, roleDetailInfo.cart) xpcall(MDL.GuildEscort.SyncEscortRivals, private.EnterWorldErrorMsg, roleDetailInfo.escortRival) --1v1 公平竞技奖励信息 xpcall(MDL.SyncSolo.SyncRewardInfo, private.EnterWorldErrorMsg, roleDetailInfo.fairPlaySoloRewardInfo) --3v3 公平竞技奖励信息 xpcall(MDL.SyncTeamPVP.SyncTeamPVPRewardInfo, private.EnterWorldErrorMsg, roleDetailInfo.battleRewardInfo) --region **************** 天地群雄 ***************** -- 天地群雄 1V1个人赛 xpcall(MDL.HeroMatch1v1.SyncHeroMatch1v1Info, private.EnterWorldErrorMsg, roleDetailInfo.heroMatch1v1Info) xpcall(MDL.HeroMatch3v3.SyncHeroMatch3v3Info, private.EnterWorldErrorMsg, roleDetailInfo.heroMatch3v3Info) -- 天地群雄 膜拜信息 xpcall(MDL.HeroMatch1v1.SyncHeroMatchWorshipInfo, private.EnterWorldErrorMsg, roleDetailInfo.worshipInfo) xpcall(MDL.HeroMatch3v3.SyncHeroMatchWorshipInfo, private.EnterWorldErrorMsg, roleDetailInfo.worshipInfo3V3) --endregion **************** 天地群雄 ***************** -- 通用布阵信息 xpcall(MDL.FreeLineUp.SyncCommonLineUpInfo, private.EnterWorldErrorMsg, roleDetailInfo.commonLineUpInfo) -- 0元购礼包 xpcall(MDL.FreeBuy.SyncActivityInfo, private.EnterWorldErrorMsg, roleDetailInfo.freePurchaseInfo) -- 一站到底 if IsServerDataNotNil(roleDetailInfo.scene_quiz_login_info) then xpcall(MDL.SceneQuiz.SetBasicInfo, private.EnterWorldErrorMsg, roleDetailInfo.scene_quiz_login_info) end -- 关注有礼 xpcall(MDL.Attention.SyncPushInterFaceInfo, private.EnterWorldErrorMsg, roleDetailInfo.pushInterFaceInfos) -- 服务器下发道具来源信息 xpcall(MDL.ItemSources.SyncServerItemSourcesMapData, private.EnterWorldErrorMsg, roleDetailInfo.itemResInfos) -- 战区数据 xpcall(MDL.WarZone.ShowInterfacePanel, private.EnterWorldErrorMsg, roleDetailInfo.warZoneTimeInfo) -- 神兵锻造 xpcall(MDL.DivineWeapon.SetForgeInfos, private.EnterWorldErrorMsg, roleDetailInfo.foundryActivateInfo) -- VIP邀请函 xpcall(MDL.VIP.SetVIPInvitationEndTime, private.EnterWorldErrorMsg, roleDetailInfo.vipInvitationTimeInfo) -- 日服预下载 xpcall(MDL.PreDownloadJP.SyncPreHotfixState, private.EnterWorldErrorMsg, roleDetailInfo.japanUpdateVersionInfo) -- 龙脉的战场id xpcall(MDL.DragonArtery.SetCurEnterWarFieldID, private.EnterWorldErrorMsg, roleDetailInfo.dragonArteryRoomId) xpcall(MDL.DragonArtery.SetCurChatWarFieldID, private.EnterWorldErrorMsg, roleDetailInfo.dragonArteryChatRoomId) -- 纳灵系统 xpcall(MDL.Reborn.SyncRecycleFragment, private.EnterWorldErrorMsg, roleDetailInfo.recycleFragmentInfo) --国战悬赏任务信息 if IsServerDataNotNil(roleDetailInfo.wantedTaskInfo) then xpcall(MDL.CountryWantedTask.SyncWantedTaskInfo, private.EnterWorldErrorMsg, roleDetailInfo.wantedTaskInfo) end --回放 战斗记录删除id xpcall(MDL.Replay.SyncFairPlayMyRecordDelId, private.EnterWorldErrorMsg, roleDetailInfo.fairPlayMyRecordDelId) -- 攻城略地(GVG) xpcall(MDL.GVGFight.SyncRedPointData, private.EnterWorldErrorMsg, roleDetailInfo.GVGRedPointInfo) xpcall(MDL.GVGFight.SyncGVGFightGroupId, private.EnterWorldErrorMsg, roleDetailInfo.gvgFightGroupId) xpcall(MDL.GVGFight.SyncGVGHighYieldAndStageInfo, private.EnterWorldErrorMsg, roleDetailInfo.gvgHighYieldAndStageInfo) --荣誉印记 if IsServerDataNotNil(roleDetailInfo.honorSignetInfo) then xpcall(MDL.HonorSignet.SetInfo, private.EnterWorldErrorMsg, roleDetailInfo.honorSignetInfo) end -- 暴风 xpcall(MDL.Storm.SyncStormInfo, private.EnterWorldErrorMsg, roleDetailInfo.stormInfo) -- 周历报名 xpcall(MDL.Activities.SyncActivationCalenderSignUp, private.EnterWorldErrorMsg, roleDetailInfo.signUpInfo) -- 金兰活动登录红点 xpcall(MDL.FriendRecharge.SetPurchaseState, private.EnterWorldErrorMsg, roleDetailInfo.isFriendRechargeInvited) -- 势力挖矿 xpcall(MDL.GuildMine.SyncGuildMineInfo, private.EnterWorldErrorMsg, roleDetailInfo.guildMineInfo) -- 王者挑战 xpcall(MDL.KingChallenge.SyncSeasonInfo, private.EnterWorldErrorMsg, roleDetailInfo.kingChallengeInfo) -- 1v1、3v3公平竞技道具卡使用信息 xpcall(MDL.FairPlayCard.SyncInfo, private.EnterWorldErrorMsg, roleDetailInfo.fairPlayCard) -- 势力GVE xpcall(MDL.SlgGvE.SyncSeasonInfo, private.EnterWorldErrorMsg, roleDetailInfo.gveSeasonInfo) xpcall(MDL.SlgGvE.SyncSlgGvEInfo, private.EnterWorldErrorMsg, roleDetailInfo.guildGVEInfo) xpcall(MDL.SlgGvE.SetMyOccupyGridInfo, private.EnterWorldErrorMsg, roleDetailInfo.personalLandInfo, true) xpcall(MDL.SlgGvE.SetAttackingCityOrBossInfo, private.EnterWorldErrorMsg, roleDetailInfo.gveClientShowLandInfo) --需要放在最后 --BattleDataGetter.IsReconnectLevel调用的是LevelManager.IsStandaloneBattleLevel --如果是登录时,not BattleDataGetter.IsReconnectLevel()一定会返回true,因为LevelManager.LevelType会为nil。 --如果是断线重连时,LevelManager.LevelType不为nil,LevelManager.IsStandaloneBattleLevel会返回当前是否是单机战斗关卡 if not BattleDataGetter.IsReconnectLevel() then xpcall(MDL.Guide.SetGuideInfo, private.EnterWorldErrorMsg, roleDetailInfo.guideStep) end if Login_Model.isReConnect then xpcall(private.OnReConnectOk, private.EnterWorldErrorMsg, roleDetailInfo.SceneInfo) end ----------------------------------------纯逻辑执行--------------------------------------- xpcall(NetManager.SetIsLaunch, private.EnterWorldErrorMsg, false) xpcall(private.SetFirstLogin, private.EnterWorldErrorMsg, false) xpcall(MDL.DyeAppearance.SetDyeAppearanceInfos, private.EnterWorldErrorMsg, roleDetailInfo.dyeAppearanceInfo, true) xpcall(MDL.Unlock.Update, private.EnterWorldErrorMsg, true) xpcall(MDL.FunctionNotice.ExecuteAfterUnlock, private.EnterWorldErrorMsg) -- 天下会武1V1 if IsServerDataNotNil(roleDetailInfo.fairTournamentInfo) then xpcall(MDL.FairSoloTournament.SyncBaseData, private.EnterWorldErrorMsg, roleDetailInfo.fairTournamentInfo) end --天下会武3V3 xpcall(MDL.TeamFairChampionship.InitTeamFairChampionshipInfo, private.EnterWorldErrorMsg, roleDetailInfo.teamFairInfo) xpcall(MDL.FunctionNotice.SyncAwardInfo, private.EnterWorldErrorMsg, roleDetailInfo.functionRewardInfo) xpcall(CTL.HomeMain.OpenPreBattleSceneUI, private.EnterWorldErrorMsg) xpcall(NotSyncBattleSetter.SetCanChangeLine, private.EnterWorldErrorMsg, true) --继续下载后续分包的内容 if not CTL.HotFix.IsUploadPackageCheckVN() then xpcall(CTL.HotFix.PreDownloadStage, private.EnterWorldErrorMsg) end xpcall(CTL.TimerWheel.InitActivityDatas, private.EnterWorldErrorMsg) xpcall(LuaNetManager.InitChatServer, private.EnterWorldErrorMsg) --易盾数据 xpcall(CTL.Player.SetNetSecProtectData, private.EnterWorldErrorMsg) --PC包初始化GME xpcall(private.InitGME, private.EnterWorldErrorMsg) xpcall(MDL.Currency.SendCurrencyInfoToBI, private.EnterWorldErrorMsg) BIManager.DispatchBIClientEvent(BIManager.EventName.RespEnterWorldSuccess, "isNewRole", msgResp.isNewRole, "roleId",roleDetailInfo.baseInfo.player_id) --主要处理断线重连,在断线重连的情况下,不会收到切场景的有关协议(MessageS2CRoleEnterScene和MessageG2CInitFubenInfo) --断线重连主要是同场景切换,现在流程不一致因此在这里处理 if BattleDataGetter.IsStandaloneBattleLevel() or BattleDataGetter.IsSyncLevel() then xpcall(private.OnRealEnterLevel, private.EnterWorldErrorMsg) end xpcall(private.OnFirstEnterTown, private.EnterWorldErrorMsg) xpcall(MDL.GuildWar.SetPersonGuildWarInfo, private.EnterWorldErrorMsg, roleDetailInfo.personGuildWarInfo) xpcall(MDL.InfoReminder.InitInfoReminds, private.EnterWorldErrorMsg, roleDetailInfo.InfoReminds) xpcall(MDL.DrawStraws.RefreshDrawStrawsInfos, private.EnterWorldErrorMsg, roleDetailInfo.drawStrawsInfos) xpcall(MDL.SyncFourCountryWar.InitTime, private.EnterWorldErrorMsg, roleDetailInfo.syncFourCountryInfo) xpcall(UTL.Material.InitCircleHpMaterialPool, private.EnterWorldErrorMsg) xpcall(MDL.ChangAnSiege.InitSiegeCityBaseInfo, private.EnterWorldErrorMsg, roleDetailInfo.siegeCityBaseInfo) xpcall(MDL.ThreeTeamFight.SyncBasicInfo, private.EnterWorldErrorMsg, roleDetailInfo.threeTeamsPKInfo, true) xpcall(MDL.ExpelMonster.SyncBasicInfo, private.EnterWorldErrorMsg, roleDetailInfo.expelMonsterInfo) xpcall(MDL.Pet.InitPetInfo, private.EnterWorldErrorMsg, roleDetailInfo.petList, roleDetailInfo.petGlobalInfo, roleDetailInfo.petSlotList, roleDetailInfo.petFormationInfo) xpcall(MDL.Pet.SetBagRune, private.EnterWorldErrorMsg, roleDetailInfo.bagInfo.petTalismans, true) xpcall(MDL.Guild.SetLeaderTaskInfo, private.EnterWorldErrorMsg, roleDetailInfo.guildLeaderTaskInfo, true) xpcall(MDL.CountryNightBoss.SetLineUpCountryLimits, private.EnterWorldErrorMsg, roleDetailInfo.CNBCountryLimit, true) xpcall(MDL.HeroAwaken.SetAwakenInfo, private.EnterWorldErrorMsg, roleDetailInfo.heroAwakenInfos, true) xpcall(MDL.HeroAwaken.SetTaskInfo, private.EnterWorldErrorMsg, roleDetailInfo.awakenTaskInfos, true) xpcall(MDL.AppPushGift.UpdateRecallGiftInfo, private.EnterWorldErrorMsg, roleDetailInfo.recallGiftInfo, true) xpcall(MDL.DivineWeaponForgeSoul.SyncWeaponForgeSoulInfo, private.EnterWorldErrorMsg, roleDetailInfo.weaponSoulInfo) xpcall(MDL.Guild.UpdateWeekAuctionBonus, private.EnterWorldErrorMsg, roleDetailInfo.personalAuctionBonus, true) xpcall(MDL.LaterEnter.SyncInfo, private.EnterWorldErrorMsg, roleDetailInfo.LaterEnterInfo) xpcall(MDL.AwakenActivity.UpdateAwakenActivityInfo, private.EnterWorldErrorMsg, roleDetailInfo.openAwakenChallengeHeroList, true) xpcall(MDL.Decoration.SyncInfo, private.EnterWorldErrorMsg, roleDetailInfo.decorateInfo) --这个放到最后,模块监听这个事件进行执行逻辑,其实是一个初始化数据完成的事件,这个时候事件名字就不改了 EventSystem.Dispatch(EventID.AcquireSystemRedAfterUnlock) end function private.InitGME() if GameAppInfo.IsPCPackage() or GameAppInfo.EditorOpenGME() then if GameAppInfo.IsChinesePackage() then SDKUtil.InitPCGME("1400548804", "DF2ZpoWy94i5C2bv", MDL.Player.GetRoleId()) elseif GameAppInfo.IsOverseaPackage() then SDKUtil.InitPCGME("1400573006", "iFWXHkxuaz7yZtwj", MDL.Player.GetRoleId()) elseif GameAppInfo.IsJapanesePackage() then SDKUtil.InitPCGME("1400722183", "4wYuznLcdNq3zex1", MDL.Player.GetRoleId()) elseif GameAppInfo.IsVietnamPackage() then SDKUtil.InitPCGME("1400800279", "b967b82e4cf94ec9", MDL.Player.GetRoleId()) end end end function private.OnFirstEnterTown() local roleName = BattleDataGetter.GetPlayerName() or "" local roleLevel = MDL.Player.GetRoleLevel() local vipLevel = 0 local phyBalance = MDL.Player.GetEnergyValue() local currencyData = {} currencyData.SilverCoin = MDL.Currency.GetMoneyCount(MDL.Currency.CurrencyType.SilverCoin) currencyData.GoldIngot = MDL.Currency.GetMoneyCount(MDL.Currency.CurrencyType.GoldIngot) currencyData.DragonJade = MDL.Currency.GetMoneyCount(MDL.Currency.CurrencyType.DragonJade) BIManager.DispatchBIClientEvent(BIManager.EventName.BDC_UserInfo, "role_name", roleName, "role_level", roleLevel, "vip_level", vipLevel, "phy_balance", phyBalance, "currency_info", JSON.encode(currencyData)) -- 延迟注册连携解锁监听事件 避开解锁初始化 CTL.AssistanceFight.DelayRegistFunctionUnlockUpdate() CTL.InfoReminder.InitInfoReminder() CTL.SpecialTeam.RefreshTeamNotice() EventSystem.Dispatch(EventID.SDKUrlMonitor_SetServiceMonitorInfo) --尝试开启预下载 CTL.HotFix.TryStartPreHotfix() end function private.OnRealEnterLevel() if BattleDataGetter.IsMonsterTestLevel() then return end if not private.isFirstEnterLevel then private.isFirstEnterLevel = true CTL.Mail.InitMail() MDL.CountryWorldBoss.C2GCountryWorldBossData() --登录请求战区Boss信息 MDL.TestingGift.HWActivityGetInfoReq() --刷新背包红点 CTL.Bag.RefreshBagRedPoint() -- 告知服务器连接成功 local levelType = BattleDataGetter.GetCurLevelType() if levelType == LuaConst.LevelType.CrossEscortTown or levelType == LuaConst.LevelType.SingleEscortTown then MDL.GuildEscort.EscortMapLoadComplete() end MDL.Stratagem.StratagemReq() CTL.Country.OnFirstEnterScene() CTL.PayMall.ReqSdkCanOpenLoginCode() end end function private.G2CDailyRefreshResp(msgResp) logging.crit(LTAG.CRIT, "G2CDailyRefreshResp") private.SetFirstLogin(true) MDL.Player.OnDailyRefreshResponse(msgResp.PlayerChange) EventSystem.Dispatch(EventID.New_Day_Refresh) end function private.OnCreateRole(msg) BIManager.DispatchBIClientEvent(BIManager.EventName.CreateProfile) BIManager.DispatchBIClientEvent(BIManager.EventName.BDC_CreateRole,BIManager.BDCEventParam.creat_role_state_key, BIManager.BDCEventParamValue.Creat_Role_State_Send , BIManager.BDCEventParam.creat_fail_reason_key, "") end function private.OnReConnectOk(sceneInfo) if BattleDataGetter.IsTownLevel() then NotSyncBattleSetter.SetMainPlayerMoveInTown(BattleDataGetter.GetMoveFromSceneInfo(sceneInfo)) end NetManager.OnReConnectOk() MDL.TeamDungeon.OnReConnectOk() --重连的情况,关闭聊天UI MDL.ChannelChat.CloseChatMainUIAfterReconnect() Login_Model.isReConnect = false EventSystem.Dispatch(EventID.OnReConnectOk) end function private.SortServerList(a,b) local aNum = tonumber(Login_Model.GetFirstName(a)) local bNum = tonumber(Login_Model.GetFirstName(b)) return aNum < bNum end function private.ForceHotUpdateCheck(msg) local curBundleVer = msg.CurBundleVer if not string.isNilOrEmpty(curBundleVer) then local newVer = CTL.Login.NewGetPlatformHotVer(curBundleVer) if not string.isNilOrEmpty(newVer) then local lastVersion = AppInfo.hotfixCodeFromServer if newVer ~= lastVersion then UTL.MessageBox.ShowOnlyOkNoCloseBox(Const_IDS.IDS_WARNING, Const_IDS.IDS_StrongUpdate, SDKUtil.SwitchAccount) end end end end function Login_Model.OnConnectionRequest() NetManager.InitPB() local msg = NetManager.GetPB("on_connection_pb").OnConnectionReq() Login_Implement.BuildConnectionReq(msg) logging.log(LTAG.XuQian, "OnConnectionRequest ") NetManager.SendMessage(MessageEnums.MessageOnConnection,msg) BIManager.GetBDCDiffTime() BIManager.DispatchBIClientEvent(BIManager.EventName.BDC_RoleLogin,BIManager.BDCEventParam.role_login_state, BIManager.BDCEventParamValue.Role_Login_State_Success, BIManager.BDCEventParam.role_login_reason, "", "ads_json", "1") end return Login_Model