From 06183f48470b7a31d3b4b7744ef3cf7a2385f80e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 28 十一月 2024 16:48:32 +0800
Subject: [PATCH] 10312 【越南】【英文】【bt】【砍树】查看跨服玩家数据向对应子服查询
---
ServerPython/CoreServerGroup/GameServer/PyNetPack.ini | 12
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py | 21 +
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py | 2
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py | 358 +++++++++++++++++++++++-----
ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py | 8
ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py | 2
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py | 46 +++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py | 39 +-
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py | 99 --------
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py | 21 -
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py | 53 +++
11 files changed, 430 insertions(+), 231 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini b/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
index 96477c9..ea1a468 100644
--- a/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
+++ b/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
@@ -352,11 +352,15 @@
Writer = alee
Releaser = alee
RegType = 0
-RegisterPackCount = 1
+RegisterPackCount = 2
PacketCMD_1=0xB3
PacketSubCMD_1=0x06
PacketCallFunc_1=OnViewPlayerShortInfo
+
+PacketCMD_2=0xC0
+PacketSubCMD_2=0x02
+PacketCallFunc_2=OnViewCrossPlayerInfo
[GameWorldBoss]
ScriptName = Player\GameWorldBoss.py
@@ -456,9 +460,9 @@
RegType = 0
RegisterPackCount = 2
-PacketCMD_1=0xC0
-PacketSubCMD_1=0x02
-PacketCallFunc_1=OnViewCrossPlayerInfo
+PacketCMD_1=
+PacketSubCMD_1=
+PacketCallFunc_1=
PacketCMD_2=0xC0
PacketSubCMD_2=0x03
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
index eb0409a..9fe85d6 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
@@ -23,6 +23,7 @@
import PlayerFuncTeam
import CrossLuckyCloudBuy
import IPY_GameServer
+import PlayerViewCache
import CrossRealmPlayer
import PlayerCompensation
import PlayerActBossTrial
@@ -66,7 +67,7 @@
if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK):
GameWorld.ErrLog("服务器未启动好,不允许向跨服服务器发送数据! %s" % (srcMsg))
return
- GameWorld.Log("SendMsgToCrossServer => %s" % (srcMsg))
+ GameWorld.Log("SendMsgToCrossServer => %s, %s" % (msgType, srcMsg))
GameWorld.GetGameWorld().SendMergerChildToCenterStringData(sendMsg, len(sendMsg))
return
@@ -78,11 +79,11 @@
return
msgDict = cPickle.loads(recvMsg)
- GameWorld.Log("OnCrossServerReceiveMsg: %s" % msgDict)
-
msgType = msgDict.get("MsgType", -1)
msgData = msgDict.get("Data", "")
serverGroupID = msgDict.get("ServerGroupID", 0)
+
+ GameWorld.Log("OnCrossServerReceiveMsg: %s, %s, %s" % (msgType, serverGroupID, msgDict))
if msgType == ShareDefine.ClientServerMsg_PKMatch:
CrossRealmPK.ClientServerMsg_PKMatch(serverGroupID, msgData, tick)
@@ -124,7 +125,10 @@
ClientServerMsg_ServerInitOK(serverGroupID, tick)
elif msgType == ShareDefine.ClientServerMsg_ViewPlayerCache:
- CrossRealmPlayer.ClientServerMsg_ViewPlayerCache(serverGroupID, msgData)
+ PlayerViewCache.ClientServerMsg_ViewPlayerCache(serverGroupID, msgData)
+
+ elif msgType == ShareDefine.ClientServerMsg_PushPlayerCache:
+ PlayerViewCache.ClientServerMsg_PushPlayerCache(serverGroupID, msgData)
elif msgType == ShareDefine.ClientServerMsg_PullOtherPlayerPackData:
PlayerPackData.ClientServerMsg_PullOtherPlayerPackData(serverGroupID, msgData)
@@ -310,7 +314,7 @@
if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK):
GameWorld.ErrLog("跨服服务器未启动好,不允许向子服发送数据! serverGroupIDList=%s, srcMsg=%s" % (serverGroupIDList, srcMsg))
return
- GameWorld.Log("SendMsgToClientServer => serverGroupIDList=%s, srcMsg=%s" % (serverGroupIDList, srcMsg))
+ GameWorld.Log("SendMsgToClientServer => %s, %s, %s" % (msgType, serverGroupIDList, srcMsg))
if not serverGroupIDList:
GameWorld.GetGameWorld().SendBroadcastMergeClient(sendMsg, len(sendMsg))
else:
@@ -335,7 +339,7 @@
msgType = msgDict.get("MsgType", -1)
msgData = msgDict.get("Data", "")
crossServerTimeStr = msgDict.get("CrossServerTime", "")
- GameWorld.Log("OnClientServerReceiveMsg: %s" % msgDict)
+ GameWorld.Log("OnClientServerReceiveMsg: %s, %s" % (msgType, msgDict))
if crossServerTimeStr:
curServerTime = int(time.time())
crossServerTime = GameWorld.ChangeTimeStrToNum(crossServerTimeStr)
@@ -363,7 +367,10 @@
PlayerTalk.CrossServerMsg_ChatCrossWorld(msgData)
elif msgType == ShareDefine.CrossServerMsg_ViewPlayerCacheRet:
- CrossRealmPlayer.CrossServerMsg_ViewPlayerCacheRet(msgData, tick)
+ PlayerViewCache.CrossServerMsg_ViewPlayerCacheRet(msgData, tick)
+
+ elif msgType == ShareDefine.CrossServerMsg_PullPlayerViewCache:
+ PlayerViewCache.CrossServerMsg_PullPlayerViewCache(msgData)
elif msgType == ShareDefine.CrossServerMsg_PlayerPackDataState:
PlayerPackData.CrossServerMsg_PlayerPackDataState(msgData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
index 682d763..1dd27a2 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
@@ -712,7 +712,13 @@
# 上线
if isOnline:
- PlayerPackData.OnPlayerLogin_CrossLogic(serverGroupID, serverID, playerID)
+ # 需要管理跨服在线状态时,默认需要同步缓存信息
+ syncStateInfo = {"playerID":playerID, "ViewCacheCross":1}
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ if playerID in packDataMgr.playerPackDataDict:
+ syncStateInfo["PackDataCross"] = 1
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PlayerPackDataState, syncStateInfo, [serverGroupID])
+
GameXiangong.OnPlayerLogin_CrossLogic(serverGroupID, serverID, playerID)
# 下线
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
index a59b095..9a0007d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -21,7 +21,6 @@
import ReadChConfig
import ChConfig
import PlayerControl
-import PlayerViewCache
import PlayerCompensation
import ChPyNetSendPack
import PlayerDBGSEvent
@@ -283,104 +282,6 @@
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
GameWorld.ErrLog("某些异常情况下,前端强制发包退出跨服状态! ", curPlayer.GetPlayerID())
PlayerControl.SetCrossMapID(curPlayer, 0)
- return
-
-#// C0 02 查看跨服玩家信息 #tagCGViewCrossPlayerInfo
-#
-#struct tagCGViewCrossPlayerInfo
-#{
-# tagHead Head;
-# DWORD PlayerID; // 跨服玩家ID
-# BYTE EquipClassLV; //大于0为查看指定境界阶装备信息, 0为查看默认信息
-#};
-def OnViewCrossPlayerInfo(index, clientData, tick):
- if GameWorld.IsCrossServer():
- return
-
- curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
- playerID = curPlayer.GetPlayerID()
- tagPlayerID = clientData.PlayerID
- equipClassLV = clientData.EquipClassLV
- curCache = PlayerViewCache.FindViewCache(tagPlayerID)
- ## 本服有,直接回客户端
- if curCache:
- GameWorld.DebugLog("查看跨服玩家,是本服玩家,直接回复!tagPlayerID=%s" % (tagPlayerID), playerID)
- PlayerViewCache.Sync_PlayerCache(curPlayer, curCache, equipClassLV)
- return
-
- if tagPlayerID in PyGameData.g_crossPlayerViewCache:
- validChaheTime = 10 * 60 * 1000
- cacheInfo, updTick = PyGameData.g_crossPlayerViewCache[tagPlayerID]
- if tick - updTick <= validChaheTime:
- GameWorld.DebugLog("查看跨服玩家数据同步CD中,直接用缓存数据回复!tagPlayerID=%s" % (tagPlayerID), playerID)
- SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo)
- return
-
- for crossPlayerID, cacheInfoList in PyGameData.g_crossPlayerViewCache.items():
- if tick - cacheInfoList[1] > validChaheTime:
- PyGameData.g_crossPlayerViewCache.pop(crossPlayerID)
-
- # 发送跨服服务器查询
- dataMsg = {"tagPlayerID":tagPlayerID, "playerID":playerID, "equipClassLV":equipClassLV}
- CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ViewPlayerCache, dataMsg)
- return
-
-def ClientServerMsg_ViewPlayerCache(serverGroupID, msgData):
- tagPlayerID = msgData["tagPlayerID"]
- playerID = msgData["playerID"]
- equipClassLV = msgData["equipClassLV"]
-
- GameWorld.Log("收到子服查看跨服玩家信息: serverGroupID=%s,playerID=%s,tagPlayerID=%s" % (serverGroupID, playerID, tagPlayerID))
-
- cacheInfo = {}
- curCache = PlayerViewCache.FindViewCache(tagPlayerID)
- if curCache:
- cacheInfo = {"PropData":curCache.PropData, "PlusData":curCache.PlusData}
- for classLV in xrange(1, 15 + 1):
- attrName = "ItemData%s" % classLV
- if hasattr(curCache, attrName):
- cacheInfo[attrName] = getattr(curCache, attrName)
-
- viewPlayerCacheRet = [playerID, tagPlayerID, equipClassLV, cacheInfo]
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ViewPlayerCacheRet, viewPlayerCacheRet, [serverGroupID])
- return
-
-def CrossServerMsg_ViewPlayerCacheRet(msgData, tick):
-
- playerID, tagPlayerID, equipClassLV, cacheInfo = msgData
- GameWorld.Log("收到跨服服务器回复的查看玩家信息: playerID=%s,tagPlayerID=%s" % (playerID, tagPlayerID))
-
- PyGameData.g_crossPlayerViewCache[tagPlayerID] = [cacheInfo, tick] # 更新信息
-
- curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- if curPlayer:
- SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo)
-
- return
-
-def SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo):
- if not cacheInfo:
- PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine")
- return
-
- if equipClassLV:
- itemData = cacheInfo.get("ItemData%s" % equipClassLV, "")
- sendPack = ChPyNetSendPack.tagSCPlayerEquipCacheResult()
- sendPack.PlayerID = tagPlayerID
- sendPack.EquipClassLV = equipClassLV
- sendPack.ItemData = itemData
- sendPack.ItemDataSize = len(sendPack.ItemData)
- NetPackCommon.SendFakePack(curPlayer, sendPack)
- return
-
- #回包客户端
- sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
- sendPack.PlayerID = tagPlayerID
- sendPack.PropData = cacheInfo.get("PropData", "")
- sendPack.PropDataSize = len(sendPack.PropData)
- sendPack.PlusData = cacheInfo.get("PlusData", "")
- sendPack.PlusDataSize = len(sendPack.PlusData)
- NetPackCommon.SendFakePack(curPlayer, sendPack)
return
def CrossServerMsg_PutInItem(itemInfo):
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
index 11fb6b1..8ec303d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
@@ -136,16 +136,7 @@
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])
+ QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", {"PackData":1})
return
def SetNeedPackData(playerIDList):
@@ -340,8 +331,7 @@
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
if not curPlayer:
return
- isCross, isNeed = 1, 1
- QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", [isCross, isNeed])
+ QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", msgData)
return
def CrossServerMsg_PullPlayerPackData(msgData):
@@ -375,7 +365,7 @@
curPlayer.MapServer_QueryPlayerResult(0, 0, "PlayerMirror", sysMsg, len(sysMsg))
return
-def OnMGUpdatePlayerPackData(curPlayer, curPackData):
+def OnMGUpdatePlayerPackData(curPlayer, curPackData, msgInfo):
## 地图同步更新的玩家打包数据
if GameWorld.IsCrossServer():
return
@@ -384,14 +374,13 @@
packData = curPackData.PackData
if not packDataSyncState or not packData:
return
- msgInfo = eval(curPackData.PackMsg) if curPackData.PackMsg else {} # 打包数据附带的信息
# 本服需要,先更新数据
- if packDataSyncState % 10:
+ if packDataSyncState&pow(2, 0):
PyDataManager.GetDBPlayerPackDataManager().UpdPlayerPackData(playerID, packData)
# 跨服需要,同步给跨服,由跨服服务器再进一步处理
- if packDataSyncState / 10:
+ if packDataSyncState&pow(2, 1):
cacheBase = PlayerViewCache.GetSyncCrossCacheBase(curPlayer) if curPlayer else {}
dataMsg = {"playerID":playerID, "packData":packData, "cacheBase":cacheBase, "msgInfo":msgInfo}
CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerPackData, dataMsg)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
index 9257609..eee9715 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -34,14 +34,18 @@
import PlayerPackData
import IpyGameDataPY
import PyDataManager
+import CrossRealmMsg
import CrossRealmPK
import ShareDefine
+import PyGameData
import ChPlayer
import ChConfig
import json
import time
import random
+
+TempCache = PyGameDataStruct.tagPlayerViewCachePy()
def DoOnDayEx():
DelOutofTimeViewCacheData()
@@ -137,6 +141,7 @@
continue
playerViewCachePyDict.pop(playerID)
+ PyGameData.g_crossPlayerViewCache = {} # 每日直接清空跨服玩家查看缓存
return
def DeleteViewCache(playerID):
@@ -254,7 +259,7 @@
def UpdCrossCacheBase(playerID, cacheBase, isLogout=False):
## 更新同步跨服基础查看缓存
- curCache = FindViewCache(playerID, True)
+ curCache = FindViewCache(playerID, True, cacheBase)
if not curCache:
return {}
curCache.LV = cacheBase.get("LV", 0)
@@ -270,6 +275,7 @@
return {}
return cacheDict
+ItemDataClassMax = 20 # 最大装备阶数
#//04 01 地图同步玩家缓存数据到GameServer#tagMGUpdatePlayerCache
#
#struct tagMGUpdatePlayerCache
@@ -298,8 +304,10 @@
playerID = curPackData.PlayerID
#playerLV = curPackData.PlayerLV
isLogout = curPackData.IsLogouting
- GameWorld.DebugLog('ViewCache### OnMGUpdatePlayerCache isLogout=%s' % isLogout, playerID)
- isSaveAll = True # 是否保存所有数据
+ packDataSyncState = curPackData.PackDataSyncState
+ packDataLen = curPackData.PackDataLen
+ GameWorld.DebugLog('地图同步玩家缓存: isLogout=%s,packDataSyncState=%s,packDataLen=%s'
+ % (isLogout, packDataSyncState, packDataLen), playerID)
curCache = FindViewCache(playerID, True)
if not curCache:
@@ -315,23 +323,26 @@
#GameWorld.DebugLog(" 更新Prop数据: size=%s, %s" % (curCache.PropDataSize, curCache.PropData), playerID)
#GameWorld.DebugLog(" 更新Plus数据: size=%s, %s" % (curCache.PlusDataSize, curCache.PlusData), playerID)
- # 装备数据存储,不保存装备数据的话则清空
- for classLV in xrange(1, 20 + 1):
- if not isSaveAll:
- itemDataSize = 0
- itemData = ""
- else:
- itemDataSize = getattr(curPackData, "ItemDataSize%s" % classLV)
- if not itemDataSize:
- continue
- itemData = getattr(curPackData, "ItemData%s" % classLV)
+ # 装备数据存储,只更新有同步的阶,只要该阶有同步,则至少是 {}
+ for classLV in xrange(1, ItemDataClassMax + 1):
+ itemDataSize = getattr(curPackData, "ItemDataSize%s" % classLV)
+ if not itemDataSize:
+ continue
+ itemData = getattr(curPackData, "ItemData%s" % classLV)
setattr(curCache, "ItemData%s" % classLV, itemData)
setattr(curCache, "ItemDataSize%s" % classLV, itemDataSize)
#GameWorld.DebugLog(" 更新Item数据: classLV=%s,size=%s, %s" % (classLV, itemDataSize, itemData), playerID)
+ msgInfo = eval(curPackData.PackMsg) if curPackData.PackMsg else {} # 打包数据附带的信息
+
+ # 需要同步跨服
+ if packDataSyncState&pow(2, 2):
+ dataMsg = {"playerID":playerID, "cacheBuffer":curCache.getBuffer(), "msgInfo":msgInfo}
+ CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PushPlayerCache, dataMsg)
+
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
# 在可能删除之前执行打包数据相关逻辑
- PlayerPackData.OnMGUpdatePlayerPackData(curPlayer, curPackData)
+ PlayerPackData.OnMGUpdatePlayerPackData(curPlayer, curPackData, msgInfo)
if isLogout:
#不需要保存离线数据的,直接删除缓存数据
@@ -365,15 +376,106 @@
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID)
findPlayerID = curPackData.FindPlayerID
equipClassLV = curPackData.EquipClassLV
- curCache = FindViewCache(findPlayerID)
+ OnQueryPlayerCache(curPlayer, findPlayerID, equipClassLV)
+ return
+
+#// C0 02 查看跨服玩家信息 #tagCGViewCrossPlayerInfo
+#
+#struct tagCGViewCrossPlayerInfo
+#{
+# tagHead Head;
+# DWORD PlayerID; // 跨服玩家ID
+# BYTE EquipClassLV; //大于0为查看指定境界阶装备信息, 0为查看默认信息
+#};
+def OnViewCrossPlayerInfo(index, clientData, tick):
+ curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+ tagPlayerID = clientData.PlayerID
+ equipClassLV = clientData.EquipClassLV
+ OnQueryPlayerCache(curPlayer, tagPlayerID, equipClassLV)
+ return
+
+#===============================================================================
+# //B3 06 查询玩家的简短信息 #tagCGViewPlayerShortInfo
+# struct tagCGViewPlayerShortInfo
+# {
+# tagHead Head;
+# DWORD PlayerID;
+# };
+#===============================================================================
+def OnViewPlayerShortInfo(index, clientPack, tick):
+ curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+ tagPlayerID = clientPack.PlayerID
+ tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID)
+ if tagPlayer:
+ answerPack = ChPyNetSendPack.tagGCAnswerPlayerShortInfo()
+ answerPack.Clear()
+ answerPack.PlayerID = clientPack.PlayerID
+ answerPack.PlayerName = tagPlayer.GetName()
+ answerPack.Job = tagPlayer.GetJob()
+ answerPack.LV = tagPlayer.GetLV()
+ answerPack.RealmLV = tagPlayer.GetOfficialRank()
+ answerPack.OnlineType = ChConfig.Def_Online
+ answerPack.IsInTeam = tagPlayer.GetTeamID() > 0
+ answerPack.ServerGroupID = PlayerControl.GetPlayerServerGroupID(tagPlayer)
+ answerPack.Face = tagPlayer.GetFace()
+ answerPack.FacePic = tagPlayer.GetFacePic()
+ NetPackCommon.SendFakePack(curPlayer, answerPack)
+ else:
+ OnQueryPlayerCache(curPlayer, tagPlayerID, isShort=1)
+ return
+
+def OnQueryPlayerCache(curPlayer, tagPlayerID, equipClassLV=0, isShort=0):
+ '''查询玩家缓存,支持直接在本服或跨服查询任意服务器玩家
+ @param tagPlayerID: 目标玩家ID
+ @param equipClassLV: 指定查看某一阶装备信息
+ @param isShort: 是否查看简短信息
+ '''
+ playerID = curPlayer.GetPlayerID()
+ GameWorld.DebugLog("查看玩家: tagPlayerID=%s,equipClassLV=%s,isShort=%s" % (tagPlayerID, equipClassLV, isShort), playerID)
+ # 在跨服服务器查询
+ if GameWorld.IsCrossServer():
+ curCache = FindViewCache(tagPlayerID)
+ if curCache:
+ GameWorld.DebugLog(" 在跨服查看玩家跨服有数据,直接回包! tagPlayerID=%s" % tagPlayerID, playerID)
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV, isShort)
+ else:
+ GameWorld.DebugLog(" 在跨服查看玩家跨服无数据,从子服拉取! tagPlayerID=%s" % tagPlayerID, playerID)
+ viewFrom = 0
+ msgInfo = {"playerID":playerID, "tagPlayerID":tagPlayerID, "equipClassLV":equipClassLV, "isShort":isShort, "viewFrom":viewFrom}
+ dataMsg = {"tagPlayerID":tagPlayerID, "msgInfo":msgInfo}
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PullPlayerViewCache, dataMsg)
+
+ # 在子服服务器查询
+ else:
+ # 同db玩家
+ if PlayerControl.GetDBPlayerAccIDByID(tagPlayerID):
+ GameWorld.DebugLog(" 查看玩家本服有数据,直接回包! tagPlayerID=%s" % tagPlayerID, playerID)
+ curCache = FindViewCache(tagPlayerID)
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV, isShort)
+ else:
+ if tagPlayerID in PyGameData.g_crossPlayerViewCache:
+ tick = GameWorld.GetGameWorld().GetTick()
+ curCache, cacheTick = PyGameData.g_crossPlayerViewCache[tagPlayerID]
+ if tick - cacheTick <= 1 * 60 * 1000:
+ GameWorld.DebugLog(" 1分钟内重复查看跨服玩家且本服有数据,直接回包! tagPlayerID=%s" % tagPlayerID, playerID)
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV, isShort)
+ return
+
+ GameWorld.DebugLog(" 查看玩家本服没有数据,发跨服查! tagPlayerID=%s" % tagPlayerID, playerID)
+ viewFrom = GameWorld.GetServerGroupID()
+ dataMsg = {"playerID":playerID, "tagPlayerID":tagPlayerID, "equipClassLV":equipClassLV, "isShort":isShort, "viewFrom":viewFrom}
+ CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ViewPlayerCache, dataMsg)
+ return
+
+def Sync_PlayerCache(curPlayer, curCache, equipClassLV=0, isShort=0):
+ ## 同步玩家缓存
+
+ if isShort:
+ Sync_PlayerShortInfo(curPlayer, curCache)
+ return
if not curCache:
PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine")
return
- Sync_PlayerCache(curPlayer, curCache, equipClassLV)
- return
-
-def Sync_PlayerCache(curPlayer, curCache, equipClassLV=0):
- ## 同步玩家缓存
if equipClassLV:
itemData = ""
if hasattr(curCache, "ItemDataSize%s" % equipClassLV):
@@ -396,60 +498,35 @@
NetPackCommon.SendFakePack(curPlayer, sendPack)
return
-#===============================================================================
-# //B3 06 查询玩家的简短信息 #tagCGViewPlayerShortInfo
-# struct tagCGViewPlayerShortInfo
-# {
-# tagHead Head;
-# DWORD PlayerID;
-# };
-#===============================================================================
-def OnViewPlayerShortInfo(index, clientPack, tick):
- ## 封包通知
- tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(clientPack.PlayerID)
+def Sync_PlayerShortInfo(curPlayer, curCache):
answerPack = ChPyNetSendPack.tagGCAnswerPlayerShortInfo()
answerPack.Clear()
- if not tagPlayer:
- curCache = FindViewCache(clientPack.PlayerID)
- if not curCache:
- # 实在找不到设置为初始化数据
- answerPack.PlayerID = clientPack.PlayerID
- answerPack.PlayerName = ""
- answerPack.Job = 1
- answerPack.LV = 1
- answerPack.RealmLV = 1
- answerPack.OnlineType = ChConfig.Def_Offline
- answerPack.ServerGroupID = 0
- answerPack.Face = 0
- answerPack.FacePic = 0
- else:
- cacheDict = GetCachePropDataDict(curCache)
- answerPack.PlayerID = clientPack.PlayerID
- answerPack.PlayerName = cacheDict["Name"]
- answerPack.Job = cacheDict["Job"]
- answerPack.LV = cacheDict["LV"]
- answerPack.RealmLV = cacheDict["RealmLV"]
- answerPack.OnlineType = ChConfig.Def_Offline
- answerPack.Face = cacheDict.get("Face", 0)
- answerPack.FacePic = cacheDict.get("FacePic", 0)
-
- if GameWorld.IsCrossServer():
- answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
- else:
- answerPack.ServerGroupID = GameWorld.GetServerGroupID()
+ if not curCache:
+ # 实在找不到设置为初始化数据
+ answerPack.PlayerID = curCache.PlayerID
+ answerPack.PlayerName = ""
+ answerPack.Job = 1
+ answerPack.LV = 1
+ answerPack.RealmLV = 1
+ answerPack.OnlineType = ChConfig.Def_Offline
+ answerPack.ServerGroupID = 0
+ answerPack.Face = 0
+ answerPack.FacePic = 0
else:
- answerPack.PlayerID = clientPack.PlayerID
- answerPack.PlayerName = tagPlayer.GetName()
- answerPack.Job = tagPlayer.GetJob()
- answerPack.LV = tagPlayer.GetLV()
- answerPack.RealmLV = tagPlayer.GetOfficialRank()
- answerPack.OnlineType = ChConfig.Def_Online
- answerPack.IsInTeam = tagPlayer.GetTeamID() > 0
- answerPack.ServerGroupID = PlayerControl.GetPlayerServerGroupID(tagPlayer)
- answerPack.Face = tagPlayer.GetFace()
- answerPack.FacePic = tagPlayer.GetFacePic()
-
- curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+ cacheDict = GetCachePropDataDict(curCache)
+ answerPack.PlayerID = curCache.PlayerID
+ answerPack.PlayerName = cacheDict["Name"]
+ answerPack.Job = cacheDict["Job"]
+ answerPack.LV = cacheDict["LV"]
+ answerPack.RealmLV = cacheDict["RealmLV"]
+ answerPack.OnlineType = ChConfig.Def_Offline
+ answerPack.Face = cacheDict.get("Face", 0)
+ answerPack.FacePic = cacheDict.get("FacePic", 0)
+
+ if GameWorld.IsCrossServer():
+ answerPack.ServerGroupID = cacheDict.get("ServerGroupID", 0)
+ else:
+ answerPack.ServerGroupID = GameWorld.GetServerGroupID()
NetPackCommon.SendFakePack(curPlayer, answerPack)
return
@@ -466,3 +543,142 @@
curCache.PropDataSize = len(curCache.PropData)
return
+def ClientServerMsg_ViewPlayerCache(serverGroupID, msgData):
+ playerID = msgData["playerID"]
+ tagPlayerID = msgData["tagPlayerID"]
+ GameWorld.DebugLog("收到子服查看跨服玩家信息: serverGroupID=%s,playerID=%s,tagPlayerID=%s" % (serverGroupID, playerID, tagPlayerID))
+
+ curCache = FindViewCache(tagPlayerID)
+ if curCache:
+ Send_CrossServerMsg_ViewPlayerCacheRet(curCache, msgData, serverGroupID)
+ else:
+ dataMsg = {"tagPlayerID":tagPlayerID, "msgInfo":msgData}
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PullPlayerViewCache, dataMsg)
+ return
+
+def Send_CrossServerMsg_ViewPlayerCacheRet(curCache, msgData, serverGroupID):
+ ## 发送查看玩家缓存结果给目标子服
+ msgData["cacheBuffer"] = curCache.getBuffer() if curCache else ""
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ViewPlayerCacheRet, msgData, [serverGroupID])
+ return
+
+def ClientServerMsg_PushPlayerCache(serverGroupID, msgData):
+ ## 收到子服推送玩家缓存信息
+
+ playerID = msgData["playerID"]
+ cacheBuffer = msgData["cacheBuffer"]
+ msgInfo = msgData.get("msgInfo", {})
+
+ curCache = None
+ if not cacheBuffer:
+ GameWorld.DebugLog("子服推送的玩家缓存数据为空! playerID=%s" % playerID, serverGroupID)
+ else:
+ curCache = FindViewCache(playerID, True)
+ __updCacheBufferToCacheObj(playerID, cacheBuffer, curCache)
+
+ if not msgInfo:
+ return
+
+ viewFrom = msgInfo.get("viewFrom", 0)
+ if viewFrom != 0:
+ # 其他子服查询的,推送给目标服务器
+ Send_CrossServerMsg_ViewPlayerCacheRet(curCache, msgInfo, viewFrom)
+ return
+
+ # 在跨服查询的,直接回包
+ viewPlayerID = msgInfo.get("playerID", 0)
+ if not viewPlayerID:
+ return
+ curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(viewPlayerID)
+ if not curPlayer:
+ return
+ equipClassLV = msgInfo.get("equipClassLV", 0)
+ isShort = msgInfo.get("isShort", 0)
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV, isShort)
+ return
+
+def __updCacheBufferToCacheObj(playerID, cacheBuffer, cacheObj):
+ try:
+ TempCache.clear()
+ if TempCache.readData(cacheBuffer) == -1:
+ GameWorld.ErrLog("玩家缓存数据readData失败! playerID=%s" % playerID)
+ return
+ except:
+ GameWorld.ErrLog("玩家缓存数据readData异常! playerID=%s" % playerID)
+ return
+ if TempCache.PlayerID != playerID:
+ GameWorld.ErrLog("玩家缓存数据readData后玩家ID不一致! playerID=%s != cachePlayerID=%s" % (playerID, TempCache.PlayerID))
+ return
+
+ cacheObj.PropDataDict = {} # 每次更新数据时,重置字典缓存,下次获取时重新eval缓存
+ cacheObj.PlayerID = TempCache.PlayerID
+ cacheObj.GeTuiIDSize = TempCache.GeTuiIDSize
+ cacheObj.GeTuiID = TempCache.GeTuiID
+ cacheObj.LV = TempCache.LV
+ cacheObj.OffTime = TempCache.OffTime
+ cacheObj.PropData = TempCache.PropData
+ cacheObj.PropDataSize = TempCache.PropDataSize
+ cacheObj.PlusData = TempCache.PlusData
+ cacheObj.PlusDataSize = TempCache.PlusDataSize
+ for classLV in xrange(1, ItemDataClassMax + 1):
+ itemDataSize = getattr(TempCache, "ItemDataSize%s" % classLV)
+ if not itemDataSize:
+ continue
+ itemData = getattr(TempCache, "ItemData%s" % classLV)
+ setattr(cacheObj, "ItemData%s" % classLV, itemData)
+ setattr(cacheObj, "ItemDataSize%s" % classLV, itemDataSize)
+
+ return True
+
+def CrossServerMsg_ViewPlayerCacheRet(msgData, tick):
+ ## 收到跨服服务器回复的查看玩家信息
+ playerID = msgData["playerID"]
+ tagPlayerID = msgData["tagPlayerID"]
+ cacheBuffer = msgData["cacheBuffer"]
+ equipClassLV = msgData["equipClassLV"]
+ isShort = msgData["isShort"]
+
+ curCache = None
+ if cacheBuffer:
+ if tagPlayerID in PyGameData.g_crossPlayerViewCache:
+ curCache = PyGameData.g_crossPlayerViewCache[tagPlayerID][0]
+ else:
+ curCache = PyGameDataStruct.tagPlayerViewCachePy()
+ if __updCacheBufferToCacheObj(tagPlayerID, cacheBuffer, curCache):
+ PyGameData.g_crossPlayerViewCache[tagPlayerID] = [curCache, tick] # 更新信息
+
+ curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+ if curPlayer:
+ Sync_PlayerCache(curPlayer, curCache, equipClassLV, isShort)
+ return
+
+def CrossServerMsg_PullPlayerViewCache(msgData):
+ ## 收到跨服服务器拉取玩家玩家缓存数据
+ msgInfo = msgData["msgInfo"]
+ tagPlayerID = msgData["tagPlayerID"]
+ DoPullPlayerViewCache(tagPlayerID, msgInfo)
+ return
+
+def DoPullPlayerViewCache(playerID, msgInfo):
+ if not PlayerControl.GetDBPlayerAccIDByID(playerID):
+ # 不是本服db玩家不处理
+ return
+
+ curCache = FindViewCache(playerID)
+ if curCache:
+ GameWorld.DebugLog("本服有缓存玩家数据,直接推给跨服!", playerID)
+ dataMsg = {"playerID":playerID, "cacheBuffer":curCache.getBuffer(), "msgInfo":msgInfo}
+ CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PushPlayerCache, dataMsg)
+ return
+
+ curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+ if not curPlayer:
+ GameWorld.DebugLog("本服无缓存玩家数据且不在线,直接回空数据给跨服!", playerID)
+ dataMsg = {"playerID":playerID, "cacheBuffer":"", "msgInfo":msgInfo}
+ CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PushPlayerCache, dataMsg)
+ return
+
+ GameWorld.DebugLog("玩家在线的发给地图同步缓存数据!", playerID)
+ # 在线的转发给地图
+ PlayerPackData.QueryPlayerResult_PlayerMirror(curPlayer, "PullPlayerViewCache", msgInfo)
+ return
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
index 1faabc5..1ef0b75 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
@@ -1635,6 +1635,7 @@
CrossServerMsg_Notify = "Notify" # 提示信息
CrossServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
CrossServerMsg_ViewPlayerCacheRet = "ViewPlayerCacheRet"# 查看跨服玩家信息结果
+CrossServerMsg_PullPlayerViewCache = "PullPlayerViewCache"# 拉取玩家缓存数据
CrossServerMsg_PlayerPackDataState = "PlayerPackDataState"# 玩家打包数据同步状态
CrossServerMsg_PullPlayerPackData = "PullPlayerPackData"# 拉取玩家打包数据
CrossServerMsg_PushPlayerPackData = "PushPlayerPackData"# 推送玩家打包数据
@@ -1695,6 +1696,7 @@
ClientServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
ClientServerMsg_GMCMD = "GMCMD" # GM命令
ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
+ClientServerMsg_PushPlayerCache = "PushPlayerCache" # 推送玩家缓存信息
ClientServerMsg_PullOtherPlayerPackData = "PullOtherPlayerPackData" # 拉其他服玩家打包数据
ClientServerMsg_PlayerPackData = "PlayerPackData" # 玩家打包数据同步
ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
index da34ebb..74ae10c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
@@ -18,6 +18,8 @@
import GameWorld
import PlayerControl
import PlayerCrossRealmPK
+import CrossRealmPlayer
+import IpyGameDataPY
import ShareDefine
import ChConfig
@@ -32,6 +34,49 @@
if not msgList:
__PrintHelp(curPlayer)
+ return
+
+ if msgList[0] == "b":
+ danLV = msgList[1] if len(msgList) > 1 else 0
+ pkScore = msgList[2] if len(msgList) > 2 else 0
+
+ billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
+ danLVLimit = billboardCfg[1] if len(billboardCfg) > 1 else 0
+ if danLV < danLVLimit:
+ GameWorld.DebugAnswer(curPlayer, "最低上榜段位为:%s" % danLVLimit)
+ return
+ danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
+ if not danIpyData:
+ GameWorld.DebugAnswer(curPlayer, "不存在该段位:%s" % danLV)
+ return
+ if pkScore <= 0:
+ pkScore = danIpyData.GetLVUpScore()
+
+ zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ if not zoneID or not seasonID:
+ GameWorld.DebugAnswer(curPlayer, "没有分区或赛季!zoneID:%s,seasonID:%s" % (zoneID, seasonID))
+ return
+
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
+
+ # 请求查询跨服服务器
+ playerInfoDict = {"accID":curPlayer.GetAccID(),
+ "playerID":curPlayer.GetPlayerID(),
+ "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
+ "playerJob":curPlayer.GetJob(),
+ "face":curPlayer.GetFace(),
+ "facePic":curPlayer.GetFacePic(),
+ "fightPower":PlayerControl.GetFightPower(curPlayer),
+ "realmLV":curPlayer.GetOfficialRank(),
+ "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore),
+ "pkScore":pkScore, "danLV":danLV, "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount),
+ }
+ dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "GMSetCrossPK":1, "PlayerInfo":playerInfoDict}
+ GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
+ PlayerCrossRealmPK.SyncCrossRealmPKPlayerInfo(curPlayer)
+ GameWorld.DebugAnswer(curPlayer, "设置上榜段位:%s,积分:%s" % (danLV, pkScore))
return
if len(msgList) == 1:
@@ -122,6 +167,7 @@
GameWorld.DebugAnswer(curPlayer, "设置历史记录: SetCrossPK 赛季ID 类型 数值")
GameWorld.DebugAnswer(curPlayer, "类型:0-段位,1-名次,2-积分,3-奖励等级")
GameWorld.DebugAnswer(curPlayer, "当前连败次数: %s" % curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount))
+ GameWorld.DebugAnswer(curPlayer, "设置上榜: SetCrossPK b 段位 [积分]")
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 468be9f..769946e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
@@ -29,8 +29,6 @@
import IpyGameDataPY
import PlayerHorse
import ChEquip
-import FBCommon
-import BossHurtMng
import ItemCommon
import PyGameData
import PlayerTJG
@@ -81,18 +79,50 @@
#GameWorld.DebugLog("packData=%s %s %s" % (type(packData), len(packData), packData), playerID)
return packData
+def UpdPackDataSyncState(curPlayer, msgData):
+ ## 更新打包数据同步状态,这里只更新状态即可,具体同步由定时同步处理
+ syncState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PackDataSyncState)
+ updSyncState = syncState
+ if msgData.get("PackData"):
+ updSyncState = GameWorld.SetBitValue(updSyncState, 0, 1)
+ if msgData.get("PackDataCross"):
+ updSyncState = GameWorld.SetBitValue(updSyncState, 1, 1)
+ if msgData.get("ViewCacheCross"):
+ updSyncState = GameWorld.SetBitValue(updSyncState, 2, 1)
+ if syncState == updSyncState:
+ return
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PackDataSyncState, updSyncState)
+ GameWorld.DebugLog("更新打包数据同步状态: msgData=%s,syncState=%s,updSyncState=%s"
+ % (msgData, syncState, updSyncState), curPlayer.GetPlayerID())
+ return
+
+def SetPackDataSyncState(curPlayer): UpdPackDataSyncState(curPlayer, {"PackData":1})
+def SetPackDataCrossSyncState(curPlayer): UpdPackDataSyncState(curPlayer, {"PackDataCross":1})
+def SetViewCacheCrossSyncState(curPlayer): UpdPackDataSyncState(curPlayer, {"ViewCacheCross":1})
##更新玩家当前详细信息到GameServer
# @param curPlayer, tick
# @return None
-def UpdateGameServerPlayerCache(curPlayer, tick, IsLogouting=False, forcePackData=False, packMsg=None):
+def UpdateGameServerPlayerCache(curPlayer, tick, IsLogouting=False, forcePackData=False, packMsg=None, isOnlyViewCache=False):
if PlayerTJG.GetIsTJG(curPlayer):
# 脱机不处理
return
curPlayer.SetDict(Def_Process_Tick, tick)
+ PackDataSyncState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PackDataSyncState)
+ isAllEquip = False
+ # 需要同步跨服缓存 且 还没同步装备的
+ if PackDataSyncState&pow(2, 2) and curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipViewCacheState) != 2:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipViewCacheState, 2)
+ isAllEquip = True
+ GameWorld.DebugLog("本次登录首次同步跨服缓存,全装备同步", curPlayer.GetPlayerID())
+
+ if forcePackData:
+ SetPackDataSyncState(curPlayer)
+ SetPackDataCrossSyncState(curPlayer)
+
#获取当前玩家缓存数据
PropData, PlusData = GetPlayerPropPlusCache(curPlayer)
- itemDataDict = __GetPlayerItemDataCache(curPlayer)
+ itemDataDict = __GetPlayerItemDataCache(curPlayer, isAllEquip)
#同步发送到GameServer
sendPack = ChMapToGamePyPack.tagMGUpdatePlayerCache()
@@ -108,20 +138,23 @@
setattr(sendPack, "ItemData%s" % classLV, itemData)
setattr(sendPack, "ItemDataSize%s" % classLV, len(itemData))
# 打包数据相关
- sendPack.PackDataSyncState = 11 if forcePackData else curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PackDataSyncState)
- sendPack.PackData = GetSyncPlayerPackData(curPlayer, forcePackData)
+ sendPack.PackDataSyncState = PackDataSyncState
+ sendPack.PackData = "" if isOnlyViewCache else GetSyncPlayerPackData(curPlayer, forcePackData)
sendPack.PackDataLen = len(sendPack.PackData)
sendPack.PackMsg = str(packMsg) if packMsg else "{}"
sendPack.PackMsgLen = len(sendPack.PackMsg)
- #GameWorld.DebugLog("同步缓存: %s" % sendPack.OutputString())
+ GameWorld.DebugLog("同步缓存: logout=%s,forcePackData=%s,isOnlyViewCache=%s,PackDataSyncState=%s,isAllEquip=%s,classList=%s"
+ % (IsLogouting, forcePackData, isOnlyViewCache, PackDataSyncState, isAllEquip, itemDataDict.keys()), curPlayer.GetPlayerID())
NetPackCommon.SendPyPackToGameServer(sendPack)
return
-def __GetPlayerItemDataCache(curPlayer):
+def __GetPlayerItemDataCache(curPlayer, isAllEquip=False):
## 装备及装备位养成缓存,由于装备位比较多,所以按阶同步,重登第一次同步所有阶
-
- if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipViewCacheState):
+ if not isAllEquip and not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipViewCacheState):
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipViewCacheState, 1)
+ isAllEquip = True
+
+ if isAllEquip:
needSyncClassLVList = xrange(1, IpyGameDataPY.GetFuncCfg('EquipMaxClasslv') + 1)
else:
playerID = curPlayer.GetPlayerID()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
index 7ff3583..9c98f39 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
@@ -18,8 +18,6 @@
import GameWorld
import MirrorAttack
import PlayerViewCacheTube
-import PlayerControl
-import ChConfig
#---------------------------------------------------------------------
# @param query_Type 请求类型
@@ -57,38 +55,33 @@
msgData = funResult[1]
if msgType == "PackDataSyncState":
- isCross, isNeed = msgData
- __UpdPackDataSyncState(curPlayer, isCross, isNeed)
+ PlayerViewCacheTube.UpdPackDataSyncState(curPlayer, msgData)
elif msgType == "PullPlayerPackData":
msgInfo = msgData
__DoPullPlayerPackData(curPlayer, msgInfo, tick)
- return
-
-def __UpdPackDataSyncState(curPlayer, isCross, isNeed):
- ## 更新打包数据同步状态,这里只更新状态即可,具体同步由定时同步处理
- syncState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_PackDataSyncState)
- if isCross:
- updSyncState = (1 if isNeed else 0) * 10 + syncState % 10
- else:
- updSyncState = syncState / 10 + (1 if isNeed else 0)
- if syncState == updSyncState:
- return
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_PackDataSyncState, syncState)
- GameWorld.DebugLog("更新打包数据同步状态: isCross=%s,isNeed=%s,syncState=%s,updSyncState=%s"
- % (isCross, isNeed, syncState, updSyncState), curPlayer.GetPlayerID())
+ elif msgType == "PullPlayerViewCache":
+ msgInfo = msgData
+ __DoPullPlayerViewCache(curPlayer, msgInfo, tick)
+
return
def __DoPullPlayerPackData(curPlayer, msgInfo, tick):
pullFrom = msgInfo.get("pullFrom")
- isCross = False
# 0 或 非本服代表跨服需要
if pullFrom == 0 or (pullFrom > 0 and pullFrom != GameWorld.GetServerGroupID()):
- isCross = True
- __UpdPackDataSyncState(curPlayer, isCross, 1)
- PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, forcePackData=True, packMsg=msgInfo)
+ PlayerViewCacheTube.SetPackDataCrossSyncState(curPlayer)
+ else:
+ PlayerViewCacheTube.SetPackDataSyncState(curPlayer)
+ PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, packMsg=msgInfo)
return
-
+def __DoPullPlayerViewCache(curPlayer, msgInfo, tick):
+ viewFrom = msgInfo.get("viewFrom")
+ # 0 或 非本服代表跨服需要
+ if viewFrom == 0 or (viewFrom > 0 and viewFrom != GameWorld.GetServerGroupID()):
+ PlayerViewCacheTube.SetViewCacheCrossSyncState(curPlayer)
+ PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, packMsg=msgInfo, isOnlyViewCache=True)
+ return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
index 1faabc5..1ef0b75 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
@@ -1635,6 +1635,7 @@
CrossServerMsg_Notify = "Notify" # 提示信息
CrossServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
CrossServerMsg_ViewPlayerCacheRet = "ViewPlayerCacheRet"# 查看跨服玩家信息结果
+CrossServerMsg_PullPlayerViewCache = "PullPlayerViewCache"# 拉取玩家缓存数据
CrossServerMsg_PlayerPackDataState = "PlayerPackDataState"# 玩家打包数据同步状态
CrossServerMsg_PullPlayerPackData = "PullPlayerPackData"# 拉取玩家打包数据
CrossServerMsg_PushPlayerPackData = "PushPlayerPackData"# 推送玩家打包数据
@@ -1695,6 +1696,7 @@
ClientServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
ClientServerMsg_GMCMD = "GMCMD" # GM命令
ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
+ClientServerMsg_PushPlayerCache = "PushPlayerCache" # 推送玩家缓存信息
ClientServerMsg_PullOtherPlayerPackData = "PullOtherPlayerPackData" # 拉其他服玩家打包数据
ClientServerMsg_PlayerPackData = "PlayerPackData" # 玩家打包数据同步
ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
--
Gitblit v1.8.0