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 | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 221 insertions(+), 16 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py index 05939f6..eb0409a 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py @@ -17,23 +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 cPickle +import time def SendMsgToCrossServer(msgType, dataMsg): ## 发送信息到跨服服务器上 @@ -55,7 +73,6 @@ def OnCrossServerReceiveMsg(recvMsg, tick): ## 跨服服务器收到信息处理 try: - GameWorld.Log("收到OnCrossServerReceiveMsg" ) if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): GameWorld.Log("服务器未启动好,不处理子服信息!") return @@ -82,6 +99,9 @@ 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) @@ -93,7 +113,10 @@ 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) @@ -102,6 +125,12 @@ 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) @@ -115,6 +144,75 @@ 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]: MapServer_CrossServerReceiveMsg(msgType, msgData, serverGroupID) @@ -123,9 +221,7 @@ GameWorld.ErrLog("没有该信息类型逻辑处理!") except: - GameWorld.ErrLog("OnCrossServerReceiveMsg:%s; except:%s" % (cPickle.loads(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, tick): @@ -146,9 +242,15 @@ ''' 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): @@ -191,17 +293,19 @@ 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: - return - - srcMsg = {"MsgType":msgType, "Data":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)) @@ -223,7 +327,6 @@ dataMsg = dataPack.GetData() try: - GameWorld.Log("收到OnClientServerReceiveMsg" ) if not GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_GameWorldInitOK): GameWorld.Log("服务器未启动好,不处理跨服信息!") return @@ -231,19 +334,45 @@ 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) @@ -266,6 +395,69 @@ 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) @@ -274,6 +466,9 @@ 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) @@ -292,6 +487,9 @@ 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) @@ -313,14 +511,21 @@ 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" % (cPickle.loads(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): -- Gitblit v1.8.0