| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package PlayerPackData  | 
| #  | 
| # @todo:Íæ¼Ò´ò°üÊý¾Ý  | 
| # @author hxp  | 
| # @date 2024-10-17  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Íæ¼Ò´ò°üÊý¾Ý  | 
| #   | 
| # Ó¦Óó¡¾°£ºÖ÷ÒªÓÃÓÚPKÀ๦ÄÜ£¬Óë¾µÏñPK  | 
| #    1. ¼È¶¨¹¦ÄÜÀàÐÍ£º   | 
| #            ÈçÆ¥Å侺¼¼³¡µÈ£¬ÕâÖÖÒ»°ãÐèÒªÏȱ¨Ãû»òµÇ¼ÇµÈ£¬»òÕßÒѾÔÚ»ý·ÖÅÅÐаñÉ쵀  | 
| #            ËùÒÔ´ò°üÊý¾Ý±íÒ»°ã»á±£´æÍæ¼Ò´ò°üÊý¾ÝÖ±µ½»î¶¯½áËã½áÊø  | 
| #            ±¨Ãû¡¢µÇ¼Ç¡¢Í¬²½£º ÕâÖÖÒ»°ãÊÇͨ¹ýÍæ¼ÒÖ÷¶¯×ÔÖ÷·¢ÆðµÄÐÐΪ  | 
| #            ÅÅÐаñ£ºÕâÖÖÏ൱ÓÚ±»¶¯Ê½±¨Ãû£¬¼´Ê×´ÎÉϰñ´¥·¢ÀÈ¡Êý¾Ý  | 
| #    2. ÏµÍ³×Ô¶¯PK¹¦ÄÜÀࣺ  | 
| #            Èç¸ù¾Ýij¸ö×ʸñ¹æÔò£¬ÏµÍ³×Ô¶¯Éú³Én¸öÍæ¼ÒËæ»úÆ¥ÅäPKµÄ¹¦ÄÜ£¬Íæ¼ÒÁ½Á½¾µÏñϵͳ×Ô¶¯¶Ô´ò½ú¼¶¼Ó»ý·Ö¾ö³öÃû´ÎµÈ  | 
| #            ÕâÖÖΪ±»¶¯Ê½£¬¼´Ä¿±êÍæ¼Ò¿ÉÄܲ»´æÔÚ´ò°üÊý¾Ý±íÖУ¬ÐèҪȡÀÈ¡  | 
| #    3. ËæÒâPKÀàÐÍ£º  | 
| #            ÈçÇдèһϣ¬Íæ¼Ò¿ÉÒÔÔÚÈÎÒⳡ¾°¶ÔÈÎÒâ±¾·þ»ò¿ç·þÍæ¼Ò·¢ÆðÇд裬ÓëÆä¾µÏñ½øÐÐÒ»³¡ÓÑÒêPK£¬´¿ÓéÀÖ  | 
| #            ÕâÖÖΪ±»¶¯Ê½£¬¼´Ä¿±êÍæ¼Ò¿ÉÄܲ»´æÔÚ´ò°üÊý¾Ý±íÖУ¬ÐèҪȡÀÈ¡  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2024-10-17 15:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import CommFunc  | 
| import GameWorld  | 
| import PyDataManager  | 
| import PlayerViewCache  | 
| import PyGameDataStruct  | 
| import CrossRealmMsg  | 
| import PlayerControl  | 
| import ShareDefine  | 
| import PyGameData  | 
| import ChConfig  | 
|   | 
| import time  | 
|   | 
| class DBPlayerPackDataManager():  | 
|     ## Íæ¼Ò´ò°üÊý¾Ý¹ÜÀí  | 
|       | 
|     def __init__(self):  | 
|         self.Clear()  | 
|         return  | 
|       | 
|     def Clear(self):  | 
|         self.playerPackDataDict = {} # {playerID:tagDBPlayerPackData, ...}  | 
|         return  | 
|       | 
|     def GetPlayerPackObj(self, playerID, isAddNew=False):  | 
|         packDataObj = None  | 
|         if playerID in self.playerPackDataDict:  | 
|             packDataObj = self.playerPackDataDict[playerID]  | 
|         elif isAddNew:  | 
|             packDataObj = PyGameDataStruct.tagDBPlayerPackData()  | 
|             packDataObj.PlayerID = playerID  | 
|             self.playerPackDataDict[playerID] = packDataObj  | 
|         return packDataObj  | 
|       | 
|     def UpdPlayerPackData(self, playerID, packData):  | 
|         if not packData:  | 
|             return  | 
|         packObj = self.GetPlayerPackObj(playerID, True)  | 
|         packObj.UpdTime = int(time.time())  | 
|         packObj.PackData = packData  | 
|         packObj.PackDataSize = len(packObj.PackData)  | 
|         return  | 
|       | 
|     # ±£´æÊý¾Ý ´æÊý¾Ý¿âºÍrealtimebackup  | 
|     def GetSaveData(self):  | 
|         savaData = ""  | 
|         cntData = ""  | 
|         cnt = 0  | 
|           | 
|         for dbData in self.playerPackDataDict.values():  | 
|             cnt += 1  | 
|             savaData += dbData.getBuffer()  | 
|               | 
|         GameWorld.Log("Save DBPlayerPackData count :%s len=%s" % (cnt, len(savaData)))  | 
|         return CommFunc.WriteDWORD(cntData, cnt) + savaData  | 
|       | 
|     # ´ÓÊý¾Ý¿âÔØÈëÊý¾Ý  | 
|     def LoadPyGameData(self, datas, pos, dataslen):  | 
|         cnt, pos = CommFunc.ReadDWORD(datas, pos)  | 
|         GameWorld.Log("Load DBPlayerPackData count :%s" % cnt)  | 
|           | 
|         self.Clear()  | 
|           | 
|         for _ in xrange(cnt):  | 
|             dbData = PyGameDataStruct.tagDBPlayerPackData()  | 
|             pos += dbData.readData(datas, pos, dataslen)  | 
|               | 
|             self.playerPackDataDict[dbData.PlayerID] = dbData  | 
|               | 
|         return pos  | 
|   | 
| def IsSaveDB(packDataObj):  | 
|     ## ÊÇ·ñÈë¿â  | 
|     if not packDataObj:  | 
|         return False  | 
|       | 
|     # ¹¦Ä̶ܹ¨ÐèÒªµÄ  | 
|     # ...  | 
|       | 
|     maxDays = 7 # Ä¬ÈÏ7Ìì  | 
|     MaxTime = maxDays * 3600 * 24  | 
|     curTime = int(time.time())  | 
|     passTime = curTime - packDataObj.UpdTime  | 
|     if passTime < MaxTime:  | 
|         return True  | 
|       | 
|     return False  | 
|   | 
| def DelOutofTimePackData():  | 
|     ## É¾³ý¹ýÆÚ  | 
|       | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     playerPackDataDict = packDataMgr.playerPackDataDict  | 
|     for playerID, packDataObj in playerPackDataDict.items():  | 
|         if IsSaveDB(packDataObj):  | 
|             continue  | 
|         playerPackDataDict.pop(playerID)  | 
|           | 
|     return  | 
|   | 
| def IsPackDataPlayer(playerID):  | 
|     return playerID in PyDataManager.GetDBPlayerPackDataManager().playerPackDataDict  | 
|   | 
| def OnPlayerLogin(curPlayer):  | 
|     ## ±¾·þµÇ¼Âß¼  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     if playerID in packDataMgr.playerPackDataDict:  | 
|         isCross, isNeed = 0, 1  | 
|         QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", [isCross, isNeed])  | 
|     return  | 
|   | 
| def OnPlayerLogin_CrossLogic(serverGroupID, serverID, playerID):  | 
|     ## ¿ç·þµÇ¼Âß¼  | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     if playerID in packDataMgr.playerPackDataDict:  | 
|         dataMsg = {"playerID":playerID}  | 
|         CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PlayerPackDataState, dataMsg, [serverGroupID])  | 
|     return  | 
|   | 
| def SetNeedPackData(playerIDList):  | 
|     ## ÉèÖÃÐèÒª´ò°üÊý¾ÝµÄÍæ¼ÒIDÁÐ±í£¬Èç¹ûûÓÐÊý¾Ý£¬Ôò»áÖ÷¶¯È¥ÀÈ¡Êý¾Ý£¬¿ç·þ±¾·þͨÓà  | 
|       | 
|     if not playerIDList:  | 
|         return  | 
|       | 
|     pullPlayerIDList = []  | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     for playerID in playerIDList:  | 
|         if playerID in packDataMgr.playerPackDataDict:  | 
|             continue  | 
|         pullPlayerIDList.append(playerID)  | 
|           | 
|     if not pullPlayerIDList:  | 
|         return  | 
|     OnPullPlayerPackData(pullPlayerIDList)  | 
|     return  | 
|   | 
| def OnPullPlayerPackData(pullPlayerIDList, msgInfo=None):  | 
|     '''ÇëÇóÀÈ¡Íæ¼ÒÊý¾Ý£¬¸Ãº¯Êý½öÔÚ´ò°üÊý¾Ý±íÖв»´æÔÚÍæ¼ÒÊý¾Ýʱ²ÅÐèÒªµ÷Ó㬿ç·þ±¾·þͨÓà  | 
|     1. ¿ç·þÀ×Ó·þÍæ¼ÒÊý¾Ý: Ö±½ÓÍÆË͸ø×Ó·þÀ¶ÔÓ¦Íæ¼ÒÊý¾Ý£¬ÀÈ¡µ½Êý¾Ýºóͬʱ´æÈë´ò°üÊý¾Ý±íÖÐ  | 
|     2. ×Ó·þÀÆäËû×Ó·þÍæ¼ÒÊý¾Ý£ºÖ±½ÓÍÆË͸ø¿ç·þ·þÎñÆ÷ÀÈ¡  | 
|     3. ×Ó·þÀ±¾·þÍæ¼ÒÊý¾Ý  | 
|         a.Èç¹ûÊÇ¿ç·þ·þÎñÆ÷ÇëÇóµÄ£¬ÓÅÏÈÈ¡´ò°üÊý¾Ý±íÖÐÊý¾Ý£¬ÓÐÔò·µ»Ø£¬Ã»ÓÐÔò¼ÌÐøÍùÏÂ×ß  | 
|         b.Íæ¼ÒÔÚÏßʱ´ÓµØÍ¼ÀÈ¡£¬ÀÈ¡µ½Êý¾Ýºóͬʱ´æÈë´ò°üÊý¾Ý±íÖÐ  | 
|         c.Íæ¼ÒÀëÏßʱ´ÓdbÀÈ¡£¬ÀÈ¡µ½Êý¾Ýºóͬʱ´æÈë´ò°üÊý¾Ý±íÖÐ  | 
|     @param msgInfo: ¹¦ÄÜÀÈ¡Íæ¼ÒÊý¾Ýʱ×Ô¶¨ÒåµÄ¹¦ÄÜÐÅÏ¢£¬Í¸´«²ÎÊý  | 
|     '''  | 
|     if msgInfo == None:  | 
|         msgInfo = {}  | 
|           | 
|     GameWorld.DebugLog("ÀÈ¡Íæ¼Ò´ò°üÊý¾Ý: %s, %s" % (pullPlayerIDList, msgInfo))  | 
|       | 
|     # pullFrom 0-¿ç·þÀ×Ó·þ£» >0-×Ó·þͨ¹ý¿ç·þÀ×Ó·þ  | 
|     if GameWorld.IsCrossServer():  | 
|         # ¹ã²¥¸ø×Ó·þÀÊý¾Ý  | 
|         msgInfo["pullFrom"] = 0  | 
|         dataMsg = {"pullPlayerIDList":pullPlayerIDList, "msgInfo":msgInfo}  | 
|         CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PullPlayerPackData, dataMsg)  | 
|     else:  | 
|         msgInfo["pullFrom"] = GameWorld.GetServerGroupID()  | 
|         otherServerPlayerIDList = [] # ÆäËû·þÍæ¼ÒID  | 
|         for playerID in pullPlayerIDList:  | 
|             if PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|                 DoPullPlayerPackData(playerID, msgInfo) # À±¾·þ  | 
|             else:  | 
|                 otherServerPlayerIDList.append(playerID)  | 
|                   | 
|         # ÀÆäËû·þÍæ¼Ò£¬Í¨¹ý¿ç·þÀ  | 
|         if otherServerPlayerIDList:  | 
|             dataMsg = {"pullPlayerIDList":otherServerPlayerIDList, "msgInfo":msgInfo}  | 
|             CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PullOtherPlayerPackData, dataMsg)  | 
|               | 
|     return  | 
|   | 
| def DoPullPlayerPackData(playerID, msgInfo):  | 
|     ## ×Ó·þÖ´ÐÐÀÈ¡±¾·þij¸öÍæ¼ÒÊý¾Ý£¬Ö»´¦ÀíÊôÓÚ±¾·þµÄÍæ¼Ò  | 
|     # @param pullFrom: 0-¿ç·þÀ£» >0-×Ó·þÀ  | 
|     if not PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|         # ·Ç±¾·þÍæ¼Ò  | 
|         return  | 
|     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|     if not curPlayer:  | 
|         GameWorld.DebugLog("Íæ¼Ò²»ÔÚÏߵĵ÷Óôò°üdbÊý¾Ý! playerID=%s" % (playerID), playerID)  | 
|         data = str(msgInfo)  | 
|         GameWorld.GetGameWorld().SendDBLogic(ChConfig.gstDBLogic_PlayerPackData, playerID, data, len(data))  | 
|         return  | 
|     GameWorld.DebugLog("Íæ¼ÒÔÚÏߵķ¢¸øµØÍ¼´ò°üÊý¾Ý! playerID=%s" % (playerID), playerID)  | 
|     # ÔÚÏßµÄת·¢¸øµØÍ¼  | 
|     QueryPlayerResult_PlayerMirror(curPlayer, "PullPlayerPackData", msgInfo)  | 
|     return  | 
|   | 
| def ReuestPlayerPackDataRet(msgInfo, packMirrorID=0, packData=""):  | 
|     '''ÇëÇóÍæ¼Ò´ò°üÊý¾Ý»ã×Ü£¬ÈçͬʱÇëÇó¶à¸öµÄ»°»áÖðÒ»½øÐлã×ÜÕûºÏ£¬Ö±µ½ËùÓÐÇëÇóµÄÍæ¼ÒÊý¾Ý¾ùÓкóÔÙͳһִÐÐÖ®ºóµÄÂß¼  | 
|     '''  | 
|     requestID = msgInfo.get("requestID") # ¿ÉÒÔÊÇÍæ¼ÒID£¬»òÕßÊÇϵͳ×Ô¶¨ÒåµÄÇëÇóID  | 
|     if requestID not in PyGameData.g_requestPlayerPackDataInfo:  | 
|         GameWorld.DebugLog("²»´æÔÚ¸Ã[Íæ¼Ò´ò°üÊý¾Ý]ÇëÇó! requestID=%s,packMirrorID=%s,%s" % (requestID, packMirrorID, msgInfo))  | 
|         return  | 
|     recInfo = PyGameData.g_requestPlayerPackDataInfo[requestID] # ¼Ç¼µÄ»ã×ÜÐÅÏ¢  | 
|       | 
|     recMsgInfo = recInfo.get("msgInfo", {})      | 
|     packDataDict = recInfo.get("packDataDict", {})  | 
|     if msgInfo.get("requestTime") != recMsgInfo.get("requestTime"):  | 
|         # ÒòΪÇëÇóµÄÊý¾ÝÓÐÒ»¶¨µÄÑÓ³Ù£¬ÊÕµ½»Øµ÷»ã×ܺó¿ÉÄÜÒѾ²»ÊÇ֮ǰÇëÇóµÄÁË£¬ÑéÖ¤²»Í¨¹ýÔò²»´¦Àí  | 
|         # ÔÝÒÔÇëÇóʱ¼ä´Á×÷ΪÑéÖ¤ÒÀ¾Ý¼´¿É£¬Í¬Ò»ÃëÄÚ²»¿ÉÖØ¸´·¢ÆðÇëÇó£¬ËùÒÔµ¥ÃëÄÚÒ»¶¨ÊÇΨһµÄ  | 
|         return  | 
|       | 
|     mirrorIDList = msgInfo["mirrorIDList"]  | 
|     if packMirrorID:  | 
|         if packMirrorID not in mirrorIDList:  | 
|             # ²»ÔÚÐèÒªµÄÇëÇóIDÀï²»´¦Àí£¬Ò»°ã²»¿ÉÄÜ£¬½ö×÷Ϊ·À·¶ÑéÖ¤  | 
|             return  | 
|         if packMirrorID not in packDataDict:  | 
|             packDataDict[packMirrorID] = packData  | 
|               | 
|     for mirrorID in mirrorIDList:  | 
|         if mirrorID not in packDataDict:  | 
|             GameWorld.DebugLog("»¹ÓÐÄ¿±êÍæ¼ÒûÓÐÊý¾Ý£¬ÉԵȺó´¦Àí! requestID=%s,mirrorID=%s,mirrorIDList=%s,packIDList=%s"   | 
|                                % (requestID, mirrorID, mirrorIDList, packDataDict.keys()))  | 
|             return  | 
|           | 
|     GameWorld.DebugLog("»ã×ÜÍæ¼Ò´ò°üÊý¾ÝÍê±Ï: requestID=%s,packMirrorID=%s, %s" % (requestID, packMirrorID, msgInfo))  | 
|     PyGameData.g_requestPlayerPackDataInfo.pop(requestID, None) # »ã×ÜÍê±Ï£¬Çå³ý»ã×ÜÐÅÏ¢  | 
|       | 
|     msgType = msgInfo.get("msgType")  | 
|     # ¾µÏñÕ½¶·  | 
|     if msgType == "MirrorBattle":  | 
|         playerID = msgInfo.get("playerID", 0)  | 
|         # Íæ¼Ò·¢ÆðµÄ  | 
|         if playerID:  | 
|             playerID = msgInfo["playerID"]  | 
|             curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|             if not curPlayer:  | 
|                 return  | 
|             tagMapID = GameWorld.GetQueryPlayerMapID(curPlayer)  | 
|             routeIndex = curPlayer.GetRouteServerIndex()  | 
|         else:  | 
|             tagMapID = msgInfo.get("requestMapID", 0)  | 
|             routeIndex = -1  | 
|               | 
|         sendMsg = str([msgInfo, packDataDict])  | 
|         GameWorld.DebugLog("MapServer_QueryPlayer tagMapID=%s,len=%s" % (tagMapID, len(sendMsg)), playerID)  | 
|         GameWorld.GetPlayerManager().MapServer_QueryPlayer(0, 0, playerID, tagMapID, "PlayerMirror", sendMsg, len(sendMsg), routeIndex)  | 
|           | 
|     # ÆäËû¹¦ÄÜ¿ÉÔÙÀ©Õ¹  | 
|     else:  | 
|         pass  | 
|       | 
|     return  | 
|   | 
| def ClientServerMsg_PlayerPackData(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þͬ²½µÄÍæ¼Ò´ò°üÊý¾Ý  | 
|     playerID = msgData["playerID"]  | 
|     packData = msgData["packData"]  | 
|     cacheBase = msgData.get("cacheBase", {})  | 
|     if cacheBase:  | 
|         PlayerViewCache.UpdCrossCacheBase(playerID, cacheBase)  | 
|     PyDataManager.GetDBPlayerPackDataManager().UpdPlayerPackData(playerID, packData)  | 
|       | 
|     msgInfo = msgData.get("msgInfo", {})  | 
|     if not msgInfo:  | 
|         return  | 
|       | 
|     pullFrom = msgInfo.get("pullFrom")  | 
|     # ¿ç·þ×ÔÉíÐèÒªµÄ  | 
|     if pullFrom == 0:  | 
|         ReuestPlayerPackDataRet(msgInfo, playerID, packData)  | 
|           | 
|     # ÆäËû×Ó·þ·¢ÆðµÄ£¬ÍƸøÄ¿±ê×Ó·þ  | 
|     elif pullFrom > 0:  | 
|         tagServerGroupID = pullFrom  | 
|         dataMsg = {"playerID":playerID, "packData":packData, "msgInfo":msgInfo}  | 
|         CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PushPlayerPackData, dataMsg, [tagServerGroupID])  | 
|           | 
|     return  | 
|   | 
| def ClientServerMsg_PullOtherPlayerPackData(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÇëÇóÀÈ¡Íæ¼Ò´ò°üÊý¾Ý  | 
|       | 
|     msgInfo = msgData["msgInfo"]  | 
|     pullPlayerIDList = msgData["pullPlayerIDList"]  | 
|       | 
|     otherServerPlayerIDList = []  | 
|     packDataDict = {}  | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     for playerID in pullPlayerIDList:  | 
|         packObj = packDataMgr.GetPlayerPackObj(playerID)  | 
|         # ÒѾÓеÄÊý¾ÝÏÈÍÆËÍ»ØÈ¥  | 
|         if packObj:  | 
|             GameWorld.DebugLog("¿ç·þÓлº´æÍæ¼Ò´ò°üÊý¾Ý£¬Ö±½ÓÍÆ¸ø×Ó·þ! playerID=%s" % playerID)  | 
|             packDataDict[playerID] = packObj.PackData  | 
|             dataMsg = {"playerID":playerID, "packData":packObj.PackData, "msgInfo":msgInfo}  | 
|             CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PushPlayerPackData, dataMsg, [serverGroupID])  | 
|         else:  | 
|             otherServerPlayerIDList.append(playerID)  | 
|               | 
|     # »¹Ã»ÓÐÊý¾ÝµÄ£¬¹ã²¥¸øÆäËû×Ó·þÀÊý¾Ý  | 
|     if otherServerPlayerIDList:  | 
|         dataMsg = {"pullPlayerIDList":otherServerPlayerIDList, "msgInfo":msgInfo}  | 
|         CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PullPlayerPackData, dataMsg)  | 
|           | 
|     return  | 
|   | 
| ##-------------------------------------------------------------------------------------------------  | 
|   | 
| def CrossServerMsg_PlayerPackDataState(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷Íæ¼Ò´ò°üÊý¾Ý״̬ͬ²½  | 
|     playerID = msgData["playerID"]  | 
|     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|     if not curPlayer:  | 
|         return  | 
|     isCross, isNeed = 1, 1  | 
|     QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", [isCross, isNeed])  | 
|     return  | 
|   | 
| def CrossServerMsg_PullPlayerPackData(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ÀÈ¡Íæ¼Ò´ò°üÊý¾Ý  | 
|       | 
|     msgInfo = msgData["msgInfo"]  | 
|     pullPlayerIDList = msgData["pullPlayerIDList"]  | 
|       | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     for playerID in pullPlayerIDList:  | 
|         packObj = packDataMgr.GetPlayerPackObj(playerID)  | 
|         if packObj:  | 
|             GameWorld.DebugLog("±¾·þÓлº´æÍæ¼Ò´ò°üÊý¾Ý£¬Ö±½ÓÍÆ¸ø¿ç·þ! playerID=%s" % playerID)  | 
|             dataMsg = {"playerID":playerID, "packData":packObj.PackData, "msgInfo":msgInfo}  | 
|             CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerPackData, dataMsg)  | 
|         else:  | 
|             DoPullPlayerPackData(playerID, msgInfo)  | 
|               | 
|     return  | 
|   | 
| def CrossServerMsg_PushPlayerPackData(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ÍÆË͵ÄÍæ¼Ò´ò°üÊý¾Ý  | 
|     playerID = msgData["playerID"]  | 
|     packData = msgData["packData"]  | 
|     msgInfo = msgData["msgInfo"]  | 
|     ReuestPlayerPackDataRet(msgInfo, playerID, packData)  | 
|     return  | 
|   | 
| def QueryPlayerResult_PlayerMirror(curPlayer, msgType, msgData=None):  | 
|     sysMsg = str([msgType, msgData])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "PlayerMirror", sysMsg, len(sysMsg))  | 
|     return  | 
|   | 
| def OnMGUpdatePlayerPackData(curPlayer, curPackData):  | 
|     ## µØÍ¼Í¬²½¸üеÄÍæ¼Ò´ò°üÊý¾Ý  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|     playerID = curPackData.PlayerID  | 
|     packDataSyncState = curPackData.PackDataSyncState  | 
|     packData = curPackData.PackData  | 
|     if not packDataSyncState or not packData:  | 
|         return  | 
|     msgInfo = eval(curPackData.PackMsg) if curPackData.PackMsg else {} # ´ò°üÊý¾Ý¸½´øµÄÐÅÏ¢  | 
|       | 
|     # ±¾·þÐèÒª£¬ÏȸüÐÂÊý¾Ý  | 
|     if packDataSyncState % 10:  | 
|         PyDataManager.GetDBPlayerPackDataManager().UpdPlayerPackData(playerID, packData)  | 
|           | 
|     # ¿ç·þÐèÒª£¬Í¬²½¸ø¿ç·þ£¬ÓÉ¿ç·þ·þÎñÆ÷ÔÙ½øÒ»²½´¦Àí  | 
|     if packDataSyncState / 10:  | 
|         cacheBase = PlayerViewCache.GetSyncCrossCacheBase(curPlayer) if curPlayer else {}  | 
|         dataMsg = {"playerID":playerID, "packData":packData, "cacheBase":cacheBase, "msgInfo":msgInfo}  | 
|         CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerPackData, dataMsg)  | 
|           | 
|     # ±¾·þÐèÒªµÄ¹¦ÄÜ  | 
|     pullFrom = msgInfo.get("pullFrom")  | 
|     if pullFrom > 0 and pullFrom == GameWorld.GetServerGroupID():  | 
|         ReuestPlayerPackDataRet(msgInfo, playerID, packData)  | 
|           | 
|     return  | 
|   | 
| def OnDBPlayerPackData(playerID, packData, msgInfo):  | 
|     ## ÊÕµ½db´ò°üÍæ¼ÒÊý¾Ý»Øµ÷  | 
|           | 
|     GameWorld.DebugLog("ÊÕµ½db´ò°üÍæ¼ÒÊý¾Ý»Øµ÷: playerID=%s, %s" % (playerID, msgInfo))  | 
|     pullFrom = msgInfo.get("pullFrom")  | 
|     # ¿ç·þÐèÒª£¬Í¬²½¸ø¿ç·þ£¬ÓÉ¿ç·þ·þÎñÆ÷ÔÙ½øÒ»²½´¦Àí  | 
|     if pullFrom == 0 or (pullFrom > 0 and pullFrom != GameWorld.GetServerGroupID()):  | 
|         dataMsg = {"playerID":playerID, "packData":packData, "msgInfo":msgInfo}  | 
|         CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerPackData, dataMsg)  | 
|         return  | 
|       | 
|     PyDataManager.GetDBPlayerPackDataManager().UpdPlayerPackData(playerID, packData)  | 
|     # ±¾·þÐèÒª£¬»ã×ܽá¹û  | 
|     ReuestPlayerPackDataRet(msgInfo, playerID, packData)  | 
|     return  | 
|   | 
| def OnMGReuestPlayerPackData(msgInfo):  | 
|     ## µØÍ¼ÇëÇóÐèÒªÍæ¼Ò´ò°üÊý¾ÝÐÅÏ¢  | 
|     #"msgType":"MirrorBattle", "msgData":msgData, "mirrorIDList":mirrorIDList, "requestTime":requestTime, "requestID":playerID, "playerID":playerID  | 
|       | 
|     packDataDict = {}  | 
|       | 
|     pullPlayerIDList = []  | 
|     packDataMgr = PyDataManager.GetDBPlayerPackDataManager()  | 
|     requestID = msgInfo["requestID"]  | 
|     mirrorIDList = msgInfo["mirrorIDList"]  | 
|     for mirrorID in mirrorIDList:  | 
|         packObj = packDataMgr.GetPlayerPackObj(mirrorID)  | 
|         if packObj:  | 
|             packDataDict[mirrorID] = packObj.PackData  | 
|             continue  | 
|         pullPlayerIDList.append(mirrorID)  | 
|           | 
|     # Ã¿´ÎÇëÇóÖ±½Ó¸²¸Ç£¬ÓɵØÍ¼¿ØÖÆÇëÇóÏÞÖÆ  | 
|     PyGameData.g_requestPlayerPackDataInfo[requestID] = {"msgInfo":msgInfo, "packDataDict":packDataDict}  | 
|       | 
|     # »¹ÓÐÍæ¼ÒûÓлº´æ´ò°üÊý¾Ý£¬ÐèÒªÏÈÍêÈ«ÀÈ¡ºóÔÙͬ²½¸øµØÍ¼  | 
|     if pullPlayerIDList:  | 
|         OnPullPlayerPackData(pullPlayerIDList, msgInfo)  | 
|         return  | 
|       | 
|     ReuestPlayerPackDataRet(msgInfo)  | 
|     return  | 
|   |