5722 【后端】【1.5】跨服BOSS开发(跨服聊天名字默认使用跨服名字格式)
3个文件已修改
126 ■■■■■ 已修改文件
ServerPython/CoreServerGroup/GameServer/Script/ChNetSendPack.py 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/ChNetSendPack.py
@@ -227,3 +227,101 @@
m_NAtagTalkMi=tagTalkMi()
ChNetPackDict[eval("0x%02x%02x"%(m_NAtagTalkMi.Head.Cmd,m_NAtagTalkMi.Head.SubCmd))] = m_NAtagTalkMi
#------------------------------------------------------
#02 08 国家频道#tagTalkCountry
class  tagTalkCountry(Structure):
    Head = tagHead()
    NameLen = 0    #(BYTE NameLen)
    Name = ""    #(String Name)//size = NameLen
    PlayerID = 0    #(DWORD PlayerID)
    Len = 0    #(WORD Len)
    Content = ""    #(String Content)//size = Len
    ExtraValue = 0    #(DWORD ExtraValue)//附加值
    Extras = ""    #(char Extras[256])//附加值列表
    data = None
    def __init__(self):
        self.Clear()
        self.Head.Cmd = 0x02
        self.Head.SubCmd = 0x08
        return
    def ReadData(self, _lpData, _pos=0, _Len=0):
        self.Clear()
        _pos = self.Head.ReadData(_lpData, _pos)
        self.NameLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
        self.Name,_pos = CommFunc.ReadString(_lpData, _pos,self.NameLen)
        self.PlayerID,_pos = CommFunc.ReadDWORD(_lpData, _pos)
        self.Len,_pos = CommFunc.ReadWORD(_lpData, _pos)
        self.Content,_pos = CommFunc.ReadString(_lpData, _pos,self.Len)
        self.ExtraValue,_pos = CommFunc.ReadDWORD(_lpData, _pos)
        self.Extras,_pos = CommFunc.ReadString(_lpData, _pos,256)
        return _pos
    def Clear(self):
        self.Head = tagHead()
        self.Head.Clear()
        self.Head.Cmd = 0x02
        self.Head.SubCmd = 0x08
        self.NameLen = 0
        self.Name = ""
        self.PlayerID = 0
        self.Len = 0
        self.Content = ""
        self.ExtraValue = 0
        self.Extras = ""
        return
    def GetLength(self):
        length = 0
        length += self.Head.GetLength()
        length += 1
        length += len(self.Name)
        length += 4
        length += 2
        length += len(self.Content)
        length += 4
        length += 256
        return length
    def GetBuffer(self):
        data = ''
        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
        data = CommFunc.WriteBYTE(data, self.NameLen)
        data = CommFunc.WriteString(data, self.NameLen, self.Name)
        data = CommFunc.WriteDWORD(data, self.PlayerID)
        data = CommFunc.WriteWORD(data, self.Len)
        data = CommFunc.WriteString(data, self.Len, self.Content)
        data = CommFunc.WriteDWORD(data, self.ExtraValue)
        data = CommFunc.WriteString(data, 256, self.Extras)
        return data
    def OutputString(self):
        DumpString = '''
                                Head:%s,
                                NameLen:%d,
                                Name:%s,
                                PlayerID:%d,
                                Len:%d,
                                Content:%s,
                                ExtraValue:%d,
                                Extras:%s
                                '''\
                                %(
                                self.Head.OutputString(),
                                self.NameLen,
                                self.Name,
                                self.PlayerID,
                                self.Len,
                                self.Content,
                                self.ExtraValue,
                                self.Extras
                                )
        return DumpString
m_NAtagTalkCountry=tagTalkCountry()
ChNetPackDict[eval("0x%02x%02x"%(m_NAtagTalkCountry.Head.Cmd,m_NAtagTalkCountry.Head.SubCmd))] = m_NAtagTalkCountry
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -46,7 +46,7 @@
# 获取玩家跨服服务器上的名字
def GetCrossPlayerName(curPlayer):
    # 通过游戏账号中的平台标志获取名称,目前为spid
    playerName = curPlayer.GetPlayerName()
    playerName = curPlayer.GetName()
    
    opName = ReadChConfig.GetPyMongoConfig("Merge", "OpName_%s_%s" % (GameWorld.GetPlayerPlatform(curPlayer), 
                                           GameWorld.GetPlayerServerSID(curPlayer)))
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTalk.py
@@ -200,7 +200,31 @@
    
    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
    if curPlayer:
        curPlayer.ChatCountry(content, extraValue, extras)
        PlayerChatCountry(curPlayer, content, extraValue, extras)
        #curPlayer.ChatCountry(content, extraValue, extras)
    return
def PlayerChatCountry(curPlayer, content, extraValue, extras):
    sendPack = ChNetSendPack.tagTalkCountry()
    sendPack.Clear()
    sendPack.Name = CrossRealmPlayer.GetCrossPlayerName(curPlayer)
    sendPack.NameLen = len(sendPack.Name)
    sendPack.PlayerID = curPlayer.GetPlayerID()
    sendPack.Content = content
    sendPack.Len = len(sendPack.Content)
    sendPack.ExtraValue = extraValue
    sendPack.Extras = extras
    # 全服广播在线玩家
    playerManager = GameWorld.GetPlayerManager()
    for i in xrange(playerManager.GetActivePlayerCount()):
        player = playerManager.GetActivePlayerAt(i)
        if player == None:
            continue
        if PlayerControl.GetIsTJG(player):
            continue
        NetPackCommon.SendFakePack(player, sendPack)
    return
## 公频(封包参数)