From 69f530796c728e06de914d7afee2e72a618dce2c Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 19 十一月 2024 11:10:23 +0800 Subject: [PATCH] 1111 跨服榜Name2长度改为65 --- ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 353 insertions(+), 36 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py index 8291317..eb0409a 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py @@ -17,19 +17,41 @@ import GameWorld import ShareDefine +import PlayerAssist import PlayerControl +import PlayerPackData +import PlayerFuncTeam +import CrossLuckyCloudBuy import IPY_GameServer import CrossRealmPlayer +import PlayerCompensation +import PlayerActBossTrial +import PlayerActXianXiaMJ +import PlayerActGubao +import PlayerActHorsePetTrain +import CrossActionControl +import CrossActAllRecharge +import CrossFamilyFlagwar +import CrossChampionship +import CrossBattlefield +import CrossBillboard +import CrossYaomoBoss import GameWorldBoss import CrossRealmPK +import GameXiangong +import GameWorship import PlayerQuery import PlayerTalk +import PyGameData import CrossBoss import ChConfig +import ChPlayer +import PlayerFB import GMShell import traceback -import json +import cPickle +import time def SendMsgToCrossServer(msgType, dataMsg): ## 发送信息到跨服服务器上 @@ -37,16 +59,26 @@ 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", "") @@ -54,6 +86,9 @@ 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) @@ -63,24 +98,120 @@ 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_PlayerLoginout: + ChPlayer.ClientServerMsg_PlayerLoginout(serverGroupID, msgData) + 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_PullOtherPlayerPackData: + PlayerPackData.ClientServerMsg_PullOtherPlayerPackData(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_PlayerPackData: + PlayerPackData.ClientServerMsg_PlayerPackData(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 == ShareDefine.ClientServerMsg_BossTrialSubmit: + PlayerActBossTrial.ClientServerMsg_BossTrialSubmit(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_XianXiaMJScore: + PlayerActXianXiaMJ.ClientServerMsg_XianXiaMJScore(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_GubaoScore: + PlayerActGubao.ClientServerMsg_GubaoScore(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_HorsePetTrainScore: + PlayerActHorsePetTrain.ClientServerMsg_HorsePetTrainScore(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_CreateFuncTeam: + PlayerFuncTeam.ClientServerMsg_CreateFuncTeam(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_ChangeFuncTeam: + PlayerFuncTeam.ClientServerMsg_ChangeFuncTeam(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_FuncTeamMemOP: + PlayerFuncTeam.ClientServerMsg_FuncTeamMemOP(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_QueryFuncTeam: + PlayerFuncTeam.ClientServerMsg_QueryFuncTeam(serverGroupID, msgData) + + elif msgType == ShareDefine.ClientServerMsg_QueryXiangong: + GameXiangong.ClientServerMsg_QueryXiangong(serverGroupID, msgData) # 需要发送到地图服务器处理的 elif msgType in [ShareDefine.ClientServerMsg_Reborn, ShareDefine.ClientServerMsg_CollectNPC]: @@ -90,19 +221,36 @@ 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) + GameWorship.Sync_CrossWorshipToClientServer(serverGroupID) return def MapServer_CrossServerReceiveMsg(msgType, msgData, serverGroupID): @@ -129,51 +277,102 @@ 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_PlayerLoginout: + ChPlayer.CrossServerMsg_PlayerLoginout(msgData) + elif msgType == ShareDefine.CrossServerMsg_ChatCrossWorld: PlayerTalk.CrossServerMsg_ChatCrossWorld(msgData) elif msgType == ShareDefine.CrossServerMsg_ViewPlayerCacheRet: CrossRealmPlayer.CrossServerMsg_ViewPlayerCacheRet(msgData, tick) + + elif msgType == ShareDefine.CrossServerMsg_PlayerPackDataState: + PlayerPackData.CrossServerMsg_PlayerPackDataState(msgData) + + elif msgType == ShareDefine.CrossServerMsg_PullPlayerPackData: + PlayerPackData.CrossServerMsg_PullPlayerPackData(msgData) + + elif msgType == ShareDefine.CrossServerMsg_PushPlayerPackData: + PlayerPackData.CrossServerMsg_PushPlayerPackData(msgData) elif msgType == ShareDefine.CrossServerMsg_PKMatchReqRet: CrossRealmPK.CrossServerMsg_PKMatchReqRet(msgData) @@ -196,11 +395,83 @@ 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_FamilyFlagwarOver: + CrossFamilyFlagwar.CrossServerMsg_FamilyFlagwarOver(msgData) + + elif msgType == ShareDefine.CrossServerMsg_CrossBossTrialFamilyAward: + PlayerActBossTrial.CrossServerMsg_CrossBossTrialFamilyAward(msgData) + + elif msgType == ShareDefine.CrossServerMsg_FuncTeamInfo: + PlayerFuncTeam.CrossServerMsg_FuncTeamInfo(msgData) + + elif msgType == ShareDefine.CrossServerMsg_FuncTeamDel: + PlayerFuncTeam.CrossServerMsg_FuncTeamDel(msgData) + + elif msgType == ShareDefine.CrossServerMsg_FuncTeamList: + PlayerFuncTeam.CrossServerMsg_FuncTeamList(msgData) + + elif msgType == ShareDefine.CrossServerMsg_Worship: + GameWorship.CrossServerMsg_Worship(msgData) + + elif msgType == ShareDefine.CrossServerMsg_Xiangong: + GameXiangong.CrossServerMsg_Xiangong(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) @@ -214,25 +485,67 @@ 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]: + 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 @@ -256,12 +569,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 @@ -274,8 +587,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