From e1dbd84e697445ea0c5f73075f56f97e5849ae53 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 08 三月 2019 14:58:15 +0800
Subject: [PATCH] 6328 【后端】优化代码eval - json只适合字符串序列化,并且尽量用于非中文;建议使用cPickle 的dumps 和loads,协议用2,可支持所有类型,缺点为序列化后不可阅读
---
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py | 12 ++--
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py | 6 +-
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py | 11 +--
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py | 4
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py | 15 ++--
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerDBOper.py | 4
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py | 8 +-
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py | 14 ++--
ServerPython/db/PyMongoDataServer/GMToolLogicProcess/ProjSpecialProcess.py | 2
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py | 6 +-
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py | 9 +-
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py | 21 +++---
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py | 6 +-
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py | 23 ++++---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py | 4
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyAction.py | 4
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py | 8 +-
17 files changed, 81 insertions(+), 76 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
index c198f41..456a8e5 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
@@ -29,7 +29,7 @@
import GMShell
import traceback
-import json
+import cPickle
def SendMsgToCrossServer(msgType, dataMsg):
## 发送信息到跨服服务器上
@@ -37,7 +37,9 @@
return
if not dataMsg:
return
- sendMsg = json.dumps({"MsgType":msgType, "Data":dataMsg, "ServerGroupID":GameWorld.GetServerGroupID()}, ensure_ascii=False)
+
+ # 协议要用最高级2,可减少长度
+ sendMsg = cPickle.dumps({"MsgType":msgType, "Data":dataMsg, "ServerGroupID":GameWorld.GetServerGroupID()}, 2)
if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK):
GameWorld.ErrLog("服务器未启动好,不允许向跨服服务器发送数据! %s" % (sendMsg))
return
@@ -52,7 +54,7 @@
if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK):
GameWorld.Log("服务器未启动好,不处理子服信息!")
return
- msgDict = json.loads(recvMsg)
+ msgDict = cPickle.loads(recvMsg)
msgType = msgDict.get("MsgType", -1)
msgData = msgDict.get("Data", "")
@@ -157,7 +159,7 @@
return
if not dataMsg:
return
- sendMsg = json.dumps({"MsgType":msgType, "Data":dataMsg}, ensure_ascii=False)
+ sendMsg = cPickle.dumps({"MsgType":msgType, "Data":dataMsg}, 2)
if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK):
GameWorld.ErrLog("跨服服务器未启动好,不允许向子服发送数据! serverGroupIDList=%s, sendMsg=%s" % (serverGroupIDList, sendMsg))
return
@@ -168,7 +170,7 @@
serverGroupIDList = list(set(serverGroupIDList)) # 去重
#for serverGroupID in serverGroupIDList:
# GameWorld.GetGameWorld().SendMergeMsgToClientByGroupID(serverGroupID, sendMsg)
- jsonGroupIDInfo = json.dumps(serverGroupIDList, ensure_ascii=False)
+ jsonGroupIDInfo = cPickle.dumps(serverGroupIDList, 2)
GameWorld.GetGameWorld().SendMergeMsgToClientByGroupList(jsonGroupIDInfo, sendMsg)
return
@@ -183,7 +185,7 @@
GameWorld.Log("服务器未启动好,不处理跨服信息!")
return
- msgDict = json.loads(dataMsg)
+ msgDict = cPickle.loads(dataMsg)
msgType = msgDict.get("MsgType", -1)
msgData = msgDict.get("Data", "")
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
index 9ae3cb6..81227c2 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -35,7 +35,7 @@
import operator
import random
import time
-import json
+import cPickle
class CrossPKPlayer():
## 跨服PK玩家类
@@ -1923,7 +1923,7 @@
overInfoData.OverType = overType
overInfoData.PlayerID = playerID
overInfoData.WinnerID = winnerID
- overInfoData.RoundWinnerInfo = json.dumps(roundWinnerIDList, ensure_ascii=False)
+ overInfoData.RoundWinnerInfo = cPickle.dumps(roundWinnerIDList, 2)
overInfoData.RoundWinnerLen = len(overInfoData.RoundWinnerInfo)
overInfoData.PKScore = pkScore
overInfoData.DanLV = danLV
@@ -1958,7 +1958,7 @@
winnerID = overInfoData.WinnerID
roundWinnerIDList = []
try:
- roundWinnerIDList = json.loads(overInfoData.RoundWinnerInfo)
+ roundWinnerIDList = cPickle.loads(overInfoData.RoundWinnerInfo)
except:
GameWorld.ErrLog("__OnLoginNotifyPKOverInfo roundWinnerIDList eval error! RoundWinnerInfo=%s" % overInfoData.RoundWinnerInfo, playerID)
pkScore = overInfoData.PKScore
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
index 7d16d92..70206b0 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
@@ -42,7 +42,7 @@
from types import IntType
import time
-import json
+import cPickle
#---------------------------------------------------------------------
#年月日时间格式
@@ -1121,20 +1121,20 @@
recMapID = universalRecData.GetValue1()
if recMapID == mapID:
findRecData = universalRecData
- fbOpenRecord[recMapID] = json.loads(universalRecData.GetStrValue1())
+ fbOpenRecord[recMapID] = cPickle.loads(universalRecData.GetStrValue1())
if not findRecData:
findRecData = recTypeListData.AddRec()
findRecData.SetValue1(mapID)
- findRecData.SetStrValue1(json.dumps([curDayStr], ensure_ascii=False))
+ findRecData.SetStrValue1(cPickle.dumps([curDayStr], 2))
fbOpenRecord[mapID] = [curDayStr]
else:
- recordList = json.loads(findRecData.GetStrValue1())
+ recordList = cPickle.loads(findRecData.GetStrValue1())
if curDayStr not in recordList:
recordList.append(curDayStr)
if len(recordList) > 3: #只存最近3次
del recordList[0]
- findRecData.SetStrValue1(json.dumps(recordList, ensure_ascii=False))
+ findRecData.SetStrValue1(cPickle.dumps(recordList, 2))
fbOpenRecord[mapID] = recordList
else:
return
@@ -1150,7 +1150,7 @@
for index in range(recTypeListData.Count()):
universalRecData = recTypeListData.At(index)
recMapID = universalRecData.GetValue1()
- recordList = json.loads(universalRecData.GetStrValue1())
+ recordList = cPickle.loads(universalRecData.GetStrValue1())
fbOpenRecord[recMapID] = recordList
return fbOpenRecord
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
index b83b6f9..f9af576 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldBoss.py
@@ -50,8 +50,7 @@
import CrossBoss
import time
-import json
-
+import cPickle
'''
ShareDefine.Def_UniversalGameRecType_BossInfo
@@ -722,7 +721,7 @@
bossid = str(bossid)
if playerid in self.bossAttentionDict:
bossAttentionData = self.bossAttentionDict[playerid]
- recordDict = json.loads(bossAttentionData.RecordData)
+ recordDict = cPickle.loads(bossAttentionData.RecordData)
if isAdd:
recordDict[bossid] = isAdd
else:
@@ -733,7 +732,7 @@
self.bossAttentionDict.pop(playerid)
else:
- bossAttentionData.RecordData = json.dumps(recordDict, ensure_ascii=False)
+ bossAttentionData.RecordData = cPickle.dumps(recordDict, 2)
bossAttentionData.DataLen = len(bossAttentionData.RecordData)
else:
if not isAdd:
@@ -741,7 +740,7 @@
bossAttention = PyGameDataStruct.tagDBPyBossAttention()
bossAttention.clear()
bossAttention.PlayerID = playerid
- bossAttention.RecordData = json.dumps({bossid:isAdd}, ensure_ascii=False)
+ bossAttention.RecordData = cPickle.dumps({bossid:isAdd}, 2)
bossAttention.DataLen = len(bossAttention.RecordData)
self.bossAttentionDict[playerid] = bossAttention
@@ -755,7 +754,7 @@
attentionData = self.bossAttentionDict.get(curPlayer.GetPlayerID())
if not attentionData:
return
- bttentionDict = json.loads(attentionData.RecordData)
+ bttentionDict = cPickle.loads(attentionData.RecordData)
packData = ChPyNetSendPack.tagGCBossAttentionInfo()
packData.BossList = []
for bossid, addState in bttentionDict.items():
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py
index 8836b9a..a86f522 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldFamilyWar.py
@@ -32,7 +32,7 @@
import random
import copy
-import json
+import cPickle
'''
1. 仙盟改名
@@ -80,8 +80,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 json.loads(recData.GetStrValue3()) # 解散的家族ID列表 [familyID, ...]
-def SetBatRecDissolutionID(recData, dissFamilyIDList): return recData.SetStrValue3(json.dumps(dissFamilyIDList, ensure_ascii=False))
+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))
''' 王者仙盟
value1 家族ID
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
index 051fa9f..11cd5dd 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -28,7 +28,8 @@
import NetPackCommon
import IpyGameDataPY
import PyGameData
-
+import cPickle
+import json
# 获取玩家跨服服务器上的名字
#===============================================================================
# def GetCrossPlayerName(curPlayer):
@@ -285,11 +286,11 @@
GameWorld.DebugLog("查看跨服玩家,是本服玩家,直接回复!tagPlayerID=%s" % (tagPlayerID), playerID)
sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
sendPack.PlayerID = tagPlayerID
- sendPack.PropData = curCache.GetPropData()
+ sendPack.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
sendPack.PropDataSize = len(sendPack.PropData)
- sendPack.ItemData = PlayerViewCache.GetItemData(curCache)
+ sendPack.ItemData = json.dumps(cPickle.loads(PlayerViewCache.GetItemData(curCache)), ensure_ascii=False)
sendPack.ItemDataSize = len(sendPack.ItemData)
- sendPack.PlusData = PlayerViewCache.GetPlusData(curCache)
+ sendPack.PlusData = json.dumps(cPickle.loads(PlayerViewCache.GetPlusData(curCache)), ensure_ascii=False)
sendPack.PlusDataSize = len(sendPack.PlusData)
NetPackCommon.SendFakePack(curPlayer, sendPack)
return
@@ -346,11 +347,11 @@
PropData, ItemData, PlusData = cacheInfo
sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
sendPack.PlayerID = tagPlayerID
- sendPack.PropData = PropData
+ sendPack.PropData = json.dumps(cPickle.loads(PropData), ensure_ascii=False)
sendPack.PropDataSize = len(sendPack.PropData)
- sendPack.ItemData = ItemData
+ sendPack.ItemData = json.dumps(cPickle.loads(ItemData), ensure_ascii=False)
sendPack.ItemDataSize = len(sendPack.ItemData)
- sendPack.PlusData = PlusData
+ sendPack.PlusData = json.dumps(cPickle.loads(PlusData), ensure_ascii=False)
sendPack.PlusDataSize = len(sendPack.PlusData)
NetPackCommon.SendFakePack(curPlayer, sendPack)
return
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerDBOper.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerDBOper.py
index dd1e215..92a73b4 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerDBOper.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerDBOper.py
@@ -27,7 +27,7 @@
import IPY_GameServer
import ReadChConfig
import base64
-import json
+import cPickle
#[isBase64, gbk]
EncodingList = ReadChConfig.GetEvalChConfig("EncodingTex")
@@ -153,7 +153,7 @@
sendDict, callFunc, extendValueList = g_dbCommandList.pop(0)
#0:不返回,1:DB返回信息到GameServer
- GameWorld.GetGameWorld().SendDBOper(1, json.dumps(sendDict, ensure_ascii=False))
+ GameWorld.GetGameWorld().SendDBOper(1, cPickle.dumps(sendDict, 2))
GameWorld.Log("send dbcommand:%s"%sendDict)
g_proccessCmdInfo = [callFunc, extendValueList]
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyAction.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyAction.py
index 2ac4979..a8fc787 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyAction.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFamilyAction.py
@@ -34,7 +34,7 @@
import PlayerControl
import IPY_GameServer
import DataRecordPack
-import json
+import cPickle
#---------------------------------------------------------------------
## 设置玩家家族行为
@@ -45,7 +45,7 @@
# @return None
def MapServer_PlayerFamilyActionNote(curPlayer, actionType, actionData, tick):
- actionDataList = json.loads(actionData)
+ actionDataList = cPickle.loads(actionData)
familyId = curPlayer.GetFamilyID()
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py
index 68c9778..e65872c 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py
@@ -28,7 +28,7 @@
import copy
import PlayerViewCache
import PlayerTeam
-import json
+import cPickle
#---------------------------------------------------------------------
@@ -82,7 +82,7 @@
#玩家的数据没有缓存过
PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
return
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
tagLV = cacheDict["LV"]
else:
tagLV = tagPlayer.GetLV()
@@ -324,7 +324,7 @@
PlayerControl.NotifyCode(srcPlayer, 'Friend_MakeFriend', [curPlayer.GetName()])
#srcPlayer.MapServer_QueryPlayerResult(0, 0, 'AddFriendSucceed', "", 0)
else:
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
PlayerControl.NotifyCode(curPlayer, 'Friend_MakeFriend', [cacheDict['Name']])
# 记录等对方上线通知地图,任务等会用到触发逻辑,通用记录次数即可, MapServer_SyncFriendInfo为具体的好友数量,根据策划需求制作
pass
@@ -396,7 +396,7 @@
curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagID)
if not curCache:
return
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
playerName = cacheDict['Name']
else:
playerName = tagPlayer.GetName()
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py
index 4daf6d4..ca043b2 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerGeTui.py
@@ -25,6 +25,7 @@
import PyDataManager
import time
import json
+import cPickle
# VIP权限
Def_Onoff_VIPCount = 5
(
@@ -282,14 +283,14 @@
if curPlayer and not PlayerControl.GetIsTJG(curPlayer):
continue
- recordDict = json.loads(bossAttentionData.RecordData)
- if recordDict.get(str(bossID), 0) in [0, 9]:
+ recordDict = cPickle.loads(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 = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
if not CheckCanGeTui(cacheDict, geTuiType):
# 过滤个推
continue
@@ -327,7 +328,7 @@
if not curCache:
return
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
if not CheckCanGeTui(cacheDict, Def_Onoff_Chat):
# 过滤个推
return
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py
index e5612fa..f944dc9 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerSocial.py
@@ -26,7 +26,7 @@
import IpyGameDataPY
import PlayerViewCache
import PyGameData
-import json
+import cPickle
#--------------------社交圈基本结构-------------------
# 社交圈
class SocialPlayers(object):
@@ -723,7 +723,7 @@
playerSocial.RealmLV = 1
playerSocial.OnlineType = ChConfig.Def_Offline
else:
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
playerSocial.clear()
playerSocial.PlayerID = playerID
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py
index 59a7206..e71da50 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py
@@ -28,7 +28,7 @@
import CrossRealmMsg
import ChNetSendPack
import NetPackCommon
-import json
+import cPickle
import PlayerGeTui
import re
@@ -101,7 +101,7 @@
return
if curCache:
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
tagPlayerName = cacheDict["Name"]
talkType = sendPack.GetTalkType()
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
index 525da05..3da6842 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -32,6 +32,7 @@
import ChConfig
import time
+import cPickle
import json
ViewCacheMgr = GameWorld.GameWorldData.GetPlayerViewCacheMgr()
@@ -85,7 +86,7 @@
# 同步更新助战信息
if PlayerFBHelpBattle.IsInHelpBattleCheckInList(PlayerID):
- PropDataDict = json.loads(PropData)
+ PropDataDict = cPickle.loads(PropData)
fightPower = PropDataDict.get("FightPower", 0)
familyID = PropDataDict.get("FamilyID", 0)
playerName = PropDataDict.get("Name", "")
@@ -214,11 +215,11 @@
sendPack.PlusDataSize = len(sendPack.PlusData)
else:
#成功回包 缓存数据
- sendPack.PropData = curCache.GetPropData()
+ sendPack.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
sendPack.PropDataSize = len(sendPack.PropData)
- sendPack.ItemData = GetItemData(curCache)
+ sendPack.ItemData = json.dumps(cPickle.loads(GetItemData(curCache)), ensure_ascii=False)
sendPack.ItemDataSize = len(sendPack.ItemData)
- sendPack.PlusData = GetPlusData(curCache)
+ sendPack.PlusData = json.dumps(cPickle.loads(GetPlusData(curCache)), ensure_ascii=False)
sendPack.PlusDataSize = len(sendPack.PlusData)
NetPackCommon.SendFakePack(curPlayer, sendPack)
@@ -236,7 +237,7 @@
return
playerEquipList = []
- equipItemList = json.loads(itemData)
+ equipItemList = cPickle.loads(itemData)
for equipItemDict in equipItemList:
equipIndex = equipItemDict["ItemIndex"]
if equipIndex not in ShareDefine.RoleEquipType:
@@ -276,7 +277,7 @@
answerPack.OnlineType = ChConfig.Def_Offline
answerPack.ServerGroupID = 0
else:
- cacheDict = json.loads(curCache.GetPropData())
+ cacheDict = cPickle.loads(curCache.GetPropData())
answerPack.PlayerID = clientPack.PlayerID
answerPack.PlayerName = cacheDict["Name"]
@@ -305,14 +306,14 @@
curCache = ViewCacheMgr.FindCache(playerID)
if not curCache:
return
- PropData = json.loads(curCache.GetPropData())
+ PropData = cPickle.loads(curCache.GetPropData())
PropData["FamilyID"] = familyID
PropData["FamilyName"] = familyName
playerLV = PropData["LV"]
- PropData = json.dumps(PropData, ensure_ascii=False)
- ItemData = curCache.GetItemData()
- PlusData = curCache.GetPlusData()
+ PropData = cPickle.dumps(PropData, 2)
+ ItemData = GetItemData(curCache)
+ PlusData = GetPlusData(curCache)
UpdatePlayerCache(playerID, PropData, ItemData, PlusData, True if playerLV > 150 else False)
return
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py
index 992ecc5..1e12485 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerXMZZ.py
@@ -36,6 +36,7 @@
import random
import json
import math
+import cPickle
RecType = ShareDefine.Def_UniversalGameRecType_XMZZStageRecord
RecType1 = ShareDefine.Def_UniversalGameRecType_XMZZPKInfoRecord
@@ -265,14 +266,13 @@
curCache = PlayerViewCache.ViewCacheMgr.FindCache(pkPlayerID)
if not curCache:
return
- PropData, ItemData = curCache.GetPropData(), curCache.GetItemData()
packData = ChPyNetSendPack.tagGCXMZZFightInfo()
packData.Clear()
packData.PlayerID = pkPlayerID
- packData.PropData = PropData
+ packData.PropData = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False)
packData.PropDataSize = len(packData.PropData)
- packData.ItemData = ItemData
+ packData.ItemData = json.dumps(cPickle.loads(PlayerViewCache.GetItemData(curCache)), ensure_ascii=False)
packData.ItemDataSize = len(packData.ItemData)
NetPackCommon.SendFakePack(curPlayer, packData)
return
@@ -674,14 +674,15 @@
#已匹配过的跳过
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] = [curCache.GetPropData(), curCache.GetItemData()]
+ pkDataDict[playerID] = [propDataDict, itemDataDict]
#GameWorld.DebugLog(' 筛选对手 playerID=%s,power=%s' % (playerID, power))
if minPower1 < power < myPower:
underList1.append(playerID)
@@ -715,15 +716,15 @@
if isRobotNPC:
#机器人, 职业随机
openJob = IpyGameDataPY.GetFuncEvalCfg("OpenJob")
- PropData = str({"Job":random.choice(openJob), "LV":curPlayer.GetLV()})
- ItemData = "" # 前端自己根据职业及NPC等级处理
+ PropData = {"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)
@@ -732,16 +733,16 @@
packData = ChPyNetSendPack.tagGCXMZZFightInfo()
packData.Clear()
packData.PlayerID = pkPlayerID
- packData.PropData = PropData
+ packData.PropData = json.dumps(PropData, ensure_ascii=False)
packData.PropDataSize = len(packData.PropData)
- packData.ItemData = ItemData
+ packData.ItemData = json.dumps(ItemData, ensure_ascii=False)
packData.ItemDataSize = len(packData.ItemData)
NetPackCommon.SendFakePack(curPlayer, packData)
#通知地图
pkPlayerPropData = {}
if PropData:
- pkPlayerPropData = eval(PropData)
+ pkPlayerPropData = PropData
else:
GameWorld.ErrLog("仙魔之争没有匹配到对手信息!fightPower=%s" % curPlayer.GetFightPower(), myPlayerID)
vsPlayerInfo = [pkPlayerID, pkPlayerPropData]
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py
index 3be21b8..5697e1b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFamily.py
@@ -36,7 +36,7 @@
import GameFuncComm
import PlayerTJG
import IpyGameDataPY
-import json
+import cPickle
import time
import random
@@ -591,7 +591,7 @@
return
#请求记录申请进入家族信息
- sendMsg = json.dumps([familyID, curPlayer.GetFightPower()])
+ sendMsg = cPickle.dumps([familyID, curPlayer.GetFightPower()], 2)
curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_AddFamilyAction,
ShareDefine.Def_ActionType_FamilyAdd, '', sendMsg, len(sendMsg))
@@ -746,7 +746,7 @@
## 添加家族事件记录
def AddFamilyEventNote(curPlayer, eventType, valueList):
##同步记录到GameServer, eventType默认为value1
- sendMsg = json.dumps([eventType] + valueList, ensure_ascii=False)
+ sendMsg = cPickle.dumps([eventType] + valueList, 2)
curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_AddFamilyAction, ShareDefine.Def_ActionType_FamilyEvent, '', sendMsg, len(sendMsg))
GameWorld.DebugLog("AddFamilyEventNote sendMsg=%s" % sendMsg)
return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
index 9384eae..b25ce9b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
@@ -32,7 +32,7 @@
import BossHurtMng
import time
-import json
+import cPickle
Def_Process_Tick = "ProcessPlayerCache"
##玩家下线同步
@@ -169,9 +169,9 @@
curPlayerPlusDict["Fruit"] = PlayerAttrFruit.GetAttrFruitEatCntDict(curPlayer)
#-----------
- curPlayerPropData = json.dumps(curPlayerPropDict, ensure_ascii=False)
- curPlayerItemData = json.dumps(curEquipItemList, ensure_ascii=False)
- curPlayerPlusData = json.dumps(__RemoveEmptyDataKey(curPlayerPlusDict), ensure_ascii=False)
+ curPlayerPropData = cPickle.dumps(curPlayerPropDict, 2)
+ curPlayerItemData = cPickle.dumps(curEquipItemList, 2)
+ curPlayerPlusData = cPickle.dumps(__RemoveEmptyDataKey(curPlayerPlusDict), 2)
return (curPlayerPropData, curPlayerItemData, curPlayerPlusData)
def __RemoveEmptyDataKey(dataDict):
diff --git a/ServerPython/db/PyMongoDataServer/GMToolLogicProcess/ProjSpecialProcess.py b/ServerPython/db/PyMongoDataServer/GMToolLogicProcess/ProjSpecialProcess.py
index 2959052..a634f1d 100644
--- a/ServerPython/db/PyMongoDataServer/GMToolLogicProcess/ProjSpecialProcess.py
+++ b/ServerPython/db/PyMongoDataServer/GMToolLogicProcess/ProjSpecialProcess.py
@@ -97,7 +97,7 @@
funcName = ''
try:
# 获得gm命令信息
- gmCmdDict = json.loads(cmd)
+ gmCmdDict = eval(cmd)
funcName = gmCmdDict.get(GMCommon.Def_GMKey_Type, '')
if funcName == None:
--
Gitblit v1.8.0