From 682fda0da1ff21251cb608b7607a90f3103b2329 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 18 二月 2025 11:57:39 +0800 Subject: [PATCH] 10261 【越南】【砍树】【英文】【BT】【GM】修复定制头像星级未同步bug; --- ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py | 183 +++++++++++++++++---------------------------- 1 files changed, 68 insertions(+), 115 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py index 9cbeaaa..7dbf112 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py @@ -21,13 +21,14 @@ import ReadChConfig import ChConfig import PlayerControl -import PlayerViewCache import PlayerCompensation import ChPyNetSendPack import PlayerDBGSEvent import NetPackCommon import IpyGameDataPY import PyGameData +import PlayerDBOper + # 获取玩家跨服服务器上的名字 #=============================================================================== # def GetCrossPlayerName(curPlayer): @@ -89,6 +90,21 @@ zoneTypeName = ChConfig.Def_CrossZoneTypeName.get(mapID, "CrossZoneComm") ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition(zoneTypeName, {"CrossZoneName":crossZoneName}, True) return ipyDataList + +def GetServerCommCrossZoneID(serverGroupID): + ## 获取跨服常规分区 + zoneTypeName = "CrossZoneComm" + crossZoneName = GameWorld.GetCrossZoneName() + ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition(zoneTypeName, {"CrossZoneName":crossZoneName}, True) + if not ipyDataList: + return 0 + for ipyData in ipyDataList: + serverGroupIDList = ipyData.GetServerGroupIDList() + for serverGroupIDInfo in serverGroupIDList: + if (isinstance(serverGroupIDInfo, tuple) and serverGroupIDInfo[0] <= serverGroupID <= serverGroupIDInfo[1]) \ + or (isinstance(serverGroupIDInfo, int) and serverGroupIDInfo == serverGroupID): + return ipyData.GetZoneID() + return 0 def GetServerCrossZoneMapIpyData(zoneID, mapID): ## 获取本服对应跨服玩法分区地图信息 - 仅适用于固定地图及虚拟分线的跨服玩法 @@ -181,12 +197,21 @@ curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) if not curPlayer: GameWorld.Log(" 退出跨服时本服玩家不在线!", playerID) + DoOfflinePlayerExitCrossServer(playerID) return PlayerControl.SetCrossMapID(curPlayer, 0) return +def DoOfflinePlayerExitCrossServer(playerID): + ## 处理离线玩家退出跨服服务器更新DB数据逻辑 + + PlayerDBOper.UpdateDBOper(PlayerDBOper.Table_DBPlayer, {"PlayerID":playerID}, {"ExAttr5":0}) + return + def SendCrossRealmReg(curPlayer, registerMap, mapID=0, dataMapID=0, copyMapID=0, posX=0, posY=0, lineID=0): # 发送跨服账号注册上传数据 + # @param mapID: 真实场景地图ID + # @param dataMapID: 真实场景地图ID对应场景数据地图ID # 设置上传数据的活动类型 curPlayer.SetDict(ChConfig.Def_PlayerKey_CrossRegisterMap, registerMap) @@ -216,21 +241,7 @@ # 跨服PK上传数据完毕,通知跨服服务器,准备完毕 if registerMap == ChConfig.Def_FBMapID_CrossRealmPK: - regVSRoomID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MergeRegisterRoomID) - vsRoomID = curPlayer.GetVsRoomId() - - if regVSRoomID != vsRoomID: - GameWorld.Log("上传跨服服务器的 regVSRoomID=%s 与玩家当前的 roomID=%s 不同!不发送准备完毕!" - % (regVSRoomID, vsRoomID), playerID) - return - - dataMsg = { - "accID":curPlayer.GetAccID(), # 角色账号ID - "playerID":playerID, # 角色ID - "vsRoomID":vsRoomID, # 所属对战房间ID - } - CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKPrepareOK, dataMsg) - GameWorld.Log("通知跨服服务器, 玩家匹配PK准备完毕!%s" % str(dataMsg), playerID) + pass # 其他的,在上传数据完毕后,使用通用的通知可进入跨服 else: @@ -257,104 +268,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): @@ -419,6 +332,46 @@ PyGameData.g_crossSetPlayerAttr = {} return +def OnPlayerLogin(curPlayer): + if not IsCrossServerOpen(): + return + + Sync_CrossZoneInfo(curPlayer) + LoginDoUnNotifyCrossMsg(curPlayer) + return + +def MapServer_QueryCrossPlayerResult(playerID, callName, msgInfo, offlineExitCross=False): + ## 同步地图跨服玩家处理信息,玩家可能不在线,缓存后等玩家上线处理,暂不考虑存档问题,服务器维护后未处理的命令将失效 + + curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) + if curPlayer and curPlayer.GetInitOK(): + msgInfo = str(msgInfo) + curPlayer.MapServer_QueryPlayerResult(0, 0, callName, msgInfo, len(msgInfo)) + return curPlayer + else: + # 缓存起来,等上线后处理 + if playerID not in PyGameData.g_unNotifyPlayerCrossMsgDict: + PyGameData.g_unNotifyPlayerCrossMsgDict[playerID] = [] + msgList = PyGameData.g_unNotifyPlayerCrossMsgDict[playerID] + msgList.append([callName, msgInfo]) + GameWorld.Log("玩家不在线,添加未通知的跨服命令: %s, msgInfo=%s" % (callName, msgInfo), playerID) + if offlineExitCross: + DoOfflinePlayerExitCrossServer(playerID) + return +def LoginDoUnNotifyCrossMsg(curPlayer): + playerID = curPlayer.GetPlayerID() + msgList = PyGameData.g_unNotifyPlayerCrossMsgDict.pop(playerID, []) + if not msgList: + return + for callName, msgInfo in msgList: + GameWorld.Log("上线处理未通知的跨服命令: %s, msgInfo=%s" % (callName, msgInfo), playerID) + msgInfo = str(msgInfo) + curPlayer.MapServer_QueryPlayerResult(0, 0, callName, msgInfo, len(msgInfo)) + return - \ No newline at end of file +def Sync_CrossZoneInfo(curPlayer): + clientPack = ChPyNetSendPack.tagGCCrossZoneInfo() + clientPack.CommZoneID = GetServerCommCrossZoneID(GameWorld.GetServerGroupID()) + NetPackCommon.SendFakePack(curPlayer, clientPack) + return -- Gitblit v1.8.0