Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local PufferODPakManager = {}
- local StringUtil = require("common.string_util")
- local PufferConst = require("client.slua.logic.download.puffer_const")
- local ModuleManager = require("client.module_framework.ModuleManager")
- local Client = _ENV.Client
- local PufferDownloader = _ENV.PufferDownloader
- local PufferQueue
- function PufferODPakManager:DefineAndResetData()
- self.ODPaks = {}
- self.PakDatas = {}
- self.itemToPaks = {}
- self.itemToItems = {}
- self.itemToPaths = {}
- self.battleDownloadPaks = {}
- self.BlackListPaks = {}
- self.PauseDontAutoDownloadPaks = {}
- self.ODPaksNameToConHash = {}
- self.needRecoverBattleData = false
- self.battleDeleteFiles = {}
- self._attachmentSkinIDInited = false
- self._attachmentSkinIDMap = nil
- PufferQueue = ModuleManager.GetModule(ModuleManager.CommonModuleConfig.PufferQueue)
- local ScriptHelperEngine = import("ScriptHelperEngine")
- self.isLowMemoryDevice = ScriptHelperEngine.IsLowMemoryDevice()
- end
- function PufferODPakManager:InitODPaks(existPaks)
- local val = HDmpveRemote.HDmpveRemoteConfigGetInt("GEnableBackpackPakCache", 0)
- local minMemorySize = HDmpveRemote.HDmpveRemoteConfigGetInt("GForceDisableBackpackPakCacheMem", 0)
- local ScriptHelperClient = import("ScriptHelperClient")
- local curMemorySize = ScriptHelperClient.GetMemorySize()
- log(bWriteLog and "PufferODPakManager:InitODPaks. size = " .. tostring(curMemorySize) .. " minMemory = " .. tostring(minMemorySize))
- if 0 < minMemorySize and minMemorySize > curMemorySize then
- val = 0
- end
- PufferDownloader.SetEnableBackpackCache(val)
- log("PufferODPakManager:InitODPaks start")
- self:DefineAndResetData()
- local IsDevelopment = Client.IsDevelopment()
- self.enableSaveODPakDataToFile = HDmpveRemote.HDmpveRemoteConfigGetBool("GSaveODPakDataToFile", false)
- local pufferFileList = PufferDownloader.GetPufferFileListJson()
- self:MapContentHashPro(pufferFileList.conhash_list)
- if pufferFileList.ODPaks == nil or next(pufferFileList.ODPaks) == nil then
- log("PufferODPakManager:InitODPaks PufferFileList.json error")
- return
- end
- self:InitUGCExpiredDepends()
- local VirtualBundleCfgs = {}
- local VirtualBundlePaks = {}
- local pakInfoTableList = CDataTable.GetTable("PakInfoTable")
- for _, packCfg in pairs(pakInfoTableList) do
- local id = packCfg.PakID
- local strID = tostring(id)
- local fileList = {}
- local dataCfg = pufferFileList.ODPaks[strID]
- if dataCfg then
- if not packCfg.IsUGC or packCfg.IsUGC == 0 then
- fileList = dataCfg.fileList
- end
- elseif packCfg.depends ~= "" then
- local dependItems = StringUtil.split(packCfg.depends, ";")
- for _, v in pairs(dependItems) do
- local itemID = tonumber(v)
- local Paks
- if itemID then
- if self.UGCExpiredDepends and not self.UGCExpiredDepends[itemID] then
- Paks = self:GetPakNamesByItemID(itemID)
- end
- elseif self.UGCExpiredDepends and not self.UGCExpiredDepends[v] then
- Paks = self:GetPakNamesByFeatureID(v)
- end
- if Paks and next(Paks) then
- local virtualCfg = VirtualBundleCfgs[strID]
- if not virtualCfg then
- virtualCfg = {
- paks = {}
- }
- VirtualBundleCfgs[strID] = virtualCfg
- end
- for PakName, _ in pairs(Paks) do
- if not VirtualBundlePaks[PakName] then
- VirtualBundlePaks[PakName] = 1
- virtualCfg.paks[PakName] = 1
- end
- end
- end
- end
- end
- self:InitODPack(fileList, id)
- end
- for ODPackID, v in pairs(pufferFileList.ODPaks) do
- local id = tonumber(ODPackID)
- if not self.ODPaks[id] then
- local fileList = v.fileList
- self:InitODPack(fileList, id)
- end
- end
- log(bWriteLog and "PufferODPakManager:InitODPaks. handleInitODPack")
- for virtualPakName, _ in pairs(VirtualBundlePaks) do
- local _, packData = self:GetPackDataByPakName(virtualPakName)
- if packData then
- local data = packData.paks[virtualPakName]
- packData.paks[virtualPakName] = nil
- packData.totalCnt = packData.totalCnt - 1
- packData.totalSize = packData.totalSize - data.tSize
- if data.state == PufferConst.ENUM_DownloadState.Done then
- packData.curCnt = packData.curCnt - 1
- packData.curSize = packData.curSize - data.cSize
- end
- end
- end
- for k, v in pairs(VirtualBundleCfgs) do
- self:InitVirtualODPack(k, v.paks)
- end
- log(bWriteLog and "PufferODPakManager:InitODPaks. handleVirtualODPack")
- self:DumpUGCDebugInfo()
- self:UpdatePkgCheckInfo(existPaks)
- self:UpdateExistPaks(existPaks)
- log("PufferODPakManager:InitODPaks end")
- end
- function PufferODPakManager:InitODPack(fileList, id, existPaks)
- if not next(fileList) then
- return
- end
- local data = {}
- self.ODPaks[id] = data
- data.paks = {}
- data.curCnt = 0
- data.totalCnt = #fileList
- data.curSize = 0
- data.totalSize = 0
- local ENUM_DownloadState = PufferConst.ENUM_DownloadState
- data.state = ENUM_DownloadState.Not
- for _, v1 in ipairs(fileList) do
- local TmpPakInfo = StringUtil.split(v1, "|")
- local TmpPakInfoNum = #TmpPakInfo
- local pakName = ""
- if 1 <= TmpPakInfoNum then
- pakName = TmpPakInfo[1]
- end
- local pakNameData = {
- tSize = 0,
- cSize = 0,
- state = ENUM_DownloadState.Not
- }
- data.paks[pakName] = pakNameData
- if self.PakDatas[pakName] then
- log(bWriteLog and "PufferODPakManager:InitODPack. exist pakName: " .. pakName)
- else
- self.PakDatas[pakName] = {packID = id, data = pakNameData}
- end
- local size = 0
- if 2 <= TmpPakInfoNum then
- size = tonumber(TmpPakInfo[2])
- end
- pakNameData.tSize = size / 1024
- local ConOrgHash = "0101010101010101010101010101010101010101"
- if 3 <= TmpPakInfoNum then
- ConOrgHash = TmpPakInfo[3]
- end
- self.ODPaksNameToConHash[pakName] = ConOrgHash
- if existPaks and existPaks[pakName] then
- pakNameData.cSize = pakNameData.tSize
- pakNameData.state = ENUM_DownloadState.Done
- data.curCnt = data.curCnt + 1
- end
- data.totalSize = data.totalSize + pakNameData.tSize
- end
- if existPaks then
- self:_UpdatePackDataState(data)
- end
- end
- function PufferODPakManager:MapContentHashPro(conhash_list)
- local USFEnableUpdatePkgMapType = HDmpveRemote.HDmpveRemoteConfigGetInt("USFEnableUpdatePkgMapType", 0)
- if USFEnableUpdatePkgMapType == 0 then
- log(bWriteLog and "PufferODPakManager:MapContentHashPro return for USFEnableUpdatePkgMapType = " .. tostring(USFEnableUpdatePkgMapType))
- return
- end
- if conhash_list == nil then
- log("PufferODPakManager:MapContentHashPro return for conhash_list == nil")
- return
- end
- log_tree("PufferODPakManager:MapContentHashPro conhash_list = ", conhash_list)
- for PkgName, ContentHash in pairs(conhash_list) do
- self.ODPaksNameToConHash[PkgName] = ContentHash
- end
- end
- function PufferODPakManager:UFSSUpdatePkgMapType(filestate)
- local USFEnableUpdatePkgMapType = HDmpveRemote.HDmpveRemoteConfigGetInt("USFEnableUpdatePkgMapType", 0)
- if USFEnableUpdatePkgMapType == 0 then
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType return for UFSSUpdatePkgMapType = " .. tostring(USFEnableUpdatePkgMapType))
- return
- end
- local IsDiffPkg = false
- local pakName = filestate.filename
- if filestate.diffFilename ~= nil then
- pakName = filestate.diffFilename
- local TmpPath = Client.ProjectSavedDir() .. "Paks/" .. pakName
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType TmpPath = " .. tostring(TmpPath))
- local TmpArrayData = {}
- table.insert(TmpArrayData, TmpPath)
- Client.USFSCacheSysContextUpdatePkgBinDiff(TmpArrayData)
- else
- pakName = filestate.filename
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType pakName = " .. tostring(pakName))
- if not Client.IsFileExistInCSCWithCheck(pakName) then
- local TmpPath = Client.ProjectSavedDir() .. "Paks/" .. pakName
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType TmpPath = " .. tostring(TmpPath))
- local TmpArrayData = {}
- table.insert(TmpArrayData, TmpPath)
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType TmpArrayData: " .. tostring(#TmpArrayData))
- Client.USFSCacheSysContextUpdatePkg(TmpArrayData)
- else
- log(bWriteLog and "PufferODPakManager:UFSSUpdatePkgMapType skip for Client.IsFileExistInCSCWithCheck pakName: " .. tostring(pakName))
- end
- end
- end
- function PufferODPakManager:UpdateExistPaks(existPaks)
- existPaks = existPaks or {}
- local ArrayData = Client.GetPkgsFromDir(true, "ODPaks")
- log_tree("ArrayData = ", ArrayData)
- if ArrayData then
- for i, v in ipairs(ArrayData) do
- existPaks[v] = true
- end
- end
- if PufferDownloader.EnableBackpackCache then
- local UBackpackUtils = import("BackpackUtils")
- local startTime = slua.getMiliseconds()
- if UBackpackUtils.SetPaKExistMap then
- UBackpackUtils.SetPaKExistMap(existPaks)
- else
- PufferDownloader.ClearPakPathMap()
- for pakName, _ in pairs(existPaks) do
- log(bWriteLog and "PufferODPakManager:UpdateExistPaks. pakName = " .. tostring(pakName))
- PufferDownloader.SetPakExist(pakName, true)
- end
- end
- local costTimeInSet = slua.getMiliseconds() - startTime
- log(bWriteLog and "PufferODPakManager:UpdateExistPaks. SetPaKExistMap costTime = " .. tostring(costTimeInSet))
- end
- for packID, data in pairs(self.ODPaks) do
- for pakName, pakNameData in pairs(data.paks) do
- if existPaks[pakName] then
- pakNameData.state = PufferConst.ENUM_DownloadState.Done
- pakNameData.cSize = pakNameData.tSize
- data.curSize = data.curSize + pakNameData.tSize
- data.curCnt = data.curCnt + 1
- end
- end
- self:_UpdatePackDataState(data)
- end
- log(bWriteLog and "PufferODPakManager:UpdateExistPaks. End")
- end
- function PufferODPakManager:InitPretechODPaks(jsonODPaks, existPaks)
- log("PufferODPakManager:InitPretechODPaks start")
- if not jsonODPaks then
- return
- end
- for ODPackID, v in pairs(jsonODPaks) do
- self:InitODPack(v.fileList, tonumber(ODPackID), existPaks)
- end
- log("PufferODPakManager:InitPretechODPaks end")
- end
- function PufferODPakManager:InitUGCExpiredDepends()
- log("PufferODPakManager:InitUGCExpiredDepends start")
- local CreativeExpiredAssetConfig = require("GameLua.Mod.CreativeBase.Gameplay.Config.CreativeExpiredAssetConfig")
- local ModuleManager = require("client.module_framework.ModuleManager")
- local PufferUGCPakManager = ModuleManager.GetModule(ModuleManager.CommonModuleConfig.puffer_ugcpak_manager)
- self.UGCExpiredDepends = {}
- for AssetID, _ in pairs(CreativeExpiredAssetConfig.CurVersionExpiredAssetSet) do
- local dependPackArray, minDepends = PufferUGCPakManager:GetDepends(AssetID)
- if next(minDepends) then
- for k, v in pairs(minDepends) do
- self.UGCExpiredDepends[v] = true
- log("PufferODPakManager:InitUGCExpiredDepends Expired Depend = " .. tostring(v) .. " AssetID = " .. tostring(AssetID))
- end
- end
- end
- end
- function PufferODPakManager:InitVirtualODPack(id, paks)
- id = tonumber(id)
- local packData = {}
- self.ODPaks[id] = packData
- packData.paks = {}
- packData.curCnt = 0
- packData.totalCnt = 0
- packData.curSize = 0
- packData.totalSize = 0
- packData.state = PufferConst.ENUM_DownloadState.Not
- packData.isVirtual = true
- for pakName, _ in pairs(paks) do
- packData.totalCnt = packData.totalCnt + 1
- local pakData = self.PakDatas[pakName]
- if pakData then
- pakData.packID = id
- else
- log(bWriteLog and "PufferODPakManager:InitVirtualODPack. pakName = " .. tostring(pakName))
- pakData = {
- data = {
- tSize = 0,
- state = PufferConst.ENUM_DownloadState.Not,
- cSize = 0
- },
- packID = id
- }
- self.PakDatas[pakName] = pakData
- end
- packData.totalSize = packData.totalSize + pakData.data.tSize
- packData.paks[pakName] = pakData.data
- end
- end
- function PufferODPakManager:_UpdatePackDataState(packData)
- if not packData then
- return
- end
- if packData.curCnt == packData.totalCnt then
- packData.state = PufferConst.ENUM_DownloadState.Done
- elseif packData.curCnt > 0 then
- packData.state = PufferConst.ENUM_DownloadState.Pause
- else
- packData.state = PufferConst.ENUM_DownloadState.Not
- end
- end
- function PufferODPakManager:IsIllegalTimeByODPackID(ODPackID)
- local RecommendHandler = require("client.slua.logic.download.recommend.logic_recommend_handler")
- if not RecommendHandler.PaksDownloadTime or not next(RecommendHandler.PaksDownloadTime) then
- return true
- end
- if not self.ODPaks[ODPackID] then
- return false
- end
- local FBI = require("client.slua.logic.fbi.logic_fbi")
- for pakName, v in pairs(self.ODPaks[ODPackID].paks) do
- if FBI.IsIllegalTime(pakName) then
- return true
- end
- end
- return false
- end
- function PufferODPakManager:JumpODPack(ODPackID)
- local PufferSwitch = require("client.slua.logic.download.puffer_switch")
- local ui_manager = require("client.slua_ui_framework.manager")
- if ui_manager.IsAndroidStackEmpty() and PufferSwitch.ODPackDownloadFinishPopUpSwitch then
- local canPop = true
- if GameStatus.GetGameStatus() == GameStatus.Fighting then
- canPop = false
- end
- local ODPackCfg = CDataTable.GetTableData("PakInfoTable", ODPackID)
- if ODPackCfg and ODPackCfg.DownloadFinishTipsID > 0 and canPop then
- local jumpInfo = {}
- jumpInfo.texturePath = "/Game/UMG/Texture/Lobby_NoAtlas/UnknowPass/Koi/Koi_Tips_icon_Chicken.Koi_Tips_icon_Chicken"
- function jumpInfo.callback()
- if ODPackID == PufferConst.EODPackID.SocialLobby then
- local logic_lobby_social_scene = require("client.slua.logic.lobby.Left.logic_lobby_social_scene")
- logic_lobby_social_scene.MoveToPage(ENUM_LobbyPageType.Left)
- else
- GlobalData.JumpUrl(ODPackCfg.JumpURL)
- end
- end
- local function cancelCallback()
- PufferSwitch.ODPackDownloadFinishPopUpSwitch = false
- end
- jumpInfo.cancelCallback = cancelCallback
- local content = LocUtil.LocalizeResFormat(ODPackCfg.DownloadFinishTipsID)
- local RightPopSystem = require("client.slua.logic.lobby_popui.logic_right_popup")
- RightPopSystem.ShowPopupTip(content, true, false, jumpInfo, 10)
- else
- end
- end
- end
- function PufferODPakManager:GetStateByKeyList(downloadType, keyList, bSkipDepends, bSkipVidepDepends)
- local resultState = PufferConst.ENUM_DownloadState.Done
- if Client.bEditorSkipDownload then
- return resultState
- end
- if not keyList then
- return resultState
- end
- for i, v in pairs(keyList) do
- local state = PufferConst.ENUM_DownloadState.Done
- if downloadType == PufferConst.ENUM_DownloadType.ODPAK then
- local typeV = type(v)
- if typeV == "number" then
- state = self:GetStateByItemID(v)
- elseif typeV == "string" then
- if StringUtil.starts(v, PufferConst.ODPAKS_RELATIVE_DIR) then
- state = self:GetStateByPakName(v)
- elseif self:GetPakNamesByFeatureID(v) then
- local pakName = next(self:GetPakNamesByFeatureID(v))
- state = self:GetStateByPakName(pakName)
- else
- state = self:GetStateByPath(v)
- end
- end
- elseif downloadType == PufferConst.ENUM_DownloadType.ODPACK then
- state = self:GetStateByPackID(v)
- end
- local curPriority = PufferConst.DownloadStatePriority[state]
- local prePriority = PufferConst.DownloadStatePriority[resultState]
- if curPriority and prePriority and curPriority > prePriority then
- resultState = state
- end
- end
- return resultState
- end
- function PufferODPakManager:GetStateByPakName(pakName, skipCache)
- if Client.bEditorSkipDownload then
- return PufferConst.ENUM_DownloadState.Done
- end
- if pakName == nil or pakName == "" then
- return PufferConst.ENUM_DownloadState.Done
- end
- if pakName == PufferConst.CE_LOCK_PAKNAME then
- return PufferConst.ENUM_DownloadState.Done
- end
- if pakName == PufferConst.LOCK_PAKNAME then
- return PufferConst.ENUM_DownloadState.Done
- end
- local state = PufferConst.ENUM_DownloadState.Done
- if not skipCache then
- local pakNameData = self:GetPakDataByPakName(pakName)
- if pakNameData then
- state = pakNameData.state
- if state == PufferConst.ENUM_DownloadState.Done then
- return PufferConst.ENUM_DownloadState.Done
- end
- end
- end
- if PufferQueue:GetDownloadingTask(pakName) then
- return PufferConst.ENUM_DownloadState.Download
- end
- if PufferQueue:GetWaitTask(pakName) then
- return PufferConst.ENUM_DownloadState.Wait
- end
- if state ~= PufferConst.ENUM_DownloadState.Done then
- return state
- end
- local isPakExist = PufferDownloader.GetPakExist(pakName, skipCache)
- if isPakExist then
- return PufferConst.ENUM_DownloadState.Done
- end
- return PufferConst.ENUM_DownloadState.Not
- end
- function PufferODPakManager:GetStateByPath(path)
- if Client.bEditorSkipDownload then
- return PufferConst.ENUM_DownloadState.Done
- end
- if path == nil or path == "" then
- return PufferConst.ENUM_DownloadState.Done
- end
- local PufferManager = require("client.slua.logic.download.puffer.puffer_manager")
- local pakName = PufferManager.GetPakName(path)
- return self:GetStateByPakName(pakName)
- end
- function PufferODPakManager:GetStateByItemID(itemID)
- if Client.bEditorSkipDownload then
- return PufferConst.ENUM_DownloadState.Done
- end
- itemID = tonumber(itemID)
- if not itemID or itemID <= 0 then
- return PufferConst.ENUM_DownloadState.Done
- end
- if self.itemToPaks[itemID] and self.itemToPaks[itemID].state == PufferConst.ENUM_DownloadState.Done then
- return PufferConst.ENUM_DownloadState.Done
- end
- local paks = self:GetPakNamesByItemID(itemID)
- local state = PufferConst.ENUM_DownloadState.Done
- for pakName, _ in pairs(paks) do
- local tempState = self:GetStateByPakName(pakName)
- if PufferConst.DownloadStatePriority[tempState] > PufferConst.DownloadStatePriority[state] then
- state = tempState
- end
- if state == PufferConst.ENUM_DownloadState.Download then
- break
- end
- end
- self.itemToPaks[itemID].state = state
- return state
- end
- function PufferODPakManager:RestStateByItemID(itemID)
- log(bWriteLog and string.format("PufferODPakManager:RestStateByItemID. itemID=%s", tostring(itemID)))
- if not itemID then
- return
- end
- local state = PufferConst.ENUM_DownloadState.Done
- local paks = self:GetPakNamesByItemID(itemID)
- for pakName, _ in pairs(paks) do
- local pakState = self:GetStateByPakName(pakName, true)
- if pakState ~= PufferConst.ENUM_DownloadState.Done then
- state = PufferConst.ENUM_DownloadState.Not
- end
- local pufferPakData = self:GetPakDataByPakName(pakName)
- if pufferPakData then
- pufferPakData.state = pakState
- end
- end
- log(bWriteLog and "PufferODPakManager:RestStateByItemID. fix state = " .. tostring(state))
- self.itemToPaks[itemID].state = state
- end
- function PufferODPakManager:GetStateByPackID(packID)
- if Client.bEditorSkipDownload then
- return PufferConst.ENUM_DownloadState.Done
- end
- local pack = self.ODPaks[packID]
- if not pack then
- if not PufferDownloader.PufferJsonDownloadReturn and not Client.IsEditor() then
- return PufferConst.ENUM_DownloadState.Not
- end
- return PufferConst.ENUM_DownloadState.Done
- end
- if pack.curCnt == pack.totalCnt then
- pack.state = PufferConst.ENUM_DownloadState.Done
- end
- return pack.state
- end
- function PufferODPakManager:GetPakNamesByItemID(itemID)
- if Client.bEditorSkipDownload then
- return {}, {}
- end
- if not itemID or itemID == 0 then
- return {}, {}
- end
- local PufferManager = require("client.slua.logic.download.puffer.puffer_manager")
- if self.itemToPaks[itemID] and self.itemToPaks[itemID].paks then
- return self.itemToPaks[itemID].paks
- end
- self.itemToPaks[itemID] = {}
- self.itemToPaks[itemID].paks = {}
- local list = self:GetBPPathsByItemID(itemID)
- for _, v in pairs(list) do
- local pakName = PufferManager.GetPakName(v)
- if pakName ~= "" then
- self.itemToPaks[itemID].paks[pakName] = true
- end
- end
- if CDataTable.GetTableData("WeaponDIYList", itemID) and self.ODPaks[PufferConst.EODPackID.DIY] then
- for i, v in pairs(self.ODPaks[PufferConst.EODPackID.DIY].paks) do
- self.itemToPaks[itemID].paks[i] = true
- log(bWriteLog and string.format("PufferODPakManager:GetPakNamesByItemID diy pak:%s", i))
- end
- end
- return self.itemToPaks[itemID].paks
- end
- function PufferODPakManager:GetPakNamesByFeatureID(featureID)
- if not featureID or featureID == "" then
- return nil
- end
- local PufferManager = require("client.slua.logic.download.puffer.puffer_manager")
- if self.itemToPaks[featureID] and self.itemToPaks[featureID].paks then
- return self.itemToPaks[featureID].paks
- end
- local FeatureAssetPathTable = CDataTable.GetTableData("FeatureAssetPathTable", featureID)
- if not FeatureAssetPathTable then
- return nil
- end
- local BPPath = FeatureAssetPathTable.Path
- if not BPPath or BPPath == "" then
- return nil
- end
- self.itemToPaks[featureID] = {}
- self.itemToPaks[featureID].paks = {}
- local pakName = ""
- local StringUtil = require("common.string_util")
- if StringUtil.ends(BPPath, ".mp4") then
- pakName = PufferManager.GetPakNameByVideoPath(BPPath)
- else
- pakName = PufferManager.GetPakName(BPPath)
- end
- if pakName ~= "" then
- self.itemToPaks[featureID].paks[pakName] = true
- else
- log(bWriteLog and "pakName is nil, BPPath = " .. BPPath)
- end
- return self.itemToPaks[featureID].paks
- end
- function PufferODPakManager:GetPakNamesByODPakID(ODPackD)
- if not ODPackD or ODPackD == 0 then
- return {}
- end
- if self.ODPaks[ODPackD] and self.ODPaks[ODPackD].paks then
- return self.ODPaks[ODPackD].paks
- end
- return {}
- end
- function PufferODPakManager:GetIconPathsByItemID(itemID, pathList)
- pathList = pathList or {}
- if not itemID or itemID <= 0 then
- return pathList
- end
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if itemCfg then
- if itemCfg.ItemSmallIcon and itemCfg.ItemSmallIcon ~= "" then
- table.insert(pathList, itemCfg.ItemSmallIcon)
- end
- if itemCfg.ItemSubType == ENUM_ITEM_SUBTYPE.Bubble_Emote then
- local cfg = CDataTable.GetTableData("IngameBubbleCfg", itemID)
- if cfg and cfg.BubbleEffectIcon and cfg.BubbleEffectIcon ~= "" then
- table.insert(pathList, cfg.BubbleEffectIcon)
- end
- end
- end
- local rareCfg = CDataTable.GetTableData("RareItemCfg", itemID)
- if rareCfg then
- if rareCfg.Path and rareCfg.Path ~= "" then
- table.insert(pathList, rareCfg.Path)
- end
- if rareCfg.PathIcon and rareCfg.PathIcon ~= "" then
- table.insert(pathList, rareCfg.PathIcon)
- end
- if rareCfg.CornerPath and rareCfg.CornerPath ~= "" then
- table.insert(pathList, rareCfg.CornerPath)
- end
- end
- local posterCfg = CDataTable.GetTableData("RareItemSharePosterList", itemID)
- if posterCfg and posterCfg.Poster and posterCfg.Poster ~= "" then
- table.insert(pathList, posterCfg.Poster)
- end
- local vehicleAppliqueCfg = CDataTable.GetTableData("VehicleAppliqueCfg", itemID)
- if vehicleAppliqueCfg and vehicleAppliqueCfg.AppliquePath and vehicleAppliqueCfg.AppliquePath ~= "" then
- table.insert(pathList, vehicleAppliqueCfg.AppliquePath)
- end
- return pathList
- end
- function PufferODPakManager:GetBPPathsByItemID(itemID)
- local BPMapping = self:_GetRelatedItems(itemID)
- local list = {}
- for _, v in pairs(BPMapping) do
- local id = tonumber(v)
- local path = self:GetItemBPPathByItemID(id)
- if path and path ~= "" then
- table.insert(list, path)
- end
- local JKPath = self:GetJKItemBPPathByItemID(id)
- if JKPath and JKPath ~= "" then
- table.insert(list, JKPath)
- end
- local lobbyPath = self:_GetItemLobbyPathByBPID(id)
- if lobbyPath and lobbyPath ~= "" then
- table.insert(list, lobbyPath)
- end
- local HighPathList = self:_GetItemHighPathByBPID(id)
- if HighPathList and next(HighPathList) then
- for key, _path in pairs(HighPathList) do
- if _path and _path ~= "" then
- table.insert(list, _path)
- end
- end
- end
- local mapCfg = CDataTable.GetTableData("BPMappingTable", id)
- if mapCfg and mapCfg.ActorMapping and mapCfg.ActorMapping ~= "" then
- local actorIDMap = StringUtil.split(mapCfg.ActorMapping, "|")
- local ActorVoiceSystem = require("client.slua.logic.actor_voice.logic_actor_voice")
- for i, actorIDStr in pairs(actorIDMap) do
- local actorID = tonumber(actorIDStr)
- if actorID and 0 < actorID then
- local bankPath = ActorVoiceSystem.GetBankPathByActorID(actorID)
- if bankPath and bankPath ~= "" then
- table.insert(list, bankPath)
- end
- end
- end
- end
- local fxData = CDataTable.GetTableData("AvatarWeaponHitFXData", id)
- if fxData and fxData.EffectPath ~= "" then
- table.insert(list, fxData.EffectPath)
- end
- list = self:GetIconPathsByItemID(id, list)
- end
- local BPMappingTable = CDataTable.GetTableData("BPMappingTable", itemID)
- if BPMappingTable and BPMappingTable.DependPath and BPMappingTable.DependPath ~= "" then
- local StringUtil = require("common.string_util")
- local arrDependPaths = StringUtil.split(BPMappingTable.DependPath, "|")
- for _, v in pairs(arrDependPaths) do
- if v and v ~= "" then
- table.insert(list, v)
- end
- end
- end
- list = self:GetIconPathsByItemID(itemID, list)
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if itemCfg and itemCfg.ItemType == ENUM_ITEM_TYPE.Home then
- local cfg = CDataTable.GetTableData("PlanPH_StructureItemCfg", itemID)
- if cfg and cfg.BPPath then
- table.insert(list, cfg.BPPath)
- end
- cfg = CDataTable.GetTableData("PlanPH_DecorateItemCfg", itemID)
- if cfg and cfg.BPPath then
- table.insert(list, cfg.BPPath)
- if cfg.DependBPPath and cfg.DependBPPath ~= "" then
- table.insert(list, cfg.DependBPPath)
- end
- end
- cfg = CDataTable.GetTableData("PlanPH_WallpaperItemCfg", itemID)
- if cfg and cfg.MatPath then
- table.insert(list, cfg.MatPath)
- end
- end
- if itemCfg and itemCfg.ItemType == ENUM_ITEM_TYPE.CYCLE_Memory_Item and itemCfg.ItemSubType == ENUM_ITEM_SUBTYPE.Aid_Gift then
- local logic_send_gift = require("client.slua.logic.gift.logic_send_gift")
- local giftData = logic_send_gift.GetGiftDataByResID(itemID)
- if giftData then
- table.insert(list, giftData.GiftAni)
- end
- end
- return list
- end
- function PufferODPakManager:CheckAutoDownloadByItemID(itemID)
- itemID = tonumber(itemID)
- if not itemID or itemID <= 0 then
- return false
- end
- local paks = self:GetPakNamesByItemID(itemID)
- local isAuto = false
- for pakName, _ in pairs(paks) do
- if self:CheckAutoDownloadByPakName(pakName) then
- isAuto = true
- break
- end
- end
- return isAuto
- end
- function PufferODPakManager:CheckAutoDownloadByPakName(pakName)
- if pakName == "" then
- return false
- end
- if pakName == PufferConst.CE_LOCK_PAKNAME then
- return false
- end
- if pakName == PufferConst.LOCK_PAKNAME then
- return false
- end
- return PufferQueue:CheckAutoDownloadTask(pakName)
- end
- function PufferODPakManager:GetSizeByKeyList(downloadType, keyList, bSkipDepends)
- local curSize = 0
- local totalSize = 0
- if not keyList then
- return curSize, totalSize
- end
- if downloadType == PufferConst.ENUM_DownloadType.ODPAK and 1 < #keyList then
- local bAllItemID = true
- for i, v in pairs(keyList) do
- if type(v) ~= "number" then
- bAllItemID = false
- break
- end
- end
- if bAllItemID then
- return self:GetSizeByItemIDList(keyList)
- end
- end
- for i, v in pairs(keyList) do
- if downloadType == PufferConst.ENUM_DownloadType.ODPAK then
- if type(v) == "number" then
- local cSize, tSize = self:GetSizeByItemID(v)
- curSize = curSize + cSize
- totalSize = totalSize + tSize
- elseif StringUtil.starts(v, PufferConst.ODPAKS_RELATIVE_DIR) then
- local cSize, tSize = self:GetSizeByPakName(v)
- curSize = curSize + cSize
- totalSize = totalSize + tSize
- elseif self:GetPakNamesByFeatureID(v) then
- local pakName = next(self:GetPakNamesByFeatureID(v))
- local cSize, tSize = self:GetSizeByPakName(pakName)
- curSize = curSize + cSize
- totalSize = totalSize + tSize
- else
- local cSize, tSize = self:GetSizeByPath(v)
- curSize = curSize + cSize
- totalSize = totalSize + tSize
- end
- elseif downloadType == PufferConst.ENUM_DownloadType.ODPACK then
- local cSize, tSize = self:GetSizeByPackID(v)
- curSize = curSize + cSize
- totalSize = totalSize + tSize
- end
- end
- return curSize, totalSize
- end
- function PufferODPakManager:GetSizeByItemIDList(itemIDList)
- local cSize = 0
- local tSize = 0
- local allPaks = {}
- for i, v in pairs(itemIDList) do
- local paks = self:GetPakNamesByItemID(v)
- for pakName, _ in pairs(paks) do
- allPaks[pakName] = true
- end
- end
- for pakName, _ in pairs(allPaks) do
- local flag = false
- local pakData = self:GetPakDataByPakName(pakName)
- if pakData then
- flag = true
- cSize = cSize + pakData.cSize * PufferConst.MB
- tSize = tSize + pakData.tSize * PufferConst.MB
- end
- if not flag then
- tSize = tSize + PufferDownloader.GetFileSizeCompressed(GameFrontendHUD, pakName, true)
- end
- end
- return cSize, tSize
- end
- function PufferODPakManager:GetSizeByItemID(itemID)
- local cSize = 0
- local tSize = 0
- local paks = self:GetPakNamesByItemID(itemID)
- for pakName, _ in pairs(paks) do
- local flag = false
- local pakData = self:GetPakDataByPakName(pakName)
- if pakData then
- flag = true
- cSize = cSize + pakData.cSize * PufferConst.MB
- tSize = tSize + pakData.tSize * PufferConst.MB
- end
- if not flag then
- tSize = tSize + PufferDownloader.GetFileSizeCompressed(GameFrontendHUD, pakName, true)
- end
- end
- if self:GetStateByItemID(itemID) == PufferConst.ENUM_DownloadState.Done then
- cSize = tSize
- end
- return cSize, tSize
- end
- function PufferODPakManager:GetSizeByPath(path)
- local PufferManager = require("client.slua.logic.download.puffer.puffer_manager")
- local cSize, tSize = 0, 0
- local pakName = PufferManager.GetPakName(path)
- cSize, tSize = self:GetSizeByPakName(pakName)
- return cSize, tSize
- end
- function PufferODPakManager:GetSizeByPakName(pakName)
- local cSize, tSize = 0, 0
- if pakName == nil or pakName == "" then
- return 0, 0
- end
- local pakNameData = self:GetPakDataByPakName(pakName)
- if pakNameData then
- cSize = pakNameData.cSize * PufferConst.MB
- tSize = pakNameData.tSize * PufferConst.MB
- end
- if tSize == 0 then
- tSize = PufferDownloader.GetFileSizeCompressed(GameFrontendHUD, pakName, true)
- local MinSize = PufferConst.MB * 0.1
- if tSize == 0 then
- tSize = MinSize
- end
- end
- if self:GetStateByPakName(pakName) == PufferConst.ENUM_DownloadState.Done then
- cSize = tSize
- end
- return cSize, tSize
- end
- function PufferODPakManager:GetSizeByPackID(packID)
- local pack = self.ODPaks[packID]
- if not pack then
- return 0, 0
- end
- return pack.curSize, pack.totalSize
- end
- function PufferODPakManager:GetAllODPakCurSize(skipIDs)
- local curSize = 0
- local totalSize = 0
- local state = PufferConst.ENUM_DownloadState.Done
- for packID, v in pairs(self.ODPaks) do
- if not skipIDs or not skipIDs[packID] then
- curSize = curSize + v.curSize
- totalSize = totalSize + v.totalSize
- if v.curSize > v.totalSize then
- log(bWriteLog and "PufferODPakManager:GetAllODPakCurSize. packID = " .. tostring(packID))
- end
- local curPriority = PufferConst.DownloadStatePriority[v.state]
- local prePriority = PufferConst.DownloadStatePriority[state]
- if curPriority and prePriority and curPriority > prePriority then
- state = v.state
- end
- end
- end
- log(bWriteLog and string.format("PufferODPakManager:GetAllODPakCurSize. curSize=%s, totalSize=%s, state=%s", tostring(curSize), tostring(totalSize), tostring(state)))
- return curSize, totalSize, state
- end
- function PufferODPakManager:ResetPakData(pakName)
- local deleteSize = 0
- PufferDownloader.ClearPakCache(pakName)
- if self.needRecoverBattleData then
- self.battleDeleteFiles[pakName] = true
- else
- local ENUM_DownloadState = PufferConst.ENUM_DownloadState
- local packID, packData = self:GetPackDataByPakName(pakName)
- if packID and packData then
- local pakData = packData.paks[pakName]
- if pakData then
- if pakData.state == ENUM_DownloadState.Done then
- if 0 < packData.curCnt then
- packData.curCnt = packData.curCnt - 1
- packData.curSize = packData.curSize - pakData.tSize
- deleteSize = deleteSize + pakData.tSize
- end
- if packData.curCnt == 0 then
- packData.curSize = 0
- packData.state = ENUM_DownloadState.Not
- elseif packData.curCnt < packData.totalCnt then
- packData.state = ENUM_DownloadState.Pause
- end
- pakData.state = ENUM_DownloadState.Not
- end
- pakData.cSize = 0
- pakData.haveDeleted = true
- end
- end
- end
- return deleteSize
- end
- function PufferODPakManager:RemovePakData(pakName)
- log(bWriteLog and string.format("PufferODPakManager:RemovePakData. pakName=%s", tostring(pakName)))
- local packID, packData = self:GetPackDataByPakName(pakName)
- if packID and packData then
- local pakData = packData.paks[pakName]
- if pakData then
- local subFinishCnt = 0
- if pakData.state == PufferConst.ENUM_DownloadState.Done then
- subFinishCnt = 1
- end
- packData.curCnt = packData.curCnt - subFinishCnt
- packData.totalCnt = packData.totalCnt - 1
- packData.curSize = packData.curSize - pakData.cSize
- packData.totalSize = packData.totalSize - pakData.tSize
- log(bWriteLog and "PufferODPakManager:RemovePakData. packData.curCnt = " .. tostring(packData.curCnt))
- log(bWriteLog and "PufferODPakManager:RemovePakData. packData.totalCnt = " .. tostring(packData.totalCnt))
- if packData.curCnt == packData.totalCnt then
- packData.state = PufferConst.ENUM_DownloadState.Done
- end
- self.PakDatas[pakName] = nil
- end
- end
- end
- function PufferODPakManager:GetItemBPPathByItemID(itemID)
- if self.itemToPaths[itemID] and self.itemToPaths[itemID] ~= "" then
- return self.itemToPaths[itemID]
- end
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if not itemCfg then
- local ActorVoiceSystem = require("client.slua.logic.actor_voice.logic_actor_voice")
- local bankPath = ActorVoiceSystem.GetBankPathByActorID(itemID)
- if bankPath then
- self.itemToPaths[itemID] = bankPath
- return bankPath
- end
- return nil
- end
- local ID = itemID
- if itemCfg.BPID > 0 and itemCfg.BPID ~= itemID then
- ID = itemCfg.BPID
- end
- local bpCfg = CDataTable.GetTableData("AvatarBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.AvatarBPPath
- return bpCfg.AvatarBPPath
- end
- bpCfg = CDataTable.GetTableData("WeaponDIYList", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.MeshPath
- return bpCfg.MeshPath
- end
- bpCfg = CDataTable.GetTableData("WeaponBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("PlaneBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("VehicleBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("ConsumableBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("EmoteBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("PetDressBlueprintTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("CareerBPTable", ID)
- if bpCfg then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("GiftBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.GiftAniPath
- return bpCfg.GiftAniPath
- end
- bpCfg = CDataTable.GetTableData("HallThemeItem", ID)
- if bpCfg then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("EffectItemBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("PetSwitchEffectBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("3DIconBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("DecalBPTable", ID)
- if bpCfg ~= nil then
- self.itemToPaths[itemID] = bpCfg.Path
- return bpCfg.Path
- end
- if itemCfg.ItemSubType == ENUM_ITEM_SUBTYPE.Voice_Pack or itemCfg.ItemSubType == ENUM_ITEM_SUBTYPE.Electronic_Eecord then
- local ActorVoiceSystem = require("client.slua.logic.actor_voice.logic_actor_voice")
- local path = ActorVoiceSystem.GetBankPath(itemID)
- self.itemToPaths[itemID] = path
- return path
- end
- return nil
- end
- function PufferODPakManager:GetJKItemBPPathByItemID(itemID)
- local PublishRegionMacros = require("client.slua.config.ClientMacros.PublishRegionMacros")
- if not PublishRegionMacros.IsJapanOrKorea() then
- return
- end
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if not itemCfg then
- return
- end
- local ID = itemCfg.JKBPID
- if ID == 0 or ID == itemCfg.BPID or ID == nil then
- return
- end
- local bpCfg = CDataTable.GetTableData("AvatarBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.AvatarBPPath
- end
- bpCfg = CDataTable.GetTableData("WeaponDIYList", ID)
- if bpCfg ~= nil then
- return bpCfg.MeshPath
- end
- bpCfg = CDataTable.GetTableData("WeaponBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("PlaneBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("VehicleBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("ConsumableBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("EmoteBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("PetDressBlueprintTable", ID)
- if bpCfg ~= nil then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("CareerBPTable", ID)
- if bpCfg then
- return bpCfg.Path
- end
- bpCfg = CDataTable.GetTableData("HallThemeItem", ID)
- if bpCfg then
- return bpCfg.Path
- end
- return nil
- end
- function PufferODPakManager:_InitAttachmentSkinIDListCache()
- if self._attachmentSkinIDInited then
- return
- end
- log(bWriteLog and "PufferODPakManager:_InitAttachmentSkinIDListCache.")
- self._attachmentSkinIDMap = {}
- self._attachmentSkinIDInited = true
- local cfgs = CDataTable.GetTable("WeaponAttrBPTable")
- for BPID, cfg in pairs(cfgs) do
- local list = self:_GetAttachmentSkinIDListByConfig(cfg)
- self._attachmentSkinIDMap[BPID] = list
- end
- end
- function PufferODPakManager:_GetAttachmentSkinIDListByConfig(cfg)
- if cfg == nil then
- return nil
- end
- local idList = {}
- if cfg.AttachmentSkinIDList and cfg.AttachmentSkinIDList ~= "" then
- for i, v in pairs(StringUtil.split(cfg.AttachmentSkinIDList, "|")) do
- local attachmentSkinID = StringUtil.split(v, "-")[2]
- table.insert(idList, tonumber(attachmentSkinID))
- end
- end
- if cfg.PendantID > 0 then
- table.insert(idList, cfg.PendantID)
- end
- if cfg.DeadInventoryBoxIDs and cfg.DeadInventoryBoxIDs ~= "" then
- for i, v in pairs(StringUtil.split(cfg.DeadInventoryBoxIDs, "|")) do
- table.insert(idList, tonumber(v))
- end
- end
- if not next(idList) then
- idList = nil
- end
- return idList
- end
- function PufferODPakManager:_GetAttachmentSkinIDList(BPID)
- if self.isLowMemoryDevice then
- local cfg = CDataTable.GetTableData("WeaponAttrBPTable", BPID)
- return cfg and self:_GetAttachmentSkinIDListByConfig(cfg)
- else
- self:_InitAttachmentSkinIDListCache()
- return self._attachmentSkinIDMap and self._attachmentSkinIDMap[BPID]
- end
- end
- function PufferODPakManager:_GetRelatedItems(itemID, bNotMapping)
- if self.itemToItems[itemID] then
- return self.itemToItems[itemID]
- end
- local depend = {}
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if not itemCfg then
- if CDataTable.GetTableData("VoiceActorCfg", itemID) then
- self.itemToItems[itemID] = {itemID}
- return {itemID}
- end
- return depend
- end
- local ModuleManager = require("client.module_framework.ModuleManager")
- local ItemUpgradeMgr = ModuleManager.GetModule(ModuleManager.LobbyModuleConfig.ItemUpgradeManager)
- local upgradeCfgList = ItemUpgradeMgr:GetUpgradeGroupByItemID(itemID)
- local attachmentSkinIDList = self:_GetAttachmentSkinIDList(itemCfg.BPID)
- local BackpackMappingCfg = CDataTable.GetTableData("BackpackMapping", itemID)
- if BackpackMappingCfg then
- depend[BackpackMappingCfg.SkinItemIDLv1] = true
- depend[BackpackMappingCfg.SkinItemIDLv2] = true
- depend[BackpackMappingCfg.SkinItemIDLv3] = true
- depend[BackpackMappingCfg.LobbyShowItemID] = true
- elseif upgradeCfgList and next(upgradeCfgList) then
- local upgradeItemID = 0
- for _, v in pairs(upgradeCfgList) do
- if upgradeItemID == 0 then
- upgradeItemID = v.itemID
- end
- depend[v.ItemID] = true
- local list = self:_GetAttachmentSkinIDList(v.ItemID)
- if list then
- for _, vv in pairs(list) do
- depend[vv] = true
- end
- end
- end
- local groupID = ItemUpgradeMgr:GetUpgradeCfg(upgradeItemID).GroupID
- groupID = ItemUpgradeMgr:GetNormalGroupID(groupID)
- log(bWriteLog and string.format("PufferODPakManager:_GetRelatedItems groupdId=%s", tostring(groupID)))
- local partIDList = ItemUpgradeMgr:GetPartIDList(groupID)
- local isCanSetRefitCfg = ItemUpgradeMgr:IsCanSetRefitCfgTableInfo(groupID)
- for _, partID in pairs(partIDList) do
- if isCanSetRefitCfg then
- local diffColorPartID = ItemUpgradeMgr:PartIDSwitch(partID, true)
- if diffColorPartID ~= partID and diffColorPartID then
- depend[diffColorPartID] = true
- end
- end
- depend[partID] = true
- end
- if isCanSetRefitCfg then
- local refitCfg = ItemUpgradeMgr:GetRefitCfgData(groupID)
- if refitCfg and refitCfg.refitGroupID then
- local refitUpgradeCfgList = ItemUpgradeMgr:GetUpgradeGroupByID(refitCfg.refitGroupID)
- if refitUpgradeCfgList then
- for _, v in pairs(refitUpgradeCfgList) do
- depend[v.ItemID] = true
- local list = self:_GetAttachmentSkinIDList(v.ItemID)
- if list then
- for _, vv in pairs(list) do
- depend[vv] = true
- end
- end
- end
- end
- end
- end
- elseif attachmentSkinIDList then
- for i, v in pairs(attachmentSkinIDList) do
- depend[v] = true
- end
- end
- local cfg = CDataTable.GetTableData("WeaponSkinMapping", itemID)
- if cfg then
- depend[cfg.WeaponID] = true
- end
- cfg = CDataTable.GetTableData("VehiclePlaneSkinMapping", itemID)
- if cfg then
- depend[cfg.OrginalID] = true
- end
- cfg = CDataTable.GetTableData("AvatarSuitsTable", itemID)
- if cfg then
- for _, v in pairs(StringUtil.split(cfg.MaleSuits, "|")) do
- local id = tonumber(v)
- if id and 0 < id then
- depend[id] = true
- end
- end
- for _, v in pairs(StringUtil.split(cfg.FemaleSuits, "|")) do
- local id = tonumber(v)
- if id and 0 < id then
- depend[id] = true
- end
- end
- end
- local featuresItem = CDataTable.GetTableData("FeaturesItems", itemID)
- if featuresItem then
- local VersionUtil = require("client.common.version_util")
- local versionNum = VersionUtil.GetCurVersionNumber()
- local features = StringUtil.split(featuresItem.Features, ";")
- for _, v in ipairs(features) do
- if v then
- local featureCfg = CDataTable.GetTableData("FeaturesConfig", tonumber(v))
- if featureCfg then
- if featureCfg.ExpressionID and 0 < featureCfg.ExpressionID then
- depend[featureCfg.ExpressionID] = true
- end
- if featureCfg.EnterExpressionID and 0 < featureCfg.EnterExpressionID and featureCfg.EnterExpressionID ~= featureCfg.ExpressionID then
- depend[featureCfg.EnterExpressionID] = true
- end
- if featureCfg.FightExpressionID and 0 < featureCfg.FightExpressionID and featureCfg.FightExpressionID ~= featureCfg.EnterExpressionID then
- depend[featureCfg.FightExpressionID] = true
- end
- end
- end
- end
- end
- cfg = CDataTable.GetTableData("EmoteBPTable", itemID)
- if cfg and cfg.LobbyEmoteAdapt ~= "" then
- for _, v in pairs(StringUtil.split(cfg.LobbyEmoteAdapt, "|")) do
- local id = tonumber(v)
- if id and 0 < id then
- depend[id] = true
- end
- end
- end
- local LogicGoldenSuit = require("client.slua.logic.golden_suit.logic_golden_suit")
- local period = LogicGoldenSuit.GetPeriodByItemId(itemID)
- if period then
- local goldList = LogicGoldenSuit.GetItemIDListByPeriod(period)
- for _, v in pairs(goldList) do
- depend[v] = true
- end
- local CallStatueActionIDMap = {
- [3] = 12219840,
- [4] = 12219841,
- [5] = 12219842
- }
- local actionID = CallStatueActionIDMap[period]
- if actionID then
- depend[actionID] = true
- end
- end
- local SpecialGlideID = LogicGoldenSuit.GetSpecialGlideID(itemID)
- depend[SpecialGlideID] = true
- local logic_pet = ModuleManager.GetModule(ModuleManager.CommonModuleConfig.logic_pet)
- local PetID = logic_pet:GetAssociatedPetID(itemID)
- if PetID then
- depend[PetID] = true
- local petDependRes = logic_pet:GetPetDependResource(PetID)
- if petDependRes then
- for _, v in pairs(petDependRes) do
- depend[v] = true
- end
- end
- end
- local UpVehicleModule = ModuleManager.GetModule(ModuleManager.LobbyModuleConfig.UpVehicle)
- local carItemIDS = UpVehicleModule:GetAssociatedCars(itemID)
- if carItemIDS then
- for _, v in pairs(carItemIDS) do
- depend[v] = true
- end
- end
- local ModuleManager = require("client.module_framework.ModuleManager")
- local LogicMultiItemModule = ModuleManager.GetModule(ModuleManager.LobbyModuleConfig.LogicMultiItemModule)
- local MultiList = LogicMultiItemModule:GetMultiListByItemID(itemID)
- for key, value in pairs(MultiList) do
- if value then
- depend[value.ItemID] = true
- end
- end
- local VehiclePlateLicenseUtil = require("GameLua.Activity.Commercialize.GamePlay.Vehicle.VehiclePlateLicenseUtil")
- local vehicleItems = VehiclePlateLicenseUtil.GetDownLoadList(itemID)
- if vehicleItems then
- for _, v in pairs(vehicleItems) do
- depend[v] = true
- end
- end
- local logic_emote = require("GameLua.Mod.Library.GamePlay.Avatar.Emote.logic_emote")
- local MileStoneDownloadList = logic_emote.GetMileStoneDownloadList(itemID)
- if MileStoneDownloadList then
- for ItemID, v in pairs(MileStoneDownloadList) do
- if ItemID and 0 < ItemID then
- depend[ItemID] = true
- end
- end
- end
- local LogicParticleEmote = ModuleManager.GetModule(ModuleManager.LobbyModuleConfig.LogicParticleEmote)
- if LogicParticleEmote:IsParticleEmote(itemID) then
- local HighLevelEmoteID = LogicParticleEmote:GetParticleEmoteID(itemID)
- depend[HighLevelEmoteID] = true
- elseif LogicParticleEmote:Is2LevelParticleEmote(itemID) then
- local BaseEmoteID = LogicParticleEmote:GetBaseID(itemID)
- depend[BaseEmoteID] = true
- end
- cfg = CDataTable.GetTableData("VehiclePlaneSkinMapping", itemID)
- if cfg and cfg.OrginalID then
- depend[cfg.OrginalID] = true
- end
- if not bNotMapping then
- cfg = CDataTable.GetTableData("BPMappingTable", itemID)
- if cfg and cfg.BPMapping and cfg.BPMapping ~= "" then
- local MapList = StringUtil.split(cfg.BPMapping, "|")
- for i, v in pairs(MapList) do
- local id = tonumber(v)
- if id and 0 < id then
- depend[id] = true
- local tmpList = self:_GetRelatedItems(id, true)
- for _, vTmp in pairs(tmpList) do
- local idTmp = tonumber(vTmp)
- if idTmp and 0 < idTmp then
- depend[idTmp] = true
- end
- end
- end
- end
- end
- end
- depend[itemID] = true
- local list = {}
- for i, _ in pairs(depend) do
- table.insert(list, i)
- end
- if not bNotMapping then
- self.itemToItems[itemID] = list
- end
- return list
- end
- function PufferODPakManager:_GetItemLobbyPathByBPID(itemID)
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if not itemCfg then
- return nil
- end
- local ID = itemID
- if itemCfg.BPID > 0 and itemCfg.BPID ~= itemID then
- ID = itemCfg.BPID
- end
- local bpCfg = CDataTable.GetTableData("AvatarBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("WeaponBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("PlaneBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("VehicleBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("ConsumableBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("EmoteBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- bpCfg = CDataTable.GetTableData("EffectItemBPTable", ID)
- if bpCfg ~= nil then
- return bpCfg.LobbyPath
- end
- return nil
- end
- function PufferODPakManager:_GetItemHighPathByBPID(itemID)
- local itemCfg = CDataTable.GetTableData("Item", itemID)
- if not itemCfg then
- return nil
- end
- local ID = itemID
- if itemCfg.BPID > 0 and itemCfg.BPID ~= itemID then
- ID = itemCfg.BPID
- end
- local bpCfg = CDataTable.GetTableData("AvatarBPTable", ID)
- if bpCfg ~= nil and 0 < bpCfg.DeviceLevel then
- local TCDeviceLevel = Client.GetTCDeviceLevel()
- if TCDeviceLevel >= bpCfg.DeviceLevel then
- local list = {}
- table.insert(list, bpCfg.AvatarBPPathHigh)
- table.insert(list, bpCfg.LobbyPathHigh)
- return list
- end
- end
- return {}
- end
- function PufferODPakManager:GetPakIDAndSizeByPakName(pakName)
- if pakName == nil or pakName == "" then
- return nil, 0
- end
- for k, v in pairs(self.ODPaks) do
- if v.paks[pakName] then
- return k, v.paks[pakName].tSize
- end
- end
- return nil, 0
- end
- function PufferODPakManager:DumpUGCDebugInfo()
- if not bWriteLog then
- return
- end
- local str = ""
- for packID, v1 in pairs(self.ODPaks) do
- if v1.isVirtual then
- str = str .. string.format("PufferODPakManager:DumpUGCDebugInfo begin ---------------- packID:%s,curSize:%.2f,totalSize:%.2f,done:%s\n", tostring(packID), v1.curSize, v1.totalSize, tostring(v1.state == 3))
- for pakName, v2 in pairs(v1.paks) do
- str = str .. string.format("PufferODPakManager:DumpUGCDebugInfo packID:%s,pakName:%s,curSize:%.2f,totalSize:%.2f,done:%s\n", tostring(packID), pakName, v2.cSize, v2.tSize, tostring(v2.state == 3))
- end
- end
- end
- log(str)
- str = ""
- for itemID, Paks in pairs(self.itemToPaks) do
- str = str .. "UGCPAKInfo,ItemID:" .. tostring(itemID) .. " , Paks : {"
- for pakName, _ in pairs(Paks.paks) do
- str = str .. pakName .. ","
- end
- str = str .. "}\n"
- end
- log(str)
- return str
- end
- function PufferODPakManager:UpdateLocalPkgIntoCSC(existPaks)
- if not Client.USFSIsNewestVersion() then
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC return for not Client.USFSIsNewestVersion()")
- return
- end
- local UpdateLocalPkgOnceCount = HDmpveRemote.HDmpveRemoteConfigGetInt("UpdateLocalPkgOnceCount", 0)
- if UpdateLocalPkgOnceCount <= 0 then
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC return for UpdateLocalPkgOnceCount <= 0")
- return
- end
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC beg UpdateLocalPkgOnceCount: " .. UpdateLocalPkgOnceCount)
- existPaks = existPaks or {}
- local TmpArrayData = {}
- for pakName, _ in pairs(existPaks) do
- if string.find(pakName, ".pak") then
- local FilePath = Client.ProjectSavedDir() .. "Paks/" .. pakName
- if not Client.IsFileExistInCSCWithCheck(pakName) then
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC collect local FilePath: " .. FilePath)
- table.insert(TmpArrayData, FilePath)
- else
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC existPaks pakName: " .. pakName)
- end
- if UpdateLocalPkgOnceCount <= #TmpArrayData then
- break
- end
- end
- end
- if #TmpArrayData then
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC USFSCacheSysContextUpdatePkg TmpArrayData: " .. tostring(#TmpArrayData))
- Client.USFSCacheSysContextUpdatePkg(TmpArrayData)
- end
- log(bWriteLog and "PufferODPakManager:UpdateLocalPkgIntoCSC end")
- end
- function PufferODPakManager:UpdatePkgCheckInfo(existPaks)
- local CacheSysContextStartSwitch = HDmpveRemote.HDmpveRemoteConfigGetInt("USFSCacheSysContextStart", 0)
- if CacheSysContextStartSwitch == 0 then
- return
- end
- log(bWriteLog and "PufferODPakManager:UpdatePkgCheckInfo beg")
- local PufferODPakDelList = {
- "ODPaks/fff3aff29028cff62c90d6205d2a9882df19d569.pak",
- }
- local USFSKickoutPkgName = HDmpveRemote.HDmpveRemoteConfigGetString("USFSKickoutPkgName", "")
- local tempList = StringUtil.split(USFSKickoutPkgName, ",")
- for _, KickPkgInfo in pairs(tempList) do
- local PkgName = KickPkgInfo
- if string.find(KickPkgInfo, "/Game/") then
- PkgName = GCPufferDownloader.GetODPakName(Puffer, KickPkgInfo)
- else
- PkgName = "ODPaks/" .. KickPkgInfo .. ".pak"
- end
- if self.ODPaksNameToConHash[PkgName] then
- self.ODPaksNameToConHash[PkgName] = "0202020202020202020202020202020202020202"
- log("PufferODPakManager:InitODPack Kickout: " .. PkgName .. " " .. self.ODPaksNameToConHash[PkgName])
- end
- end
- local ScriptHelperClient = import("ScriptHelperClient")
- local data = ScriptHelperClient.LoadFileToArrayByFullPath(Client.ProjectDir() .. "Config/CommCRC.ini")
- if data then
- local StringUtil = require("common.string_util")
- data = StringUtil.split(data, "\n")
- for _, Info in pairs(data) do
- local PkgName = string.gsub(Info, "[\n\r]", "")
- PkgName = "ODPaks/" .. PkgName .. ".pak"
- if self.ODPaksNameToConHash[PkgName] then
- self.ODPaksNameToConHash[PkgName] = "0202020202020202020202020202020202020202"
- log("PufferODPakManager:InitODPack CommCRC.ini Kickout: " .. PkgName .. " " .. self.ODPaksNameToConHash[PkgName])
- end
- end
- end
- for __, PkgName in pairs(PufferODPakDelList) do
- self.ODPaksNameToConHash[PkgName] = "0202020202020202020202020202020202020202"
- log("PufferODPakManager:InitODPack PufferODPakDelList Kickout: " .. PkgName .. " " .. self.ODPaksNameToConHash[PkgName])
- end
- local USFSCacheSysContexInit = HDmpveRemote.HDmpveRemoteConfigGetInt("USFSCacheSysContexInit", 1)
- if USFSCacheSysContexInit == 1 then
- log(bWriteLog and "PufferODPakManager:UpdatePkgCheckInfo Client.USFSCacheSysContexInit")
- Client.USFSCacheSysContexInit(self.ODPaksNameToConHash)
- end
- self.ODPaksNameToConHash = nil
- local ArrayData = {}
- ArrayData[1] = "ShadowTrackerExtra/Content/Paks/res_cachesyspkgdiffmini_obb.pak"
- Client.USFSCacheSysContextUpdatePkgDiff(ArrayData)
- self:UpdateLocalPkgIntoCSC(existPaks)
- log(bWriteLog and "PufferODPakManager:UpdatePkgCheckInfo end")
- end
- function PufferODPakManager:GetPakDataByPakName(pakName)
- local pakData = self.PakDatas and self.PakDatas[pakName]
- if pakData then
- return pakData.data
- end
- return nil
- end
- function PufferODPakManager:GetPackDataByPakName(pakName)
- if not pakName then
- return
- end
- local pakData = self.PakDatas[pakName]
- if pakData then
- return pakData.packID, self.ODPaks[pakData.packID]
- end
- return nil, nil
- end
- function PufferODPakManager:OnDownloadFinish(task, isSuccess, errorCode, IsUGC)
- local pakName = task.pakName
- local ODPackID, packData = self:GetPackDataByPakName(pakName)
- if ODPackID and packData then
- local pakData = packData.paks[pakName]
- if pakData then
- local PufferTlog = require("client.slua.logic.download.report.puffer_tlog")
- if isSuccess or errorCode == 1 and not Client.IsDevelopment() then
- pakData.cSize = pakData.tSize
- packData.curSize = packData.curSize + pakData.tSize
- packData.curCnt = packData.curCnt + 1
- pakData.state = PufferConst.ENUM_DownloadState.Done
- if pakData.tSize >= 5 then
- PufferTlog.SendTLog(task.from, PufferTlog.Enum_TLog_Optype.Finish, pakName)
- end
- if packData.curCnt >= packData.totalCnt then
- packData.curCnt = packData.totalCnt
- packData.curSize = packData.totalSize
- packData.state = PufferConst.ENUM_DownloadState.Done
- if not IsUGC then
- PufferDownloader.SetDownloadKeyRecord(ODPackID, true)
- PufferTlog.SendTLog(task.from, PufferTlog.Enum_TLog_Optype.Finish, ODPackID, nil, ODPackID == PufferConst.EODPackID.PREFETCH_ODPACKID)
- local PufferSwitch = require("client.slua.logic.download.puffer_switch")
- log(bWriteLog and string.format("puffer_odpak_downloader:OnDownloadFinish pakName:%s ODPackID:%s", pakName, ODPackID))
- local ModuleManager = require("client.module_framework.ModuleManager")
- local ui_navigation_manager = ModuleManager.GetModule(ModuleManager.CommonModuleConfig.ui_navigation_manager)
- local keyName = ui_navigation_manager:GetTopUIName()
- log(bWriteLog and string.format("puffer_odpak_downloader:OnDownloadFinish keyName:%s ODPackDownloadFinishPopUpSwitch:%s", keyName, tostring(PufferSwitch.ODPackDownloadFinishPopUpSwitch)))
- self:JumpODPack(ODPackID)
- log(bWriteLog and string.format("puffer_odpak_downloader:OnDownloadFinish ODPack:%s", ODPackID))
- end
- end
- else
- pakData.state = PufferConst.ENUM_DownloadState.Error
- end
- end
- end
- end
- function PufferODPakManager:HandleEnterFight()
- log(bWriteLog and "PufferODPakManager:HandleEnterFight. self.enableSaveODPakDataToFile = " .. tostring(self.enableSaveODPakDataToFile))
- if not self.enableSaveODPakDataToFile then
- return
- end
- self.needRecoverBattleData = true
- self.battleDeleteFiles = {}
- xpcall(self.SaveODPakDataToFile, function()
- log(bWriteLog and "PufferODPakManager:HandleEnterFight. save error")
- self.needRecoverBattleData = false
- end, self)
- if self.needRecoverBattleData then
- self:ClearBattleMemory()
- end
- end
- function PufferODPakManager:HandleExitFight()
- log(bWriteLog and "PufferODPakManager:HandleExitFight. self.enableSaveODPakDataToFile = " .. tostring(self.enableSaveODPakDataToFile))
- log(bWriteLog and "PufferODPakManager:HandleExitFight. self.needRecoverData = " .. tostring(self.needRecoverBattleData))
- if not self.enableSaveODPakDataToFile or not self.needRecoverBattleData then
- return
- end
- self.needRecoverBattleData = false
- local loadComplete = true
- xpcall(self.LoadODPakDataFromFile, function()
- log(bWriteLog and "PufferODPakManager:HandleExitFight. load error")
- loadComplete = false
- end, self)
- if loadComplete and next(self.ODPaks) then
- self:RecoverBattleMemory()
- else
- local ret = GCPufferDownloader.ReturnLocalFiles(PufferDownloader.DOWNLOAD_DIR_RELATIVE .. PufferDownloader.DOWNLOAD_ODPAKS_RELATIVE, "")
- local existPaks = {}
- for _, filename in pairs(ret) do
- existPaks[PufferDownloader.DOWNLOAD_ODPAKS_RELATIVE .. filename] = true
- end
- self:InitODPaks(existPaks)
- end
- end
- function PufferODPakManager:GetSaveFilePath()
- return "ODPakData.txt"
- end
- function PufferODPakManager:SaveODPakDataToFile()
- log(bWriteLog and "PufferODPakManager:SaveODPakDataToFile.")
- local json = require("common.json_util")
- local encode = json.encode(self.ODPaks)
- Client.SaveStringToFile(encode, self:GetSaveFilePath())
- self:ClearBattleMemory()
- end
- function PufferODPakManager:LoadODPakDataFromFile()
- log(bWriteLog and "PufferODPakManager:LoadODPakDataFromFile.")
- local path = self:GetSaveFilePath()
- local dataStr = Client.LoadFileToString(path)
- local json = require("common.json_util")
- local data = json.decode(dataStr)
- if not data then
- log(bWriteLog and "PufferODPakManager:LoadODPakDataFromFile. data is nil")
- return
- end
- log_tree("PufferODPakManager:LoadODPakDataFromFile. data = ", data)
- for k, v in pairs(data) do
- self.ODPaks[tonumber(k)] = v
- end
- Client.DeleteFile(path)
- end
- function PufferODPakManager:ClearBattleMemory()
- log(bWriteLog and "PufferODPakManager:ClearBattleMemory.")
- self.ODPaks = {}
- self.PakDatas = {}
- self.itemToPaks = {}
- self.itemToItems = {}
- self.itemToPaths = {}
- end
- function PufferODPakManager:RecoverBattleMemory()
- log(bWriteLog and "PufferODPakManager:RecoverBattleMemory.")
- local begintime = slua.getMiliseconds()
- self.PakDatas = {}
- for packID, v in pairs(self.ODPaks) do
- for pakName, data in pairs(v.paks) do
- self.PakDatas[pakName] = {packID = packID, data = data}
- end
- end
- local deleteFiles = self.battleDeleteFiles
- self.battleDeleteFiles = {}
- for pakName, v in pairs(deleteFiles) do
- self:ResetPakData(pakName)
- end
- local costTime = slua.getMiliseconds() - begintime
- log(bWriteLog and "PufferODPakManager:RecoverBattleMemory. costTime = " .. tostring(costTime))
- end
- function PufferODPakManager:OnPostSwitchGameStatus(pre, next)
- log(bWriteLog and string.format("PufferODPakManager:OnPostSwitchGameStatus. pre=%s, next=%s", tostring(pre), tostring(next)))
- if GameStatus.InActualFight() then
- self:HandleEnterFight()
- end
- end
- function PufferODPakManager:OnPreSwitchGameStatus(pre, next)
- log(bWriteLog and string.format("PufferODPakManager:OnPreSwitchGameStatus. pre=%s, next=%s", tostring(pre), tostring(next)))
- if GameStatus.InActualFight() and next ~= GameStatus.Fighting then
- self:HandleExitFight()
- end
- end
- local class = require("class")
- local CModuleBase = require("client.module_framework.ModuleBase")
- local CPufferODPakManager = class(CModuleBase, nil, PufferODPakManager)
- return CPufferODPakManager
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement