hxp
2022-03-07 56ac916d2f9398a5f7509bebbdcfc941e8fb1d16
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -28,6 +28,8 @@
import NetPackCommon
import IpyGameDataPY
import PyGameData
import PlayerDBOper
# 获取玩家跨服服务器上的名字
#===============================================================================
# def GetCrossPlayerName(curPlayer):
@@ -181,8 +183,15 @@
    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):
@@ -419,6 +428,40 @@
    PyGameData.g_crossSetPlayerAttr = {}
    return
def OnPlayerLogin(curPlayer):
    if not IsCrossServerOpen():
        return
    LoginDoUnNotifyCrossMsg(curPlayer)
    return
def MapServer_QueryCrossPlayerResult(playerID, callName, msgInfo):
    ## 同步地图跨服玩家处理信息,玩家可能不在线,缓存后等玩家上线处理,暂不考虑存档问题,服务器维护后未处理的命令将失效
    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
    if curPlayer:
        msgInfo = str(msgInfo)
        curPlayer.MapServer_QueryPlayerResult(0, 0, callName, msgInfo, len(msgInfo))
    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)
    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