hxp
16 小时以前 9d5ec7599f3abe0cebb76ce1df3c3b8c4e0aa51e
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/CrossPlayer.py
@@ -101,6 +101,8 @@
        self.__crossPlayerDict.pop(playerID, None)
        return
    
    def GetPlayerIDList(self): return self.__crossPlayerDict.keys()
def GetCrossPlayerMgr():
    mgr = PyGameData.g_crossPlayerMgr
    if mgr == None:
@@ -145,6 +147,24 @@
            crossPlayerList.append(crossPlayer)
    if crossPlayerList:
        SendFakePackToPlayerList(crossPlayerList, clientPack)
    return
def SendFackPackToServerList(clientPack, serverIDList):
    ## 给服务器范围的在线玩家发送封包
    toCrossPlayerList = []
    crossPlayerMgr = GetCrossPlayerMgr()
    playerIDList = crossPlayerMgr.GetPlayerIDList()
    for playerID in playerIDList:
        crossPlayer = crossPlayerMgr.FindCrossPlayer(playerID)
        mainServerID = crossPlayer.GetMainServerID()
        if not GameWorld.CheckServerIDInList(mainServerID, serverIDList):
            continue
        curPlayer = crossPlayer.GetPlayer()
        if curPlayer: # 有玩家,一般只有游戏服有,可视为游戏服在线,直接发送
            curPlayer.SendFakePack(clientPack.GetBuffer(), clientPack.GetLength())
            continue
        toCrossPlayerList.append(crossPlayer)
    SendFakePackToPlayerList(toCrossPlayerList, clientPack)
    return
def SendFakePackToPlayerList(crossPlayerList, clientPack):
@@ -246,7 +266,9 @@
    CrossMsg.SendToClientServer(ShareDefine.C2S_NotifyCode, dataMsg, [mainServerID], playerID)
    return
def FamilyNotify(familyID, msgMark, msgParamList=[], excludeIDList=[]):
def SendToFamilyPlayer(familyID, msgType, dataMsg, excludeIDList=[], onlyIDList=[], havePlayerCall=None):
    ## 发送给某个公会所有在线游戏服成员,跨服游戏服通用
    # @param havePlayerCall: 有curPlayer时回调函数,一般是游戏服时有,直接本服执行 func(curPlayer, familyID, dataMsg)
    family = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    if not family:
        return
@@ -257,6 +279,8 @@
    for index in range(family.GetCount()):
        member = family.GetAt(index)
        playerID = member.GetPlayerID()
        if onlyIDList and playerID not in onlyIDList:
            continue
        if excludeIDList and playerID in excludeIDList:
            continue
        crossPlayer = crossPlayerMgr.FindCrossPlayer(playerID)
@@ -265,7 +289,8 @@
            continue
        curPlayer = crossPlayer.GetPlayer()
        if curPlayer: # 有玩家,一般只有游戏服有,可视为游戏服在线,直接发送
            PlayerControl.NotifyCode(curPlayer, msgMark, msgParamList)
            if havePlayerCall:
                havePlayerCall(curPlayer, familyID, dataMsg)
            continue
        mainServerID = crossPlayer.GetMainServerID()
        if mainServerID == curServerID:
@@ -278,8 +303,22 @@
            playerIDList.append(playerID)
            
    for mainServerID, playerIDList in crossServerPlayerDict.items():
        dataMsg = {"playerIDList":playerIDList, "msgMark":msgMark, "msgParamList":msgParamList}
        CrossMsg.SendToClientServer(ShareDefine.C2S_NotifyCode, dataMsg, [mainServerID])
        sendDataMsg = {"playerIDList":playerIDList, "familyID":familyID}
        sendDataMsg.update(dataMsg)
        CrossMsg.SendToClientServer(msgType, sendDataMsg, [mainServerID])
    return
def FamilyNotify(familyID, msgMark, msgParamList=[], excludeIDList=[]):
    family = DBDataMgr.GetFamilyMgr().FindFamily(familyID)
    if not family:
        return
    def havePlayerCall(curPlayer, familyID, dataMsg):
        PlayerControl.NotifyCode(curPlayer, dataMsg["msgMark"], dataMsg["msgParamList"])
        return
    dataMsg = {"msgMark":msgMark, "msgParamList":msgParamList}
    SendToFamilyPlayer(familyID, ShareDefine.C2S_NotifyCode, dataMsg, excludeIDList, havePlayerCall=havePlayerCall)
    return
def C2S_NotifyCode(dataMsg):
@@ -360,7 +399,7 @@
    
    return
def GivePlayerResources(crossPlayer, awardItemList=None, moneyDict=None, eventName="", drDict=None):
def GivePlayerResources(crossPlayer, awardItemList=None, moneyDict=None, eventName="", drDict=None, isNotifyAward=True):
    '''给玩家资源
    @param awardItemList: 给物品列表 [[itemID,itemCnt], ...]
    @param moneyDict: 给货币 {货币类型:消耗值, ...}
@@ -375,6 +414,8 @@
        dataMsg["moneyDict"] = moneyDict
    if drDict:
        dataMsg["drDict"] = drDict
    if not isNotifyAward:
        dataMsg["isNotifyAward"] = isNotifyAward
        
    playerID = crossPlayer.GetPlayerID()
    curPlayer = crossPlayer.GetPlayer()
@@ -405,6 +446,7 @@
    awardItemList = eventData.get("awardItemList", [])
    moneyDict = eventData.get("moneyDict", {})
    drDict = eventData.get("drDict", {})
    isNotifyAward = eventData.get("isNotifyAward", True)
    
    GameWorld.DebugLog("awardItemList=%s" % awardItemList)
    if awardItemList:
@@ -418,7 +460,8 @@
        for moneyType, moneyValue in moneyDict.items():
            PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, eventName, moneyRDict)
            
    ItemControler.NotifyGiveAwardInfo(curPlayer, awardItemList, eventName, moneyInfo=moneyDict)
    if isNotifyAward:
        ItemControler.NotifyGiveAwardInfo(curPlayer, awardItemList, eventName, moneyInfo=moneyDict)
    return
def SetPlayerNomalDict(crossPlayer, setDict, isDayReset=False):