From faeca70d5c95ccb4744931a176f671c7836b1a72 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期五, 10 五月 2024 17:25:06 +0800 Subject: [PATCH] 10054 【后端】任务系统(是否完成任务改为领取完奖励才算;福地采集任务类型增加进度改为开始采集就算;) --- ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py | 368 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 334 insertions(+), 34 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py index b90e7af..20b9244 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py @@ -17,17 +17,31 @@ import GameWorld import ShareDefine +import PlayerAssist import PlayerControl +import CrossLuckyCloudBuy import IPY_GameServer import CrossRealmPlayer +import PlayerCompensation +import CrossActionControl +import CrossActAllRecharge +import CrossChampionship +import CrossBattlefield +import CrossBillboard +import CrossYaomoBoss import GameWorldBoss import CrossRealmPK +import PlayerQuery +import PlayerTalk +import PyGameData import CrossBoss import ChConfig +import PlayerFB import GMShell import traceback -import json +import cPickle +import time def SendMsgToCrossServer(msgType, dataMsg): ## 发送信息到跨服服务器上 @@ -35,23 +49,36 @@ return if not dataMsg: return - sendMsg = str({"MsgType":msgType, "Data":dataMsg, "ServerGroupID":GameWorld.GetServerGroupID()}) - GameWorld.Log("SendMsgToCrossServer => %s" % (sendMsg)) + + # 协议要用最高级2,可减少长度 + srcMsg = {"MsgType":msgType, "Data":dataMsg, "ServerGroupID":GameWorld.GetServerGroupID()} + sendMsg = cPickle.dumps(srcMsg, 2) + if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): + GameWorld.ErrLog("服务器未启动好,不允许向跨服服务器发送数据! %s" % (srcMsg)) + return + GameWorld.Log("SendMsgToCrossServer => %s" % (srcMsg)) GameWorld.GetGameWorld().SendMergerChildToCenterStringData(sendMsg, len(sendMsg)) return def OnCrossServerReceiveMsg(recvMsg, tick): ## 跨服服务器收到信息处理 try: - #GameWorld.Log("OnCrossServerReceiveMsg: %s" % recvMsg) - msgDict = eval(recvMsg) + if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): + GameWorld.Log("服务器未启动好,不处理子服信息!") + return + msgDict = cPickle.loads(recvMsg) + + GameWorld.Log("OnCrossServerReceiveMsg: %s" % msgDict) msgType = msgDict.get("MsgType", -1) msgData = msgDict.get("Data", "") serverGroupID = msgDict.get("ServerGroupID", 0) - + if msgType == ShareDefine.ClientServerMsg_PKMatch: CrossRealmPK.ClientServerMsg_PKMatch(serverGroupID, msgData, tick) + + elif msgType == ShareDefine.ClientServerMsg_PKRobotOver: + CrossRealmPK.ClientServerMsg_PKRobotOver(serverGroupID, msgData, tick) elif msgType == ShareDefine.ClientServerMsg_PKCancel: CrossRealmPK.ClientServerMsg_PKCancel(msgData, tick) @@ -61,74 +88,229 @@ elif msgType == ShareDefine.ClientServerMsg_PKBillboard: CrossRealmPK.ClientServerMsg_PKBillboard(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_LuckyCloudBuy: + CrossLuckyCloudBuy.ClientServerMsg_LuckyCloudBuy(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_QueryBillboard: + CrossBillboard.ClientServerMsg_QueryBillboard(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_UpdateBillboard: + CrossBillboard.ClientServerMsg_UpdateBillboard(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_MailContent: + PlayerCompensation.ClientServerMsg_MailContent(serverGroupID, msgData, tick) + + elif msgType == ShareDefine.ClientServerMsg_ChatCrossWorld: + PlayerTalk.ClientServerMsg_ChatCrossWorld(serverGroupID, msgData, tick) elif msgType == ShareDefine.ClientServerMsg_GMCMD: GMShell.ClientServerMsg_GMCMD(msgData, tick) elif msgType == ShareDefine.ClientServerMsg_ServerInitOK: - ClientServerMsg_ServerInitOK(serverGroupID, msgData, tick) + ClientServerMsg_ServerInitOK(serverGroupID, tick) elif msgType == ShareDefine.ClientServerMsg_ViewPlayerCache: CrossRealmPlayer.ClientServerMsg_ViewPlayerCache(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_QueryNPCInfo: + PlayerQuery.ClientServerMsg_QueryNPCInfo(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_EnterFB: + PlayerFB.ClientServerMsg_EnterFB(serverGroupID, msgData, tick) + + elif msgType == ShareDefine.ClientServerMsg_SetPlayerAttrValue: + MapServer_CrossSetPlayerAttrValue(msgData) + + elif msgType == ShareDefine.ClientServerMsg_AddBuff: + MapServer_CrossAddBuff(msgData) + + elif msgType == ShareDefine.ClientServerMsg_CrossAssist: + PlayerAssist.ClientServerMsg_CrossAssist(serverGroupID, msgData, tick) + + elif msgType == ShareDefine.ClientServerMsg_BattlefieldBuyOpen: + CrossBattlefield.ClientServerMsg_BattlefieldBuyOpen(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_BattlefieldCallJoin: + CrossBattlefield.ClientServerMsg_BattlefieldCallJoin(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_BattlefieldCallKick: + CrossBattlefield.ClientServerMsg_BattlefieldCallKick(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_BattlefieldCallChange: + CrossBattlefield.ClientServerMsg_BattlefieldCallChange(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipOfficialApply: + CrossChampionship.ClientServerMsg_ChampionshipOfficialApply(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipOfficialApplyReply: + CrossChampionship.ClientServerMsg_ChampionshipOfficialApplyReply(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipOfficialKick: + CrossChampionship.ClientServerMsg_ChampionshipOfficialKick(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipOfficialLeave: + CrossChampionship.ClientServerMsg_ChampionshipOfficialLeave(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipOfficialChallenge: + CrossChampionship.ClientServerMsg_ChampionshipOfficialChallenge(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipGuess: + CrossChampionship.ClientServerMsg_ChampionshipGuess(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChampionshipWorship: + CrossChampionship.ClientServerMsg_ChampionshipWorship(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ActAllRechargeValue: + CrossActAllRecharge.ClientServerMsg_ActAllRechargeValue(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_CrossYaomoBossHurtAward: + CrossYaomoBoss.ClientServerMsg_CrossYaomoBossHurtAward(serverGroupID, msgData) + + # 需要发送到地图服务器处理的 + elif msgType in [ShareDefine.ClientServerMsg_Reborn, ShareDefine.ClientServerMsg_CollectNPC]: + MapServer_CrossServerReceiveMsg(msgType, msgData, serverGroupID) else: GameWorld.ErrLog("没有该信息类型逻辑处理!") except: - GameWorld.ErrLog("OnCrossServerReceiveMsg:%s; except:%s" % (recvMsg, traceback.format_exc())) - if GameWorld.GetGameWorld().GetDebugLevel(): - raise BaseException(str(traceback.format_exc())) + GameWorld.RaiseException("跨服服务器接收信息处理报错 \r\n%s" % str(traceback.format_exc())) return -def ClientServerMsg_ServerInitOK(serverGroupID, msgData, tick): +def ClientServerMsg_ServerInitOK(serverGroupID, tick): ''' 收到子服连接成功通知 当子服启动成功后,可同步一次跨服服务器活动状态及活动数据给子服 ''' - GameWorld.Log("收到跨服子服连接成功通知!") - CrossRealmPlayer.ClientServerMsg_ServerInitOK(serverGroupID) - CrossRealmPK.ClientServerMsg_ServerInitOK(serverGroupID, tick) - CrossBoss.ClientServerMsg_ServerInitOK(serverGroupID) + GameWorld.Log("收到跨服子服连接成功通知! serverGroupID=%s" % serverGroupID) + Sync_CrossServerInitDataToClientServer(tick, serverGroupID) return +def Sync_CrossServerInitDataToClientServer(tick, serverGroupID=0): + ''' 同步跨服功能数据到子服服务器 + 本函数调用时机: + 1.跨服服务器启动成功,主动广播同步所有子服,此时设置 serverGroupID 为 0 + 2.子服启动成功,由子服主动发起请求同步最新数据,此时有指定子服 serverGroupID + 3.子服重新连接跨服服务器成功,逻辑同2 + @param serverGroupID: 子服服务器组ID,为0时为全部子服务器组 + ''' + CrossRealmPlayer.Sync_CrossCommInitDataToClientServer(serverGroupID) + CrossRealmPK.Sync_CrossPKInitDataToClientServer(tick, serverGroupID) + CrossChampionship.Sync_CrossChampionshipDataToClientServer(serverGroupID) + CrossBattlefield.Sync_CrossBattlefieldDataToClientServer(serverGroupID) + CrossBoss.Sync_CrossBossInitDataToClientServer(serverGroupID) + CrossActionControl.Sync_CrossActInfoToClientServer(serverGroupID) + CrossLuckyCloudBuy.Sync_LuckyCloudBuyDataToClientServer(tick, serverGroupID) + CrossActAllRecharge.Sync_AllRechargeDataToClientServer(serverGroupID) + CrossYaomoBoss.Sync_CrossYaomoBossDataToClientServer(serverGroupID) + PlayerCompensation.Sync_CrossMailPlayerIDToClientServer(serverGroupID) + return + +def MapServer_CrossServerReceiveMsg(msgType, msgData, serverGroupID): + ## 收到子服信息,需要发送到地图服务器处理 + + if not isinstance(msgData, dict): + return + tagPlayerID = msgData.get("PlayerID") + if not tagPlayerID: + return + tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) + if not tagPlayer: + return + msgInfo = str([msgType, msgData, serverGroupID]) + tagPlayer.MapServer_QueryPlayerResult(0, 0, "CrossServerReceiveMsg", msgInfo, len(msgInfo)) + return + +def MapServer_CrossSetPlayerAttrValue(msgData): + for playerID, setAttrInfoList in msgData.items(): + player = GameWorld.GetPlayerManager().FindPlayerByID(playerID) + if not player: + return + msgInfo = str(setAttrInfoList) + player.MapServer_QueryPlayerResult(0, 0, "CrossSetPlayerAttrValue", msgInfo, len(msgInfo)) + return + +def MapServer_CrossAddBuff(msgData): + ## 收到子服信息,添加buff + tagPlayerID = msgData.get("PlayerID") + if not tagPlayerID: + return + tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) + if not tagPlayer: + return + buffID = msgData.get("buffID") + if not buffID: + return + sendMsg = str(buffID) + tagPlayer.MapServer_QueryPlayerResult(0, 0, 'AddBuff', sendMsg, len(sendMsg)) + return ## ================================================================================================ -def SendMsgToClientServer(msgType, dataMsg, serverGroupIDList=[]): +def SendMsgToClientServer(msgType, dataMsg, serverGroupIDList=None): ''' 广播信息到子服务器上 @param serverGroupIDList: 发送指定的服务器组ID列表,内部已经针对列表中组ID去重, 所以外部逻辑可直接添加,不用考虑组ID重复问题,没有指定服务器组ID时,默认广播所有子服 ''' if not GameWorld.IsCrossServer(): return - if not dataMsg: + #if not dataMsg: + # return + if serverGroupIDList == None: + serverGroupIDList = [] + + srcMsg = {"MsgType":msgType, "Data":dataMsg, "CrossServerTime":GameWorld.GetCurrentDataTimeStr()} + sendMsg = cPickle.dumps(srcMsg, 2) + if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): + GameWorld.ErrLog("跨服服务器未启动好,不允许向子服发送数据! serverGroupIDList=%s, srcMsg=%s" % (serverGroupIDList, srcMsg)) return - sendMsg = str({"MsgType":msgType, "Data":dataMsg}) - GameWorld.Log("SendMsgToClientServer => serverGroupIDList=%s, sendMsg=%s" % (serverGroupIDList, sendMsg)) + GameWorld.Log("SendMsgToClientServer => serverGroupIDList=%s, srcMsg=%s" % (serverGroupIDList, srcMsg)) if not serverGroupIDList: - GameWorld.GetGameWorld().SendBroadcastMergeClient(sendMsg) + GameWorld.GetGameWorld().SendBroadcastMergeClient(sendMsg, len(sendMsg)) else: serverGroupIDList = list(set(serverGroupIDList)) # 去重 #for serverGroupID in serverGroupIDList: - # GameWorld.GetGameWorld().SendMergeMsgToClientByGroupID(serverGroupID, sendMsg) - jsonGroupIDInfo = json.dumps(serverGroupIDList, ensure_ascii=False) - GameWorld.GetGameWorld().SendMergeMsgToClientByGroupList(jsonGroupIDInfo, sendMsg) + # GameWorld.GetGameWorld().SendMergeMsgToClientByGroupID(serverGroupID, sendMsg, len(sendMsg)) + jsonGroupIDInfo = cPickle.dumps(serverGroupIDList, 2) + GameWorld.GetGameWorld().SendMergeMsgToClientByGroupList(jsonGroupIDInfo, len(jsonGroupIDInfo), sendMsg, len(sendMsg)) return def OnClientServerReceiveMsg(index, tick): ## 子服收到跨服服务器信息 dataPack = IPY_GameServer.IPY_MGBroadcastMergeClient() dataMsg = dataPack.GetData() - #GameWorld.Log("OnClientServerReceiveMsg: %s" % dataMsg) try: - msgDict = eval(dataMsg) + if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): + GameWorld.Log("服务器未启动好,不处理跨服信息!") + return + + msgDict = cPickle.loads(dataMsg) msgType = msgDict.get("MsgType", -1) msgData = msgDict.get("Data", "") - + crossServerTimeStr = msgDict.get("CrossServerTime", "") + GameWorld.Log("OnClientServerReceiveMsg: %s" % msgDict) + if crossServerTimeStr: + curServerTime = int(time.time()) + crossServerTime = GameWorld.ChangeTimeStrToNum(crossServerTimeStr) + curServerCrossServerTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCrossServerTimeStr()) + diffSeconds = curServerCrossServerTime - crossServerTime# 本服计算误差 + + _, _, syncMapTime = PyGameData.g_crossServerTimeInfo + PyGameData.g_crossServerTimeInfo = [crossServerTime, curServerTime, syncMapTime] + if curServerTime - syncMapTime >= 600 or abs(diffSeconds) >= 30 or msgType == ShareDefine.CrossServerMsg_CrossServerTime: # 一定时间同步地图一次 或计算 误差超过30秒 或强制同步时间的 + GameWorld.DebugLog("同步地图跨服服务器时间时,本服与跨服服务器时间计算误差! diffSeconds=%s" % (diffSeconds)) + syncMapTime = curServerTime + PyGameData.g_crossServerTimeInfo = [crossServerTime, curServerTime, syncMapTime] + GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CrossServerTime, PyGameData.g_crossServerTimeInfo) + if msgType == ShareDefine.CrossServerMsg_ExitCrossServer: CrossRealmPlayer.CrossServerMsg_ExitCrossServer(msgData) elif msgType == ShareDefine.CrossServerMsg_Notify: PlayerControl.CrossServerMsg_Notify(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChatCrossWorld: + PlayerTalk.CrossServerMsg_ChatCrossWorld(msgData) elif msgType == ShareDefine.CrossServerMsg_ViewPlayerCacheRet: CrossRealmPlayer.CrossServerMsg_ViewPlayerCacheRet(msgData, tick) @@ -154,11 +336,62 @@ elif msgType == ShareDefine.CrossServerMsg_PKSyncBillboard: CrossRealmPK.CrossServerMsg_PKSyncBillboard(msgData) + elif msgType == ShareDefine.CrossServerMsg_LuckyCloudBuyLottery: + CrossLuckyCloudBuy.CrossServerMsg_LuckyCloudBuyLottery(msgData) + + elif msgType == ShareDefine.CrossServerMsg_LuckyCloudBuyNum: + CrossLuckyCloudBuy.CrossServerMsg_LuckyCloudBuyNum(msgData) + + elif msgType == ShareDefine.CrossServerMsg_BattlefieldState: + CrossBattlefield.CrossServerMsg_BattlefieldState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_BattlefieldBuy: + CrossBattlefield.CrossServerMsg_BattlefieldBuy(msgData) + + elif msgType == ShareDefine.CrossServerMsg_BattlefieldOver: + CrossBattlefield.CrossServerMsg_BattlefieldOver(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipState: + CrossChampionship.CrossServerMsg_ChampionshipState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipPlayer: + CrossChampionship.CrossServerMsg_ChampionshipPlayer(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipGroup: + CrossChampionship.CrossServerMsg_ChampionshipGroup(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipGuess: + CrossChampionship.CrossServerMsg_ChampionshipGuess(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipOfficial: + CrossChampionship.CrossServerMsg_ChampionshipOfficial(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ChampionshipDailyOfficial: + CrossChampionship.CrossServerMsg_ChampionshipDailyOfficial(msgData) + + elif msgType == ShareDefine.CrossServerMsg_ActAllRechargeInfo: + CrossActAllRecharge.CrossServerMsg_ActAllRechargeInfo(msgData) + + elif msgType == ShareDefine.CrossServerMsg_CrossDailyActionState: + CrossActionControl.CrossServerMsg_CrossDailyActionState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_CrossYaomoBossHurtInfo: + CrossYaomoBoss.CrossServerMsg_CrossYaomoBossHurtInfo(msgData) + + elif msgType == ShareDefine.CrossServerMsg_SyncBillboard: + CrossBillboard.CrossServerMsg_SyncBillboard(msgData, tick) + elif msgType == ShareDefine.CrossServerMsg_CrossBossInfo: CrossBoss.CrossServerMsg_CrossBossInfo(msgData) elif msgType == ShareDefine.CrossServerMsg_CrossBossState: CrossBoss.CrossServerMsg_CrossBossState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_CrossAssist: + PlayerAssist.CrossServerMsg_CrossAssist(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_CrossActInfo: + CrossActionControl.CrossServerMsg_CrossActInfo(msgData) elif msgType == ShareDefine.CrossServerMsg_PutInItem: CrossRealmPlayer.CrossServerMsg_PutInItem(msgData) @@ -169,19 +402,82 @@ elif msgType == ShareDefine.CrossServerMsg_DropGoodItem: GameWorldBoss.CrossServerMsg_DropGoodItem(msgData, tick) + elif msgType == ShareDefine.CrossServerMsg_NPCInfoRet: + PlayerQuery.CrossServerMsg_NPCInfoRet(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_EnterFBRet: + PlayerFB.CrossServerMsg_EnterFBRet(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_EnterVSRoomRet: + PlayerFB.CrossServerMsg_EnterVSRoomRet(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_SendMail: + PlayerCompensation.CrossServerMsg_SendMail(msgData) + + elif msgType == ShareDefine.CrossServerMsg_MailPlayerIDList: + PlayerCompensation.CrossServerMsg_MailPlayerIDList(msgData) + + elif msgType == ShareDefine.CrossServerMsg_MailContent: + PlayerCompensation.CrossServerMsg_MailContent(msgData) + + elif msgType == ShareDefine.CrossServerMsg_FBPlayerCount: + PlayerFB.CrossServerMsg_FBPlayerCount(msgData) + + # 需要发送到地图服务器处理的 + elif msgType in [ShareDefine.CrossServerMsg_RebornRet, ShareDefine.CrossServerMsg_CollectNPCOK, ShareDefine.CrossServerMsg_FBEnd, + ShareDefine.CrossServerMsg_NPCAttackCount]: + MapServer_ClientServerReceiveMsg(msgType, msgData) + elif msgType == ShareDefine.CrossServerMsg_CrossServerState: CrossRealmPlayer.CrossServerMsg_CrossServerState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_CrossServerTime: + playerID = msgData.get("PlayerID") + if playerID: + tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) + if tagPlayer: + GameWorld.DebugAnswer(tagPlayer, "跨服服务器时间: %s" % GameWorld.GetCrossServerTimeStr()) + + elif msgType == ShareDefine.CrossServerMsg_DebugAnswer: + GameWorld.CrossServerMsg_DebugAnswer(msgData) else: GameWorld.ErrLog("没有该信息类型逻辑处理!") except: - GameWorld.ErrLog("OnClientServerReceiveMsg:%s; except:%s" % (dataMsg, traceback.format_exc())) - if GameWorld.GetGameWorld().GetDebugLevel(): - raise BaseException(str(traceback.format_exc())) - + GameWorld.RaiseException("子服服务器接收信息处理报错\r\n%s" % str(traceback.format_exc())) return +def MapServer_ClientServerReceiveMsg(msgType, msgData): + ## 收到跨服服务器信息,需要发送到地图服务器处理 + + if msgType in [ShareDefine.CrossServerMsg_FBEnd]: + curServerGroupID = GameWorld.GetServerGroupID() + for tagPlayerID, msgInfo in msgData.items(): + if not msgInfo: + continue + serverGroupID = msgInfo[0] + if curServerGroupID != serverGroupID: + continue + tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) + if not tagPlayer: + continue + msgInfo = str([msgType, msgInfo[1:]]) + tagPlayer.MapServer_QueryPlayerResult(0, 0, "ClientServerReceiveMsg", msgInfo, len(msgInfo)) + + return + + if not isinstance(msgData, dict): + return + tagPlayerID = msgData.get("PlayerID") + if not tagPlayerID: + return + tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) + if not tagPlayer: + return + msgInfo = str([msgType, msgData]) + tagPlayer.MapServer_QueryPlayerResult(0, 0, "ClientServerReceiveMsg", msgInfo, len(msgInfo)) + return # 连接跨服服务器状态 # 1 为连接成功; 其他为失败,失败会延迟通知 @@ -193,12 +489,12 @@ GameWorld.GetGameWorld().SetDict(ShareDefine.Def_Notify_WorldKey_CrossServerConnState, connState) if result != 1: - GameWorld.Log("--OnClientServerReceiveMsg disconn") + GameWorld.Log("===与跨服服务器断开连接!") CrossRealmPlayer.CrossServerMsg_CrossServerState({"isOpen":0}) return - GameWorld.Log("OnConnCorossServer conn success!!!") - if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_IsGameWorldInit): + GameWorld.Log("===与跨服服务器连接成功!") + if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): GameWorld.Log(" 服务器还未启动好,暂不处理! 等服务器启动好后再处理!") return @@ -211,8 +507,12 @@ return def OnGameServerInitOK(): - ## 子服启动成功 + ## 服务器启动成功 + + tick = GameWorld.GetGameWorld().GetTick() + if GameWorld.IsCrossServer(): + Sync_CrossServerInitDataToClientServer(tick, serverGroupID=0) # 这里设置为0,广播所有子服务器组 return serverGroupID = GameWorld.GetServerGroupID() -- Gitblit v1.8.0