|  |  |  | 
|---|
|  |  |  | #--------------------------------------------------------------------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import GameWorld | 
|---|
|  |  |  | import GameWorship | 
|---|
|  |  |  | import PlayerControl | 
|---|
|  |  |  | import NetPackCommon | 
|---|
|  |  |  | import GameWorldArena | 
|---|
|  |  |  | import ChPyNetSendPack | 
|---|
|  |  |  | import PlayerFBHelpBattle | 
|---|
|  |  |  | import GameWorldSkyTower | 
|---|
|  |  |  | import CrossChampionship | 
|---|
|  |  |  | import CrossBattlefield | 
|---|
|  |  |  | import PyGameDataStruct | 
|---|
|  |  |  | import IpyGameDataPY | 
|---|
|  |  |  | import PyDataManager | 
|---|
|  |  |  | import ShareDefine | 
|---|
|  |  |  | import ChConfig | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import json | 
|---|
|  |  |  | import time | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def DoOnDay(): | 
|---|
|  |  |  | def DoOnDayEx(): | 
|---|
|  |  |  | DelOutofTimeViewCacheData() | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def IsSaveDBViewCache(playerID, playerLV): | 
|---|
|  |  |  | ## 是否保存基本的缓存数据 | 
|---|
|  |  |  | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if GameWorldArena.IsArenaBattlePlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if CrossBattlefield.IsBattlefieldCallPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if CrossChampionship.IsChampionshipPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if GameWorship.IsWorshipPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if GameWorldSkyTower.IsSkyTowerPassPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1) | 
|---|
|  |  |  | 
|---|
|  |  |  | def IsSaveAllViewCache(playerID): | 
|---|
|  |  |  | ## 是否保存所有缓存数据 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if GameWorldArena.IsArenaBattlePlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if CrossBattlefield.IsBattlefieldCallPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if CrossChampionship.IsChampionshipPlayer(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2) | 
|---|
|  |  |  | #校验玩家是否上排行榜 | 
|---|
|  |  |  | billboardMgr = GameWorld.GetBillboard() | 
|---|
|  |  |  | 
|---|
|  |  |  | if curBillboard.FindByID(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #跨服榜单上的默认保留 | 
|---|
|  |  |  | if GameWorld.IsCrossServer(): | 
|---|
|  |  |  | billboardMgr = PyDataManager.GetCrossBillboardManager() | 
|---|
|  |  |  | for billboardType in ShareDefine.CrossBillboardTypeList: | 
|---|
|  |  |  | groupList = billboardMgr.GetBillboardGroupList(billboardType) | 
|---|
|  |  |  | for billboardType, groupValue1, groupValue2 in groupList: | 
|---|
|  |  |  | billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2) | 
|---|
|  |  |  | if billboardObj.FindByID(playerID): | 
|---|
|  |  |  | return True | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return False | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def DelOutofTimeViewCacheData(): | 
|---|
|  |  |  | ## 删除过期的查看缓存数据 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | curTime = int(time.time()) | 
|---|
|  |  |  | MaxTime = 30 * 3600 * 24 # 30天 | 
|---|
|  |  |  | MaxTime = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 3) * 3600 * 24 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager() | 
|---|
|  |  |  | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict | 
|---|
|  |  |  | 
|---|
|  |  |  | ## 删除玩家缓存 | 
|---|
|  |  |  | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager() | 
|---|
|  |  |  | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict | 
|---|
|  |  |  | playerViewCachePyDict.pop(playerID) | 
|---|
|  |  |  | playerViewCachePyDict.pop(playerID, None) | 
|---|
|  |  |  | GameWorld.DebugLog("删除查看缓存!", playerID) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def FindViewCache(playerID, isAddNew=False): | 
|---|
|  |  |  | def FindViewCache(playerID, isAddNew=False, newPropData={}): | 
|---|
|  |  |  | ## 查找玩家缓存 | 
|---|
|  |  |  | # @param newPropData: 新数据初始PropData {}, key: LV,RealmLV,Job,VIPLV,Name,FamilyID,FamilyName,FightPower | 
|---|
|  |  |  | curCache = None | 
|---|
|  |  |  | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager() | 
|---|
|  |  |  | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict | 
|---|
|  |  |  | 
|---|
|  |  |  | elif isAddNew: | 
|---|
|  |  |  | curCache = PyGameDataStruct.tagPlayerViewCachePy() | 
|---|
|  |  |  | curCache.PlayerID = playerID | 
|---|
|  |  |  | if newPropData: | 
|---|
|  |  |  | curCache.PropData = json.dumps(newPropData, ensure_ascii=False).replace(" ", "") | 
|---|
|  |  |  | curCache.PropDataSize = len(curCache.PropData) | 
|---|
|  |  |  | playerViewCachePyDict[playerID] = curCache | 
|---|
|  |  |  | return curCache | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetCachePropDataDict(curCache): | 
|---|
|  |  |  | ## 获取缓存基础属性字典信息 | 
|---|
|  |  |  | if not curCache: | 
|---|
|  |  |  | return {} | 
|---|
|  |  |  | if not hasattr(curCache, "PropDataDict"): | 
|---|
|  |  |  | curCache.PropDataDict = {} | 
|---|
|  |  |  | if not curCache.PropDataDict: | 
|---|
|  |  |  | if not curCache.PropDataDict and curCache.PropData: | 
|---|
|  |  |  | curCache.PropDataDict = eval(curCache.PropData) | 
|---|
|  |  |  | return curCache.PropDataDict | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | #    WORD        ItemDataSize1; | 
|---|
|  |  |  | #    char        ItemData1[ItemDataSize1];    //1阶装备数据 | 
|---|
|  |  |  | #    ...         ... | 
|---|
|  |  |  | #    WORD        ItemDataSize15; | 
|---|
|  |  |  | #    char        ItemData15[ItemDataSize15]; | 
|---|
|  |  |  | #    WORD        ItemDataSize20; | 
|---|
|  |  |  | #    char        ItemData20[ItemDataSize20]; | 
|---|
|  |  |  | #}; | 
|---|
|  |  |  | def OnMGUpdatePlayerCache(routeIndex, mapID, curPackData, tick): | 
|---|
|  |  |  | playerID = curPackData.PlayerID | 
|---|
|  |  |  | 
|---|
|  |  |  | #GameWorld.DebugLog("    更新Plus数据: size=%s, %s" % (curCache.PlusDataSize, curCache.PlusData), playerID) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 装备数据存储,不保存装备数据的话则清空 | 
|---|
|  |  |  | for classLV in xrange(1, 15 + 1): | 
|---|
|  |  |  | for classLV in xrange(1, 20 + 1): | 
|---|
|  |  |  | if not isSaveAll: | 
|---|
|  |  |  | itemDataSize = 0 | 
|---|
|  |  |  | itemData = "" | 
|---|
|  |  |  | 
|---|
|  |  |  | answerPack.LV = cacheDict["LV"] | 
|---|
|  |  |  | answerPack.RealmLV = cacheDict["RealmLV"] | 
|---|
|  |  |  | answerPack.OnlineType = ChConfig.Def_Offline | 
|---|
|  |  |  | answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if GameWorld.IsCrossServer(): | 
|---|
|  |  |  | answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0) | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | answerPack.ServerGroupID = GameWorld.GetServerGroupID() | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | answerPack.PlayerID = clientPack.PlayerID | 
|---|
|  |  |  | answerPack.PlayerName = tagPlayer.GetName() | 
|---|