6328 【后端】优化代码eval -还原部分cPickle 无法应用与数据库存储,保留部分传输解析
12个文件已修改
113 ■■■■■ 已修改文件
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -35,7 +35,6 @@
import operator
import random
import time
import cPickle
class CrossPKPlayer():
    ## 跨服PK玩家类
@@ -1923,7 +1922,7 @@
            overInfoData.OverType = overType
            overInfoData.PlayerID = playerID
            overInfoData.WinnerID = winnerID
            overInfoData.RoundWinnerInfo = cPickle.dumps(roundWinnerIDList, 2)
            overInfoData.RoundWinnerInfo = str(roundWinnerIDList)
            overInfoData.RoundWinnerLen = len(overInfoData.RoundWinnerInfo)
            overInfoData.PKScore = pkScore
            overInfoData.DanLV = danLV
@@ -1958,7 +1957,7 @@
    winnerID = overInfoData.WinnerID
    roundWinnerIDList = []
    try:
        roundWinnerIDList = cPickle.loads(overInfoData.RoundWinnerInfo)
        roundWinnerIDList = eval(overInfoData.RoundWinnerInfo)
    except:
        GameWorld.ErrLog("__OnLoginNotifyPKOverInfo roundWinnerIDList eval error! RoundWinnerInfo=%s" % overInfoData.RoundWinnerInfo, playerID)
    pkScore = overInfoData.PKScore
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
@@ -43,7 +43,6 @@
from types import IntType
import time
import cPickle
#---------------------------------------------------------------------
#年月日时间格式
@@ -1122,20 +1121,20 @@
        recMapID = universalRecData.GetValue1()
        if recMapID == mapID:
            findRecData = universalRecData
        fbOpenRecord[recMapID] = cPickle.loads(universalRecData.GetStrValue1())
        fbOpenRecord[recMapID] = eval(universalRecData.GetStrValue1())
        
    if not findRecData:
        findRecData = recTypeListData.AddRec()
        findRecData.SetValue1(mapID)
        findRecData.SetStrValue1(cPickle.dumps([curDayStr], 2))
        findRecData.SetStrValue1(str([curDayStr]))
        fbOpenRecord[mapID] = [curDayStr]
    else:
        recordList = cPickle.loads(findRecData.GetStrValue1())
        recordList = eval(findRecData.GetStrValue1())
        if curDayStr not in recordList:
            recordList.append(curDayStr)
            if len(recordList) > 3: #只存最近3次
                del recordList[0]
            findRecData.SetStrValue1(cPickle.dumps(recordList, 2))
            findRecData.SetStrValue1(str(recordList))
            fbOpenRecord[mapID] = recordList
        else:
            return
