|  |  | 
 |  |  | import PyDataManager
 | 
 |  |  | import ChConfig
 | 
 |  |  | import EventReport
 | 
 |  |  | import ChPyNetSendPack
 | 
 |  |  | import NetPackCommon
 | 
 |  |  | import PlayerFamilyParty
 | 
 |  |  | import ChPyNetSendPack
 | 
 |  |  | import ShareDefine
 | 
 |  |  | 
 |  |  | import ChNetSendPack
 | 
 |  |  | import NetPackCommon
 | 
 |  |  | import PlayerGeTui
 | 
 |  |  | import PyGameData
 | 
 |  |  | 
 | 
 |  |  | import re
 | 
 |  |  | import time
 | 
 |  |  | import IpyGameDataPY
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | g_ChatMi = {}   # 离线聊天记录 {玩家ID:[信息]} 一个玩家最多8条
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  |     curCache = None
 | 
 |  |  |     tagPlayerName = ""
 | 
 |  |  |     if tagPlayer == None:
 | 
 |  |  |         curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagPlayerID)
 | 
 |  |  |         curCache = PlayerViewCache.FindViewCache(tagPlayerID)
 | 
 |  |  |         if not curCache:
 | 
 |  |  |             PlayerControl.NotifyCode(curPlayer, "CanootTalk10")
 | 
 |  |  |             return
 | 
 |  |  | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  |     if curCache:
 | 
 |  |  |         cacheDict = eval(curCache.GetPropData())
 | 
 |  |  |         cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
 | 
 |  |  |         tagPlayerName = cacheDict["Name"]
 | 
 |  |  |         
 | 
 |  |  |     talkType = sendPack.GetTalkType()
 | 
 |  |  | 
 |  |  |                 g_ChatMi[tagPlayerID].pop(0)
 | 
 |  |  |                 return
 | 
 |  |  |         
 | 
 |  |  |         PlayerGeTui.ChatMiGeTui(tagPlayerID, tagPlayerName, curPlayer.GetName())
 | 
 |  |  |         #PlayerGeTui.ChatMiGeTui(tagPlayerID, tagPlayerName, curPlayer.GetName())
 | 
 |  |  | 
 | 
 |  |  | # 登录时将离线消息下发
 | 
 |  |  | def LoginChatMi(curPlayer):
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  | def ClientServerMsg_ChatCrossWorld(serverGroupID, msgData, tick):
 | 
 |  |  |     ## 收到子服跨服世界频道聊天
 | 
 |  |  |     zoneIpyData = CrossRealmPlayer.GetCrossCommZoneIpyDataByServerGroupID(serverGroupID)
 | 
 |  |  |     zoneIpyData = CrossRealmPlayer.GetCrossZoneIpyDataByServerGroupID(0, serverGroupID)
 | 
 |  |  |     if not zoneIpyData:
 | 
 |  |  |         return
 | 
 |  |  |     serverGroupIDList = zoneIpyData.GetServerGroupIDList()
 | 
 |  |  | 
 |  |  |     extraValue = sendPack.GetExtraValue()
 | 
 |  |  |     extras = sendPack.GetExtras()
 | 
 |  |  |     curPlayer.ChatGong(content, extraValue, extras)
 | 
 |  |  |      | 
 |  |  |     #缓存
 | 
 |  |  |     DoTalkCache(0, curPlayer.GetName(), curPlayer.GetPlayerID(), content, extras)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  |     curPlayer.ChatFamily(content, extraValue, extras)
 | 
 |  |  |     #仙盟宴会答题
 | 
 |  |  |     PlayerFamilyParty.OnTalkFamily(curPlayer, content, tick)
 | 
 |  |  |     #缓存
 | 
 |  |  |     DoTalkCache(curPlayer.GetFamilyID(), curPlayer.GetName(), curPlayer.GetPlayerID(), content, extras)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  |     vipLv = player.GetVIPLv()  # 玩家vip等级
 | 
 |  |  |     GMLevel = player.GetGMLevel()
 | 
 |  |  |     job = player.GetJob()
 | 
 |  |  | 
 | 
 |  |  |     playerID = player.GetID()
 | 
 |  |  |      | 
 |  |  |     extraValueStr = ""
 | 
 |  |  |     # vip等级
 | 
 |  |  |     extraValueStr += GetTalkExtraValueStar(ShareDefine.Def_TalkExtraValue_Bit_VipLv)%vipLv
 | 
 |  |  | 
 |  |  |     extraValueStr += GetTalkExtraValueStar(ShareDefine.Def_TalkExtraValue_Bit_ServerGroupID) % PlayerControl.GetPlayerServerGroupID(player)
 | 
 |  |  |     # 等级
 | 
 |  |  |     extraValueStr += GetTalkExtraValueStar(ShareDefine.Def_TalkExtraValue_Bit_LV) % player.GetLV()
 | 
 |  |  |     # 伴侣信息
 | 
 |  |  |     coupleName, coupleJob, bridePriceMaxID = "", 1, 0
 | 
 |  |  |     couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID)
 | 
 |  |  |     if couple:
 | 
 |  |  |         coupleName = couple.GetCoupleName(playerID)
 | 
 |  |  |         coupleJob = couple.GetCoupleJob(playerID)
 | 
 |  |  |         bridePriceMaxID = couple.BridePriceMaxID
 | 
 |  |  |     extraValueStr = "%s|%s|%s|%s" % (extraValueStr, coupleName, coupleJob, bridePriceMaxID)
 | 
 |  |  |     return extraValueStr
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |     return True
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | def DoTalkCache(familyID, name, playerID, content, extras):
 | 
 |  |  |     #仙盟、世界频道聊天缓存
 | 
 |  |  |     curTime = int(time.time())
 | 
 |  |  |     saveInfo = [curTime, name, playerID, content, extras]
 | 
 |  |  |     if familyID:
 | 
 |  |  |         if familyID not in PyGameData.g_familyTalkCache:
 | 
 |  |  |             PyGameData.g_familyTalkCache[familyID] = []
 | 
 |  |  |         else:
 | 
 |  |  |             maxCnt = IpyGameDataPY.GetFuncCfg('TalkCache', 2)
 | 
 |  |  |             if maxCnt and len(PyGameData.g_familyTalkCache[familyID]) >= maxCnt:
 | 
 |  |  |                 del PyGameData.g_familyTalkCache[familyID][0]
 | 
 |  |  |         PyGameData.g_familyTalkCache[familyID].append(saveInfo)
 | 
 |  |  |     else:
 | 
 |  |  |         maxCnt = IpyGameDataPY.GetFuncCfg('TalkCache', 1)
 | 
 |  |  |         if maxCnt and len(PyGameData.g_worldTalkCache) >= maxCnt:
 | 
 |  |  |             del PyGameData.g_worldTalkCache[0]
 | 
 |  |  |         PyGameData.g_worldTalkCache.append(saveInfo)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def NotifyTalkCache(curPlayer):
 | 
 |  |  |     ##上线通知非脱机离线后的聊天缓存
 | 
 |  |  |     if PlayerControl.GetIsTJG(curPlayer):
 | 
 |  |  |         return
 | 
 |  |  |     playerID = curPlayer.GetPlayerID()
 | 
 |  |  |     unTJLogoffTime = PyGameData.g_unTJLogoffTime.get(playerID, 0)
 | 
 |  |  |      | 
 |  |  |     familyCacheList, worldCacheList = [], []
 | 
 |  |  |     familyID = curPlayer.GetFamilyID()
 | 
 |  |  |     if familyID and familyID in PyGameData.g_familyTalkCache:
 | 
 |  |  |         for curTime, name, playerID, content, extras in PyGameData.g_familyTalkCache[familyID]:
 | 
 |  |  |             if curTime < unTJLogoffTime:
 | 
 |  |  |                 continue
 | 
 |  |  |             contentInfo = ChPyNetSendPack.tagGCTalkCacheInfo()
 | 
 |  |  |             contentInfo.Clear()
 | 
 |  |  |             contentInfo.ChannelType = 2
 | 
 |  |  |             contentInfo.Name = name
 | 
 |  |  |             contentInfo.NameLen = len(name)
 | 
 |  |  |             contentInfo.PlayerID = playerID
 | 
 |  |  |             contentInfo.Time = curTime
 | 
 |  |  |             contentInfo.Content = content
 | 
 |  |  |             contentInfo.Len = len(content)
 | 
 |  |  |             contentInfo.Extras = extras
 | 
 |  |  |             familyCacheList.append(contentInfo)
 | 
 |  |  |              | 
 |  |  |     for curTime, name, playerID, content, extras in PyGameData.g_worldTalkCache:
 | 
 |  |  |         if curTime < unTJLogoffTime:
 | 
 |  |  |             continue
 | 
 |  |  |         contentInfo = ChPyNetSendPack.tagGCTalkCacheInfo()
 | 
 |  |  |         contentInfo.Clear()
 | 
 |  |  |         contentInfo.ChannelType = 1
 | 
 |  |  |         contentInfo.Name = name
 | 
 |  |  |         contentInfo.NameLen = len(name)
 | 
 |  |  |         contentInfo.PlayerID = playerID
 | 
 |  |  |         contentInfo.Time = curTime
 | 
 |  |  |         contentInfo.Content = content
 | 
 |  |  |         contentInfo.Len = len(content)
 | 
 |  |  |         contentInfo.Extras = extras
 | 
 |  |  |         worldCacheList.append(contentInfo)
 | 
 |  |  |          | 
 |  |  |     if familyCacheList:
 | 
 |  |  |         sendPack = ChPyNetSendPack.tagGCTalkCache()
 | 
 |  |  |         sendPack.Clear()
 | 
 |  |  |         sendPack.InfoList = familyCacheList
 | 
 |  |  |         sendPack.Count = len(sendPack.InfoList)
 | 
 |  |  |         NetPackCommon.SendFakePack(curPlayer, sendPack)
 | 
 |  |  |          | 
 |  |  |     if worldCacheList:
 | 
 |  |  |         sendPack = ChPyNetSendPack.tagGCTalkCache()
 | 
 |  |  |         sendPack.Clear()
 | 
 |  |  |         sendPack.InfoList = worldCacheList
 | 
 |  |  |         sendPack.Count = len(sendPack.InfoList)
 | 
 |  |  |         NetPackCommon.SendFakePack(curPlayer, sendPack)
 | 
 |  |  |     return |