@@ -1151,7 +1150,7 @@
    for index in range(recTypeListData.Count()):
        universalRecData = recTypeListData.At(index)
        recMapID = universalRecData.GetValue1()
        recordList = cPickle.loads(universalRecData.GetStrValue1())
        recordList = eval(universalRecData.GetStrValue1())
        fbOpenRecord[recMapID] = recordList
    return fbOpenRecord
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
@@ -50,7 +50,6 @@
import CrossBoss
import time
import cPickle
'''
ShareDefine.Def_UniversalGameRecType_BossInfo
@@ -718,10 +717,9 @@
    # RecordData改json记录 bossid存为字符串
    def UpdateBossAttention(self, playerid, bossid, isAdd):
        bossid = str(bossid)
        if playerid in self.bossAttentionDict:
            bossAttentionData = self.bossAttentionDict[playerid]
            recordDict = cPickle.loads(bossAttentionData.RecordData)
            recordDict = eval(bossAttentionData.RecordData)
            if isAdd:
                recordDict[bossid] = isAdd
            else:
@@ -732,7 +730,7 @@
                self.bossAttentionDict.pop(playerid)
                
            else:
                bossAttentionData.RecordData = cPickle.dumps(recordDict, 2)
                bossAttentionData.RecordData = str(recordDict)
                bossAttentionData.DataLen = len(bossAttentionData.RecordData)
        else:
            if not isAdd:
@@ -740,7 +738,7 @@
            bossAttention = PyGameDataStruct.tagDBPyBossAttention()
            bossAttention.clear()
            bossAttention.PlayerID = playerid
            bossAttention.RecordData = cPickle.dumps({bossid:isAdd}, 2)
            bossAttention.RecordData = str({bossid:isAdd})
            bossAttention.DataLen = len(bossAttention.RecordData)
            self.bossAttentionDict[playerid] = bossAttention
        
@@ -754,7 +752,7 @@
        attentionData = self.bossAttentionDict.get(curPlayer.GetPlayerID())
        if not attentionData:
            return
        bttentionDict = cPickle.loads(attentionData.RecordData)
        bttentionDict = eval(attentionData.RecordData)
        packData = ChPyNetSendPack.tagGCBossAttentionInfo()
        packData.BossList = []
        for bossid, addState in bttentionDict.items():
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py
@@ -32,7 +32,6 @@
import random
import copy
import cPickle
'''
1. 仙盟改名
@@ -80,8 +79,8 @@
def SetBatRecFamilyNameA(recData, familyNameA): return recData.SetStrValue1(familyNameA)
def GetBatRecFamilyNameB(recData): return recData.GetStrValue2()
def SetBatRecFamilyNameB(recData, familyNameB): return recData.SetStrValue2(familyNameB)
def GetBatRecDissolutionID(recData): return [] if not recData.GetStrValue3() else cPickle.loads(recData.GetStrValue3()) # 解散的家族ID列表 [familyID, ...]
def SetBatRecDissolutionID(recData, dissFamilyIDList): return recData.SetStrValue3(cPickle.dumps(dissFamilyIDList, 2))
def GetBatRecDissolutionID(recData): return [] if not recData.GetStrValue3() else eval(recData.GetStrValue3()) # 解散的家族ID列表 [familyID, ...]
def SetBatRecDissolutionID(recData, dissFamilyIDList): return recData.SetStrValue3(str(dissFamilyIDList))
''' 王者仙盟
value1        家族ID
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -28,8 +28,6 @@
import NetPackCommon
import IpyGameDataPY
import PyGameData
import cPickle
import json
# 获取玩家跨服服务器上的名字
#===============================================================================
# def GetCrossPlayerName(curPlayer):
@@ -286,11 +284,11 @@
        GameWorld.DebugLog("查看跨服玩家,是本服玩家,直接回复!tagPlayerID=%s" % (tagPlayerID), playerID)
        sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
        sendPack.PlayerID = tagPlayerID
        sendPack.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
        sendPack.PropData = curCache.GetPropData()
        sendPack.PropDataSize = len(sendPack.PropData)
        sendPack.ItemData = json.dumps(cPickle.loads(PlayerViewCache.GetItemData(curCache)), ensure_ascii=False)
        sendPack.ItemData = PlayerViewCache.GetItemData(curCache)
        sendPack.ItemDataSize = len(sendPack.ItemData)
        sendPack.PlusData = json.dumps(cPickle.loads(PlayerViewCache.GetPlusData(curCache)), ensure_ascii=False)
        sendPack.PlusData = PlayerViewCache.GetPlusData(curCache)
        sendPack.PlusDataSize = len(sendPack.PlusData)
        NetPackCommon.SendFakePack(curPlayer, sendPack)
        return
@@ -347,11 +345,11 @@
    PropData, ItemData, PlusData = cacheInfo
    sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
    sendPack.PlayerID = tagPlayerID
    sendPack.PropData = json.dumps(cPickle.loads(PropData), ensure_ascii=False)
    sendPack.PropData = PropData
    sendPack.PropDataSize = len(sendPack.PropData)
    sendPack.ItemData = json.dumps(cPickle.loads(ItemData), ensure_ascii=False)
    sendPack.ItemData = ItemData
    sendPack.ItemDataSize = len(sendPack.ItemData)
    sendPack.PlusData = json.dumps(cPickle.loads(PlusData), ensure_ascii=False)
    sendPack.PlusData = PlusData
    sendPack.PlusDataSize = len(sendPack.PlusData)
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py
@@ -28,7 +28,6 @@
import copy
import PlayerViewCache
import PlayerTeam
import cPickle
#---------------------------------------------------------------------
@@ -82,7 +81,7 @@
            #玩家的数据没有缓存过
            PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
            return
        cacheDict = cPickle.loads(curCache.GetPropData())
        cacheDict = eval(curCache.GetPropData())
        tagLV = cacheDict["LV"]
    else:
        tagLV = tagPlayer.GetLV()
@@ -324,7 +323,7 @@
        PlayerControl.NotifyCode(srcPlayer, 'Friend_MakeFriend', [curPlayer.GetName()])
        #srcPlayer.MapServer_QueryPlayerResult(0, 0, 'AddFriendSucceed', "", 0)
    else:
        cacheDict = cPickle.loads(curCache.GetPropData())
        cacheDict = eval(curCache.GetPropData())
        PlayerControl.NotifyCode(curPlayer, 'Friend_MakeFriend', [cacheDict['Name']])  
        # 记录等对方上线通知地图,任务等会用到触发逻辑,通用记录次数即可, MapServer_SyncFriendInfo为具体的好友数量,根据策划需求制作
        pass
@@ -396,7 +395,7 @@
        curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagID)
        if not curCache:
            return
        cacheDict = cPickle.loads(curCache.GetPropData())
        cacheDict = eval(curCache.GetPropData())
        playerName = cacheDict['Name']
    else:
        playerName = tagPlayer.GetName()
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py
@@ -25,7 +25,6 @@
import PyDataManager
import time
import json
import cPickle
# VIP权限
Def_Onoff_VIPCount = 5
(
@@ -283,14 +282,14 @@
        if curPlayer and not PlayerControl.GetIsTJG(curPlayer):
            continue
        recordDict = cPickle.loads(bossAttentionData.RecordData)
        recordDict = eval(bossAttentionData.RecordData)
        if recordDict.get(bossID, 0) in [0, 9]:
            #0-默认未关注, 1-主动关注, 2-自动关注, 9-主动取消关注
            continue
        curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
        if not curCache:
            continue
        cacheDict = cPickle.loads(curCache.GetPropData())
        cacheDict = eval(curCache.GetPropData())
        if not CheckCanGeTui(cacheDict, geTuiType):
            # 过滤个推
            continue
@@ -328,7 +327,7 @@
    if not curCache:
        return
    cacheDict = cPickle.loads(curCache.GetPropData())
    cacheDict = eval(curCache.GetPropData())
    if not CheckCanGeTui(cacheDict, Def_Onoff_Chat):
        # 过滤个推
        return
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py
@@ -26,7 +26,6 @@
import IpyGameDataPY
import PlayerViewCache
import PyGameData
import cPickle
#--------------------社交圈基本结构-------------------
# 社交圈
class SocialPlayers(object):
@@ -723,7 +722,7 @@
            playerSocial.RealmLV = 1
            playerSocial.OnlineType = ChConfig.Def_Offline
        else:
            cacheDict = cPickle.loads(curCache.GetPropData())
            cacheDict = eval(curCache.GetPropData())
    
            playerSocial.clear()
            playerSocial.PlayerID = playerID
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py
@@ -28,7 +28,6 @@
import CrossRealmMsg
import ChNetSendPack
import NetPackCommon
import cPickle
import PlayerGeTui
import re
@@ -101,7 +100,7 @@
        return
    
    if curCache:
        cacheDict = cPickle.loads(curCache.GetPropData())
        cacheDict = eval(curCache.GetPropData())
        tagPlayerName = cacheDict["Name"]
        
    talkType = sendPack.GetTalkType()
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -32,7 +32,6 @@
import ChConfig
import time
import cPickle
import json
ViewCacheMgr = GameWorld.GameWorldData.GetPlayerViewCacheMgr()
@@ -86,7 +85,7 @@
    
    # 同步更新助战信息
    if PlayerFBHelpBattle.IsInHelpBattleCheckInList(PlayerID):
        PropDataDict = cPickle.loads(PropData)
        PropDataDict = eval(PropData)
        fightPower = PropDataDict.get("FightPower", 0)
        familyID = PropDataDict.get("FamilyID", 0)
        playerName = PropDataDict.get("Name", "")
@@ -215,11 +214,11 @@
        sendPack.PlusDataSize = len(sendPack.PlusData)
    else:
        #成功回包 缓存数据
        sendPack.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
        sendPack.PropData = curCache.GetPropData()
        sendPack.PropDataSize = len(sendPack.PropData)
        sendPack.ItemData = json.dumps(cPickle.loads(GetItemData(curCache)), ensure_ascii=False)
        sendPack.ItemData = GetItemData(curCache)
        sendPack.ItemDataSize = len(sendPack.ItemData)
        sendPack.PlusData = json.dumps(cPickle.loads(GetPlusData(curCache)), ensure_ascii=False)
        sendPack.PlusData = GetPlusData(curCache)
        sendPack.PlusDataSize = len(sendPack.PlusData)
        
    NetPackCommon.SendFakePack(curPlayer, sendPack)
@@ -237,7 +236,7 @@
        return
    
    playerEquipList = []
    equipItemList = cPickle.loads(itemData)
    equipItemList = eval(itemData)
    for equipItemDict in equipItemList:
        equipIndex = equipItemDict["ItemIndex"]
        if equipIndex not in ShareDefine.RoleEquipType:
@@ -277,7 +276,7 @@
            answerPack.OnlineType = ChConfig.Def_Offline
            answerPack.ServerGroupID = 0
        else:
            cacheDict = cPickle.loads(curCache.GetPropData())
            cacheDict = eval(curCache.GetPropData())
    
            answerPack.PlayerID = clientPack.PlayerID
            answerPack.PlayerName = cacheDict["Name"]
@@ -306,12 +305,12 @@
    curCache = ViewCacheMgr.FindCache(playerID)
    if not curCache:
        return
    PropData = cPickle.loads(curCache.GetPropData())
    PropData = eval(curCache.GetPropData())
    PropData["FamilyID"] = familyID
    PropData["FamilyName"] = familyName
    playerLV = PropData["LV"]
    
    PropData = cPickle.dumps(PropData, 2)
    PropData = json.dumps(PropData, ensure_ascii=False)
    ItemData = GetItemData(curCache)
    PlusData = GetPlusData(curCache)
    UpdatePlayerCache(playerID, PropData, ItemData, PlusData, True if playerLV > 150 else False)  
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py
@@ -34,9 +34,7 @@
import PlayerUniversalGameRec
import random
import json
import math
import cPickle
RecType = ShareDefine.Def_UniversalGameRecType_XMZZStageRecord
RecType1 = ShareDefine.Def_UniversalGameRecType_XMZZPKInfoRecord
@@ -270,9 +268,9 @@
        packData = ChPyNetSendPack.tagGCXMZZFightInfo()
        packData.Clear()
        packData.PlayerID = pkPlayerID
        packData.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
        packData.PropData = curCache.GetPropData()
        packData.PropDataSize = len(packData.PropData)
        packData.ItemData = json.dumps(cPickle.loads(PlayerViewCache.GetItemData(curCache)), ensure_ascii=False)
        packData.ItemData = PlayerViewCache.GetItemData(curCache)
        packData.ItemDataSize = len(packData.ItemData)
        NetPackCommon.SendFakePack(curPlayer, packData)
        return
@@ -674,15 +672,14 @@
                #已匹配过的跳过
                continue
            
            propDataDict = cPickle.loads(curCache.GetPropData())
            itemDataDict = cPickle.loads(itemData)
            if playerID in g_playerPowerDict:
                power = g_playerPowerDict[playerID]
            else:
                propDataDict = eval(curCache.GetPropData())
                power = propDataDict.get('FightPower', 0)
                g_playerPowerDict[playerID] = power
            
            pkDataDict[playerID] = [propDataDict, itemDataDict]
            pkDataDict[playerID] = [curCache.GetPropData(), itemData]
            #GameWorld.DebugLog('    筛选对手 playerID=%s,power=%s' % (playerID, power))
            if minPower1 < power < myPower:
                underList1.append(playerID)
@@ -716,15 +713,15 @@
    if isRobotNPC:
        #机器人, 职业随机
        openJob = IpyGameDataPY.GetFuncEvalCfg("OpenJob")
        PropData = {"Job":random.choice(openJob), "LV":curPlayer.GetLV()}
        ItemData = {} # 前端自己根据职业及NPC等级处理
        PropData = str({"Job":random.choice(openJob), "LV":curPlayer.GetLV()})
        ItemData = "" # 前端自己根据职业及NPC等级处理
    else:
        if myPlayerID in g_historyPKDict:
            g_historyPKDict[myPlayerID].append(pkPlayerID)
        else:
            g_historyPKDict[myPlayerID] = [pkPlayerID]
            
        PropData, ItemData = pkDataDict.get(pkPlayerID, [{}, {}])
        PropData, ItemData = pkDataDict.get(pkPlayerID, ["", ""])
    XMZZManager.vsPlayerIDDict[myPlayerID] = pkPlayerID
    GameWorld.DebugLog('   仙魔之争匹配对手信息 pkPlayerID=%s, PropData=%s, overInfo=%s' % (pkPlayerID, PropData, overInfo), myPlayerID)
@@ -733,16 +730,16 @@
    packData = ChPyNetSendPack.tagGCXMZZFightInfo()
    packData.Clear()
    packData.PlayerID = pkPlayerID
    packData.PropData = json.dumps(PropData, ensure_ascii=False)
    packData.PropData = PropData
    packData.PropDataSize = len(packData.PropData)
    packData.ItemData = json.dumps(ItemData, ensure_ascii=False)
    packData.ItemData = ItemData
    packData.ItemDataSize = len(packData.ItemData)
    NetPackCommon.SendFakePack(curPlayer, packData)
    
    #通知地图
    pkPlayerPropData = {}
    if PropData:
        pkPlayerPropData = PropData
        pkPlayerPropData = eval(PropData)
    else:
        GameWorld.ErrLog("仙魔之争没有匹配到对手信息!fightPower=%s" % curPlayer.GetFightPower(), myPlayerID)
    vsPlayerInfo = [pkPlayerID, pkPlayerPropData]
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
@@ -32,7 +32,7 @@
import BossHurtMng
import time
import cPickle
import json
Def_Process_Tick = "ProcessPlayerCache"
##玩家下线同步
@@ -169,9 +169,9 @@
    curPlayerPlusDict["Fruit"] = PlayerAttrFruit.GetAttrFruitEatCntDict(curPlayer)
    
    #-----------
    curPlayerPropData = cPickle.dumps(curPlayerPropDict, 2)
    curPlayerItemData = cPickle.dumps(curEquipItemList, 2)
    curPlayerPlusData = cPickle.dumps(__RemoveEmptyDataKey(curPlayerPlusDict), 2)
    curPlayerPropData = json.dumps(curPlayerPropDict, ensure_ascii=False)
    curPlayerItemData = json.dumps(curEquipItemList, ensure_ascii=False)
    curPlayerPlusData = json.dumps(__RemoveEmptyDataKey(curPlayerPlusDict), ensure_ascii=False)
    return (curPlayerPropData, curPlayerItemData, curPlayerPlusData)
def __RemoveEmptyDataKey(dataDict):