using System; using System.Collections.Generic; using System.Text; using KKSG; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class XChatDocument : XDocComponent { public override uint ID { get { return XChatDocument.uuID; } } public XChatView ChatView { get { return DlgBase.singleton; } set { this._XChatView = value; } } public XChatSmallView ChatSmallView { get { return this._XChatSmallView; } set { this._XChatSmallView = value; } } public XChatSettingView ChatSettingView { get { return this._XChatSettingView; } set { this._XChatSettingView = value; } } public XChatMaqueeView ChatMaqueeView { get { return this._XChatMaqueeView; } set { this._XChatMaqueeView = value; } } public bool onlyDisplayTeamChannel { get { XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); bool flag = specificDocument != null; return !flag || specificDocument.GetValue(XOptionsDefine.OD_Shield_NoTeam_Chat) != 0; } } public new static readonly uint uuID = XSingleton.singleton.XHash("XChatDocument"); private XChatView _XChatView = null; private XChatSmallView _XChatSmallView = null; private XChatSettingView _XChatSettingView = null; private XChatMaqueeView _XChatMaqueeView = null; private DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); public List ChatFriendList = new List(); //confirm private static Dictionary> m_ChatDic = new Dictionary>(); private const int CHAT_MEMORY_COUNT = 200; //confirm private static List m_ChatSmallList = new List(); //confirm private static List m_ProcessListSmall = new List(); //confirm public static List offlineProcessList = new List(); public List recentSendmsg = new List(); public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); public static byte[] m_ApolloKey = new byte[1024]; public static int[] m_ApolloIPtable = new int[4]; public static bool m_ApolloInited = false; public static string m_ClientIP = "127.0.0.1"; public static int CLEAR_ENTER_AUDIO_COUNT = 5; public static bool is_delete_audio = true; public static bool m_AnswerUseApollo = true; public static bool UseApollo = true; public int getFlowerLeftTime; public bool canGetFlower; private string color_r1; private string color_r2; private string color_g; private string color_n; private string color_dg; private static ChatTable _chatTable = new ChatTable(); private static ChatOpen _chatOpenTabel = new ChatOpen(); public static ChatApollo _chatApolloTable = new ChatApollo(); private static bool[] s_commonIcons = new bool[15]; private bool firstIn = true; private const int MAX_RECNET_COUNT = 10; private const int MAX_OFFLINE_COUNT = 10; private Dictionary openTable = new Dictionary(); private Dictionary sOpenTbale = new Dictionary(); private XGuildDocument guildDoc; private XTeamDocument teamDoc; public static void Execute(OnLoadedCallback callback = null) { XChatDocument.AsyncLoader.AddTask("Table/Chat", XChatDocument._chatTable, false); XChatDocument.AsyncLoader.AddTask("Table/ChatOpen", XChatDocument._chatOpenTabel, false); XChatDocument.AsyncLoader.AddTask("Table/ChatApollo", XChatDocument._chatApolloTable, false); XChatDocument.AsyncLoader.Execute(callback); } public ChatTable.RowData GetRawData(ChatChannelType type) { int num = XFastEnumIntEqualityComparer.ToInt(type); for (int i = 0; i < XChatDocument._chatTable.Table.Length; i++) { bool flag = (ulong)XChatDocument._chatTable.Table[i].id == (ulong)((long)num); if (flag) { return XChatDocument._chatTable.Table[i]; } } return XChatDocument._chatTable.Table[0]; } public ChatApollo.RowData GetApollo(int speak, int music, int click) { int num = 100 * speak + 10 * music + click; for (int i = 0; i < XChatDocument._chatApolloTable.Table.Length; i++) { ChatApollo.RowData rowData = XChatDocument._chatApolloTable.Table[i]; int num2 = 100 * rowData.speak + 10 * rowData.music + rowData.click; bool flag = num2 == num; if (flag) { return rowData; } } return null; } protected override void EventSubscribe() { base.EventSubscribe(); } public override void OnEnterSceneFinally() { base.OnEnterSceneFinally(); DlgBase.singleton.cacheShow = false; bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; if (flag) { XSingleton.singleton.EnableAutoPlay(true); } bool flag2 = this.recentSendmsg.Count <= 0; if (flag2) { this.recentSendmsg = XSingleton.singleton.GetStringList("ChatArray"); } bool flag3 = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; if (flag3) { bool flag4 = !XChatDocument.m_ApolloInited; if (flag4) { RpcC2G_QueryClientIp rpc = new RpcC2G_QueryClientIp(); XSingleton.singleton.Send(rpc); } DlgBase.singleton.CheckShow(); XChatDocument.m_AnswerUseApollo = (int.Parse(XSingleton.singleton.GetValue("UseApollo")) == 1); DlgBase.singleton.SetMaqueeSwitch(true); } } public override void OnGamePause(bool pause) { base.OnGamePause(pause); DlgBase.singleton.OnFouceGame(pause); bool flag = !pause; if (flag) { DlgBase.singleton.ResumeReplay(); } DlgBase.singleton.OnScreenLock(pause); } public override void OnLeaveScene() { base.OnLeaveScene(); bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.SetVisibleWithAnimation(false, null); } XSingleton.singleton.OnCloseWebView(); } protected override void OnReconnected(XReconnectedEventArgs arg) { } public override void PostUpdate(float fDeltaT) { bool flag = this.ChatMaqueeView != null; if (flag) { this.ChatMaqueeView.UpdateMaquee(fDeltaT); } } public override void Update(float fDeltaT) { bool flag = XChatDocument.m_ProcessListSmall.Count > 0; if (flag) { for (int i = 0; i < XChatDocument.m_ProcessListSmall.Count; i++) { this.AddSmallChatInfo(XChatDocument.m_ProcessListSmall[i]); } DlgBase.singleton.OnReceieveChatInfos(XChatDocument.m_ProcessListSmall); XChatDocument.m_ProcessListSmall.Clear(); } } private void HanderSereverChatinfo(KKSG.ChatInfo info) { bool flag = info == null; if (!flag) { bool flag2 = info.source != null; if (flag2) { bool flag3 = !DlgBase.singleton.IsBlock(info.source.roleid); if (flag3) { this.HandlerReceiveChatInfo(info); } } else { bool flag4 = info != null && XSingleton.singleton.XPlayerData != null && info.level <= XSingleton.singleton.XPlayerData.Level; if (flag4) { this.HandlerReceiveChatInfo(info); } } } } public override void OnAttachToHost(XObject host) { base.OnAttachToHost(host); int @int = XSingleton.singleton.GetInt("BroadcastOpen"); PlayerPrefs.SetInt("BroadcastOpen", @int); XChatDocument.is_delete_audio = (int.Parse(XSingleton.singleton.GetValue("IsDeleteAudio")) == 1); this.color_r1 = XSingleton.singleton.GetValue("Chat_R1"); this.color_r2 = XSingleton.singleton.GetValue("Chat_R2"); this.color_g = XSingleton.singleton.GetValue("Chat_G"); this.color_n = XSingleton.singleton.GetValue("Chat_N"); this.color_dg = XSingleton.singleton.GetValue("Chat_DG"); } public override void OnDetachFromHost() { this.OnClearAllData(); this.firstIn = true; DlgBase.singleton.StopBroad(); DlgBase.singleton.OnStopClick(null); } public void SendOfflineMsg() { bool flag = this.firstIn; if (flag) { this.ClearAllData(); PtcC2M_LoadOfflineChatNtf ptcC2M_LoadOfflineChatNtf = new PtcC2M_LoadOfflineChatNtf(); ptcC2M_LoadOfflineChatNtf.Data.roleID = XSingleton.singleton.XPlayerData.RoleID; XSingleton.singleton.Send(ptcC2M_LoadOfflineChatNtf); this.firstIn = false; } } public void ClearRoleMsg(ulong roleid) { List list; XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.World, out list); List list2; XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Guild, out list2); List list3; XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Team, out list3); List list4; XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Spectate, out list4); List list5; XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Friends, out list5); bool flag = list != null; if (flag) { this.RemveRoleMsg(roleid, list); } bool flag2 = list2 != null; if (flag2) { this.RemveRoleMsg(roleid, list2); } bool flag3 = list3 != null; if (flag3) { this.RemveRoleMsg(roleid, list3); } bool flag4 = list4 != null; if (flag4) { this.RemveRoleMsg(roleid, list4); } bool flag5 = list5 != null; if (flag5) { this.RemveRoleMsg(roleid, list5); } bool flag6 = XChatDocument.offlineProcessList != null; if (flag6) { this.RemveRoleMsg(roleid, XChatDocument.offlineProcessList); } bool flag7 = XChatDocument.m_ChatSmallList != null; if (flag7) { this.RemveRoleMsg(roleid, XChatDocument.m_ChatSmallList); } bool flag8 = XChatDocument.m_ProcessListSmall != null; if (flag8) { this.RemveRoleMsg(roleid, XChatDocument.m_ProcessListSmall); } this.ChatView.RefreshLoopScroll(this.ChatView.activeChannelType); bool flag9 = this.ChatSmallView.IsVisible(); if (flag9) { this.ChatSmallView.ShowCacheMsg(); } } private void RemveRoleMsg(ulong roleid, List list) { bool flag = list != null; if (flag) { for (int i = list.Count - 1; i >= 0; i--) { bool flag2 = list[i].mSenderId == roleid; if (flag2) { list.RemoveAt(i); } } } } public void ReceiveOfflineMsg(PtcM2C_MCChatOffLineNotify roPtc) { DlgBase.singleton.CacheMsg(); List list = new List(); bool flag = !DlgBase.singleton.IsInited; if (flag) { for (int i = 0; i < roPtc.Data.rolechat.Count; i++) { list.Add(roPtc.Data.rolechat[i]); } for (int j = 0; j < roPtc.Data.guildchat.Count; j++) { list.Add(roPtc.Data.guildchat[j]); } for (int k = 0; k < roPtc.Data.teamchat.Count; k++) { list.Add(roPtc.Data.teamchat[k]); } for (int l = 0; l < roPtc.Data.worldchat.Count; l++) { list.Add(roPtc.Data.worldchat[l]); } for (int m = 0; m < roPtc.Data.partnerchat.Count; m++) { list.Add(roPtc.Data.partnerchat[m]); } for (int n = 0; n < roPtc.Data.groupchat.Count; n++) { list.Add(roPtc.Data.groupchat[n]); } list.Sort(new Comparison(this.SortOfflineData)); for (int num = 0; num < list.Count; num++) { this.HanderSereverChatinfo(list[num]); } this.HandlerOfflineFriend(roPtc.Data.privatechatlist); } } private int SortOfflineData(KKSG.ChatInfo x, KKSG.ChatInfo y) { return x.time.CompareTo(y.time); } public void OnReceiveChatInfo(KKSG.ChatInfo info) { this.HanderSereverChatinfo(info); } private ChatFriendData Chatinfo2FriendData(ChatSource friend, uint time) { return new ChatFriendData { isfriend = DlgBase.singleton.IsMyFriend(friend.roleid), name = friend.name, powerpoint = friend.powerpoint, profession = friend.profession, viplevel = friend.viplevel, roleid = friend.roleid, setid = ((friend.pre != null) ? friend.pre.setid : new List()), msgtime = this.startTime.AddSeconds(time) }; } private void HandlerOfflineFriend(PrivateChatList friends) { bool flag = friends != null && friends.rolelist != null; if (flag) { for (int i = 0; i < friends.rolelist.Count; i++) { ChatFriendData chatFriendData = new ChatFriendData(); XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; bool flag2 = friends.rolelist[i] != null && xplayerData != null && friends.rolelist[i].roleid != xplayerData.RoleID; if (flag2) { chatFriendData = this.Chatinfo2FriendData(friends.rolelist[i], friends.lastChatTime[i]); chatFriendData.hasOfflineRead = friends.hasOfflineChat[i]; this.ChatFriendList.Add(chatFriendData); } } } this.RemoveBlockFriends(); } public void SetFriendRelation(ulong uid, bool isfriend) { for (int i = 0; i < this.ChatFriendList.Count; i++) { bool flag = this.ChatFriendList[i].roleid == uid; if (flag) { this.ChatFriendList[i].isfriend = isfriend; break; } } } public void OnReceiveChatSmallInfo(XMainClient.ChatInfo info) { bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.World && this.onlyDisplayTeamChannel && info.mChannelId != ChatChannelType.Team && info.mChannelId != ChatChannelType.Curr && info.mChannelId != ChatChannelType.Battle; if (!flag) { XChatDocument.m_ProcessListSmall.Add(info); } } private void CacheRecentSendmsg(string str) { bool flag = !this.recentSendmsg.Contains(str); if (flag) { bool flag2 = this.recentSendmsg.Count > 10; if (flag2) { this.recentSendmsg.RemoveAt(0); } this.recentSendmsg.Add(str); } } private void CacheRecentChatinfo(XMainClient.ChatInfo info) { bool flag = XChatDocument.offlineProcessList.Count > 10; if (flag) { XChatDocument.offlineProcessList.RemoveRange(0, XChatDocument.offlineProcessList.Count - 10); } XChatDocument.offlineProcessList.Add(info); } public bool OnJoinTeam(XEventArgs args) { return true; } public bool OnLeaveTeam(XEventArgs args) { return true; } public ChatFriendData FindFriendData(ulong uid) { for (int i = 0; i < this.ChatFriendList.Count; i++) { bool flag = this.ChatFriendList[i].roleid == uid; if (flag) { return this.ChatFriendList[i]; } } return null; } public void RemoveBlockFriends() { for (int i = this.ChatFriendList.Count - 1; i >= 0; i--) { ChatFriendData chatFriendData = this.ChatFriendList[i]; bool flag = DlgBase.singleton.IsBlock(chatFriendData.roleid); if (flag) { this.ChatFriendList.RemoveAt(i); } } } public void RemoveFriend(ulong uid) { this.SetFriendRelation(uid, false); } public void RemoveStranger(ulong uid) { this.SetFriendRelation(uid, true); } public void AddStranger(ulong uid) { this.SetFriendRelation(uid, false); } public List GetChatInfoList(ChatChannelType channelType) { List result = null; XChatDocument.m_ChatDic.TryGetValue(channelType, out result); return result; } public DateTime GetFriendChatInfoTime(ulong uid) { DateTime dateTime = DateTime.Today; List friendChatInfoList = this.GetFriendChatInfoList(uid); for (int i = 0; i < friendChatInfoList.Count; i++) { bool flag = friendChatInfoList[i].mTime.CompareTo(dateTime) > 0; if (flag) { dateTime = friendChatInfoList[i].mTime; } } return dateTime; } public List GetFriendChatInfoList(ulong uid) { List list = null; List list2 = new List(); XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Friends, out list); bool flag = list != null; if (flag) { for (int i = 0; i < list.Count; i++) { XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; bool flag2 = xplayerData != null; if (flag2) { bool flag3 = list[i].mSenderId == xplayerData.RoleID && list[i].mReceiverId == uid; bool flag4 = list[i].mReceiverId == xplayerData.RoleID && list[i].mSenderId == uid; bool flag5 = flag4 || flag3; if (flag5) { list2.Add(list[i]); } } } } return list2; } public List GetGroupChatInfoList(ulong groupid) { List list = null; List list2 = new List(); XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Group, out list); bool flag = list != null; if (flag) { int i = 0; int count = list.Count; while (i < count) { bool flag2 = list[i].group != null && list[i].group.groupchatID == groupid; if (flag2) { list2.Add(list[i]); } i++; } } return list2; } public XMainClient.ChatInfo GetChatInfoById(int id) { List list = null; for (ChatChannelType chatChannelType = ChatChannelType.World; chatChannelType <= ChatChannelType.ChannelNum; chatChannelType++) { XChatDocument.m_ChatDic.TryGetValue(chatChannelType, out list); bool flag = list != null; if (flag) { for (int i = 0; i < list.Count; i++) { bool flag2 = list[i].id == id; if (flag2) { return list[i]; } } } } return null; } private string ReplaceRoleName(string name) { bool flag = name.Length > 3; if (flag) { name = name.Remove(name.Length - 2, 2); name = name.Insert(name.Length, "**"); } else { bool flag2 = name.Length == 3; if (flag2) { name = name.Remove(name.Length - 1, 1); name = name.Insert(name.Length, "*"); } } return name; } public string ProcessText(KKSG.ChatInfo serverChatInfo) { int num = 0; int num2 = XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System); int num3 = XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System); for (int i = 0; i < serverChatInfo.param.Count; i++) { ChatParam chatParam = serverChatInfo.param[i]; bool flag = chatParam == null; if (!flag) { for (int j = 0; j < serverChatInfo.info.Length; j++) { bool flag2 = serverChatInfo.info[j] == '$' && serverChatInfo.info.Length >= j + 2; if (flag2) { string text = ""; bool flag3 = chatParam.role != null && serverChatInfo.info[j + 1] == 'R'; if (flag3) { string name = chatParam.role.name; bool flag4 = (long)XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel); if (flag4) { text = name; } else { bool flag5 = chatParam.role.uniqueid == XSingleton.singleton.XPlayerData.RoleID; if (flag5) { text = this.color_r1 + name + "[-]"; } else { text = this.color_r2 + name + "[-]"; } } num = (int)(chatParam.role.profession % 10u - 1u); } else { bool flag6 = chatParam.item != null && serverChatInfo.info[j + 1] == 'I'; if (flag6) { ItemList.RowData itemConf = XBagDocument.GetItemConf((int)chatParam.item.item.itemID); bool flag7 = itemConf == null; if (flag7) { XSingleton.singleton.AddErrorLog("itemid: ", chatParam.item.item.itemID.ToString(), " content:", serverChatInfo.info, null, null); } else { bool flag8 = (long)XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel); if (flag8) { bool flag9 = itemConf != null; if (flag9) { bool flag10 = XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemName.Length > num; if (flag10) { text = chatParam.item.item.itemCount.ToString() + itemConf.NumberName + itemConf.ItemName[num]; } else { text = chatParam.item.item.itemCount.ToString() + itemConf.NumberName + itemConf.ItemName[0]; } } } else { int itemQuality = (int)XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemQuality; string itemQualityColorStr = XSingleton.singleton.GetItemQualityColorStr(itemQuality); bool flag11 = itemConf != null; if (flag11) { bool flag12 = XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemName.Length > 1; if (flag12) { text = string.Concat(new string[] { "[", itemQualityColorStr, "]", chatParam.item.item.itemCount.ToString(), itemConf.NumberName, itemConf.ItemName[num], "[-]" }); } else { text = string.Concat(new string[] { "[", itemQualityColorStr, "]", chatParam.item.item.itemCount.ToString(), itemConf.NumberName, itemConf.ItemName[0], "[-]" }); } } } } } else { bool flag13 = chatParam.num != null && serverChatInfo.info[j + 1] == 'N'; if (flag13) { bool flag14 = (long)XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel); if (flag14) { text = chatParam.num.num.ToString(); } else { text = this.color_n + chatParam.num.num.ToString() + "[-]"; } } else { bool flag15 = chatParam.team != null && serverChatInfo.info[j + 1] == 'T'; if (flag15) { text = XLabelSymbolHelper.FormatTeam(chatParam.team.teamname, (int)chatParam.team.teamid, chatParam.team.expeditionid); } else { bool flag16 = chatParam.guild != null && serverChatInfo.info[j + 1] == 'G'; if (flag16) { text = this.color_g + chatParam.guild.guildname.ToString() + "[-]"; } else { bool flag17 = chatParam.link != null && serverChatInfo.info[j + 1] == 'L'; if (flag17) { XInvitationDocument specificDocument = XDocuments.GetSpecificDocument(XInvitationDocument.uuID); text = specificDocument.ParseLink(chatParam); } else { bool flag18 = chatParam.dragonguild != null && serverChatInfo.info[j + 1] == 'D'; if (flag18) { text = this.color_dg + chatParam.dragonguild.dragonguildname.ToString() + "[-]"; } } } } } } } string value = serverChatInfo.info.Substring(0, j); string value2 = serverChatInfo.info.Substring(j + 2, serverChatInfo.info.Length - (j + 2)); text = text.Replace("$", "%^&%"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(value); stringBuilder.Append(text); stringBuilder.Append(value2); serverChatInfo.info = stringBuilder.ToString(); break; } } } } return serverChatInfo.info.Replace("%^&%", "$"); } private ulong GetFriendID(XMainClient.ChatInfo chatInfo) { XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; bool flag = xplayerData != null && chatInfo != null; ulong result; if (flag) { result = ((chatInfo.mSenderId != xplayerData.RoleID) ? chatInfo.mSenderId : chatInfo.mReceiverId); } else { result = 0UL; } return result; } public void RefreshSelfMemberPriviligeInfo(uint payMemberID) { List list = new List { ChatChannelType.World, ChatChannelType.Guild, ChatChannelType.Curr, ChatChannelType.Team }; for (int i = 0; i < list.Count; i++) { List list2 = null; XChatDocument.m_ChatDic.TryGetValue(list[i], out list2); bool flag = list2 != null; if (flag) { for (int j = 0; j < list2.Count; j++) { bool isSelfSender = list2[j].isSelfSender; if (isSelfSender) { list2[j].mSenderPaymemberid = payMemberID; } } this.ChatView.RefreshLoopScroll(list[i]); } } } public List AddChatInfo(XMainClient.ChatInfo chatInfo, ChatChannelType channelId) { List list = null; XChatDocument.m_ChatDic.TryGetValue(channelId, out list); bool flag = list == null; if (flag) { list = new List(); list.Add(chatInfo); XChatDocument.m_ChatDic.Add(channelId, list); } else { bool flag2 = list.Count > 200; if (flag2) { list.RemoveAt(0); } list.Add(chatInfo); } bool flag3 = channelId == ChatChannelType.Friends; if (flag3) { ulong friendID = this.GetFriendID(chatInfo); ChatFriendData chatFriendData = this.FindFriendData(friendID); bool flag4 = chatFriendData == null && DlgBase.singleton.IsInited; if (flag4) { this.AddChatinfo2FriendList(chatInfo); } bool flag5 = chatFriendData != null; if (flag5) { chatFriendData.msgtime = DateTime.Now; } list = this.GetFriendChatInfoList(this.ChatView.ChatFriendId); } else { bool flag6 = channelId == ChatChannelType.Group; if (flag6) { GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); specificDocument.AddChat2Group(chatInfo); } } return list; } public void AddChatinfo2FriendList(XMainClient.ChatInfo info) { ChatFriendData chatFriendData = new ChatFriendData(); chatFriendData.msgtime = info.mTime; bool flag = !info.isSelfSender; if (flag) { chatFriendData.name = info.mSenderName; chatFriendData.roleid = info.mSenderId; chatFriendData.powerpoint = info.mSenderPowerPoint; chatFriendData.profession = info.mServerProfession; chatFriendData.viplevel = info.mSenderVip; chatFriendData.setid = ((info.payConsume != null) ? info.payConsume.setid : new List()); bool flag2 = info.payConsume != null; if (flag2) { chatFriendData.setid = info.payConsume.setid; } chatFriendData.isfriend = DlgBase.singleton.IsMyFriend(info.mSenderId); } else { chatFriendData.name = info.mReceiverName; chatFriendData.roleid = info.mReceiverId; chatFriendData.powerpoint = info.mReciverPowerPoint; chatFriendData.profession = info.mRecieverProfession; chatFriendData.viplevel = info.mReceiverVip; chatFriendData.isfriend = DlgBase.singleton.IsMyFriend(info.mReceiverId); } bool flag3 = !this.ContainRole(chatFriendData.roleid); if (flag3) { this.ChatFriendList.Add(chatFriendData); } } private bool ContainRole(ulong roleID) { for (int i = 0; i < this.ChatFriendList.Count; i++) { bool flag = this.ChatFriendList[i].roleid == roleID; if (flag) { return true; } } return false; } private void HandlerMaqueeInfo(KKSG.ChatInfo serverChatInfo) { for (int i = 0; i < serverChatInfo.param.Count; i++) { ChatParam chatParam = serverChatInfo.param[i]; bool flag = chatParam == null; if (!flag) { for (int j = 0; j < serverChatInfo.info.Length; j++) { bool flag2 = serverChatInfo.info[j] == '$' && serverChatInfo.info.Length >= j + 2; if (flag2) { bool flag3 = chatParam.role != null && serverChatInfo.info[j + 1] == 'R'; if (flag3) { chatParam.role.name = this.ReplaceRoleName(chatParam.role.name); } } } } } } public void HandlerReceiveChatInfo(KKSG.ChatInfo serverChatInfo) { bool flag = serverChatInfo.info == null || serverChatInfo.info == "" || XSingleton.singleton.XPlayerData == null; if (!flag) { string info = serverChatInfo.info; bool flag2 = serverChatInfo.channel == 5u || serverChatInfo.channel == 6u; if (flag2) { this.HandlerMaqueeInfo(serverChatInfo); serverChatInfo.info = this.ProcessText(serverChatInfo); DlgBase.singleton.ReceiveChatInfo(serverChatInfo); serverChatInfo.channel = (uint)XFastEnumIntEqualityComparer.ToInt(ChatChannelType.System); serverChatInfo.info = info; } serverChatInfo.info = this.ProcessText(serverChatInfo); XMainClient.ChatInfo chatInfo = new XMainClient.ChatInfo(); chatInfo.mTime = this.startTime.AddSeconds(serverChatInfo.time); chatInfo.mAudioId = serverChatInfo.audioUid; chatInfo.mAudioTime = serverChatInfo.audioLen; chatInfo.voice = chatInfo.GetVoice(serverChatInfo.audioUid, serverChatInfo.audioLen); chatInfo.mRegression = false; chatInfo.CampDuelID = 0u; chatInfo.isAudioPlayed = !DlgBase.singleton.IsInited; chatInfo.isUIShowed = !DlgBase.singleton.IsInited; bool flag3 = serverChatInfo.source != null; if (flag3) { chatInfo.mSenderName = serverChatInfo.source.name.TrimEnd(new char[0]); chatInfo.mSenderId = serverChatInfo.source.roleid; chatInfo.mSenderVip = serverChatInfo.source.viplevel; chatInfo.mSenderPaymemberid = serverChatInfo.source.paymemberid; chatInfo.mServerProfession = serverChatInfo.source.profession; chatInfo.mSenderPowerPoint = serverChatInfo.source.powerpoint; chatInfo.mCoverDesignationID = serverChatInfo.source.coverDesignationID; chatInfo.mSpecialDesignation = serverChatInfo.source.desname; chatInfo.militaryRank = serverChatInfo.source.military_rank; chatInfo.payConsume = serverChatInfo.source.pre; chatInfo.mHeroID = serverChatInfo.source.heroid; chatInfo.group = serverChatInfo.groupchatinfo; chatInfo.mRegression = serverChatInfo.source.isBackFlow; chatInfo.CampDuelID = serverChatInfo.source.campDuelID; } else { bool flag4 = serverChatInfo.channel == 7u && this.CheckTeam(); if (flag4) { chatInfo.mSenderId = 0UL; chatInfo.mSenderName = XStringDefineProxy.GetString("CHAT_TEAM_NEW"); chatInfo.mSenderVip = 1u; chatInfo.mSenderPaymemberid = 0u; } else { bool flag5 = serverChatInfo.channel == 2u && this.CheckGuild(); if (flag5) { chatInfo.mSenderId = 0UL; chatInfo.mSenderName = XStringDefineProxy.GetString("CHAT_GUILD_NEW"); chatInfo.mSenderVip = 1u; chatInfo.mSenderPaymemberid = 0u; } } } bool flag6 = serverChatInfo.destList != null && serverChatInfo.destList.Count > 0; if (flag6) { chatInfo.mReceiverId = serverChatInfo.destList[0].roleid; chatInfo.mReceiverName = serverChatInfo.destList[0].name; chatInfo.mReceiverVip = serverChatInfo.destList[0].viplevel; chatInfo.mRecieverProfession = serverChatInfo.destList[0].profession; chatInfo.mReciverPowerPoint = serverChatInfo.destList[0].powerpoint; } else { bool flag7 = serverChatInfo.dest != null && serverChatInfo.dest.roleid.Count > 0; if (flag7) { chatInfo.mReceiverId = serverChatInfo.dest.roleid[0]; } } chatInfo.mContent = serverChatInfo.info; chatInfo.mChannelId = (ChatChannelType)serverChatInfo.channel; bool flag8 = chatInfo.mSenderId == XSingleton.singleton.XPlayerData.RoleID; if (flag8) { chatInfo.isSelfSender = true; chatInfo.mChatType = (chatInfo.isAudioChat ? ChatType.SelfVoice : ChatType.SelfText); } else { chatInfo.isSelfSender = false; chatInfo.mChatType = (chatInfo.isAudioChat ? ChatType.OtherVoice : ChatType.OtherText); } this.ReceiveChatInfo(chatInfo); } } public void ReceiveChatInfo(XMainClient.ChatInfo chatInfo) { bool flag = chatInfo.isAudioChat && !chatInfo.isAudioPlayed; if (flag) { bool isSelfSender = chatInfo.isSelfSender; if (isSelfSender) { XSingleton.singleton.StopAutoPlay(); XSingleton.singleton.InsertAutoPlayList(chatInfo, true); return; } bool isAutoPlayEnable = XSingleton.singleton.IsAutoPlayEnable; if (isAutoPlayEnable) { bool flag2 = XSingleton.singleton.AddAutoPlayList(chatInfo); bool flag3 = !flag2; if (!flag3) { return; } chatInfo.isAudioPlayed = true; } chatInfo.isAudioPlayed = true; } bool isInited = DlgBase.singleton.IsInited; if (isInited) { this.OnReceiveChatSmallInfo(chatInfo); bool flag4 = chatInfo.isSelfSender && !chatInfo.isAudioChat && !chatInfo.mContent.Contains("tm=") && !chatInfo.mContent.Contains("gd=") && !chatInfo.mContent.Contains("ui=") && !chatInfo.mContent.Contains("sp="); if (flag4) { this.CacheRecentSendmsg(chatInfo.mContent); } XEntity entity = XSingleton.singleton.GetEntity(chatInfo.mSenderId); bool flag5 = entity != null; if (flag5) { XCharacterShowChatComponent xcharacterShowChatComponent = entity.GetXComponent(XCharacterShowChatComponent.uuID) as XCharacterShowChatComponent; bool flag6 = xcharacterShowChatComponent != null; if (flag6) { xcharacterShowChatComponent.AttachChatBubble(); } bool flag7 = xcharacterShowChatComponent != null; if (flag7) { xcharacterShowChatComponent.DealWithChat(chatInfo.mContent); } } DlgBase.singleton.RealPush(chatInfo); } this.CacheRecentChatinfo(chatInfo); List list = this.AddChatInfo(chatInfo, chatInfo.mChannelId); bool flag8 = chatInfo.mChannelId == ChatChannelType.Friends; if (flag8) { DlgBase.singleton.ShowTabFriendRed(); } bool flag9 = !this.ChatView.IsInited || !this.ChatView.IsVisible() || chatInfo.mChannelId != this.ChatView.activeChannelType; if (!flag9) { bool flag10 = chatInfo.mContent.IndexOf("\\n") != -1; if (flag10) { chatInfo.mContent = chatInfo.mContent.Replace("\\n", "/n"); } this.ChatView.RefreshLoopScroll(this.ChatView.activeChannelType); } } public void ClearFriendMsg(ulong roleid) { bool flag = roleid == 0UL; if (flag) { this.ChatFriendList.Clear(); } else { for (int i = 0; i < this.ChatFriendList.Count; i++) { bool flag2 = this.ChatFriendList[i].roleid == roleid; if (flag2) { this.ChatFriendList.RemoveAt(i); } } } } public List GetSmallChatList() { return XChatDocument.m_ChatSmallList; } public void RestrainSmallChatInfoNum() { bool flag = (long)XChatDocument.m_ChatSmallList.Count > (long)((ulong)XChatSmallBehaviour.m_MaxShowMsg); if (flag) { XChatDocument.m_ChatSmallList.RemoveRange(0, XChatDocument.m_ChatSmallList.Count - (int)XChatSmallBehaviour.m_MaxShowMsg); } } //confirm public void AddSmallChatInfo(XMainClient.ChatInfo info) { XChatDocument.m_ChatSmallList.Add(info); } public void OnClearAllData() { this.ClearAllData(); XSingleton.singleton.EnableAutoPlay(false); XSingleton.singleton.StopAutoPlay(); XSingleton.singleton.ClearPlayList(); DlgBase.singleton.IsInited = false; DlgBase.singleton.ChatFriendId = 0UL; } private void ClearAllData() { List list = new List(XChatDocument.m_ChatDic.Keys); for (int i = 0; i < list.Count; i++) { List list2 = XChatDocument.m_ChatDic[list[i]]; bool flag = list2 != null; if (flag) { list2.Clear(); } } XChatDocument.m_ChatSmallList.Clear(); XChatDocument.offlineProcessList.Clear(); XChatDocument.m_ChatDic.Clear(); XChatDocument.m_ProcessListSmall.Clear(); } private ChatOpen.RowData ChatOpenRow(int type) { bool flag = this.openTable.Count <= 0; if (flag) { this.sOpenTbale.Clear(); for (int i = 0; i < XChatDocument._chatOpenTabel.Table.Length; i++) { bool flag2 = XChatDocument._chatOpenTabel.Table[i].sceneid == 0u; if (flag2) { this.openTable.Add((int)XChatDocument._chatOpenTabel.Table[i].id, XChatDocument._chatOpenTabel.Table[i]); } else { bool flag3 = !this.sOpenTbale.ContainsKey(XChatDocument._chatOpenTabel.Table[i].sceneid); if (flag3) { this.sOpenTbale.Add(XChatDocument._chatOpenTabel.Table[i].sceneid, XChatDocument._chatOpenTabel.Table[i]); } } } } uint sceneID = XSingleton.singleton.SceneID; bool flag4 = type < 100 && this.sOpenTbale.ContainsKey(sceneID); ChatOpen.RowData result; if (flag4) { result = this.sOpenTbale[sceneID]; } else { bool flag5 = this.openTable.ContainsKey(type); if (flag5) { result = this.openTable[type]; } else { XSingleton.singleton.AddErrorLog("找胡博聃,配chatopen表! new scenetype:", type.ToString(), null, null, null, null); result = this.openTable[1]; } } return result; } public List SortCommonIcons(int type) { List list = new List(this.ChatOpenRow(type).opens); bool flag = this.CheckGuild(); bool flag2 = this.CheckTeam(); bool flag3 = this.CheckLevelLimit(ChatChannelType.World); bool flag4 = list.Contains(1) && !flag3; if (flag4) { list.Remove(1); } bool flag5 = list.Contains(2) && !flag; if (flag5) { list.Remove(2); } bool flag6 = list.Contains(7) && !flag2; if (flag6) { list.Remove(7); } return list; } public ChatOpen.RowData GetYuyinRaw(int type) { return this.ChatOpenRow(type); } public ChatOpen.RowData GetBattleRaw() { return this.GetYuyinRaw((int)XSingleton.singleton.SceneType); } public List FetchFriendsIcons() { this.ChatFriendList.Sort(XSingleton.singleton.CompareNewMsgCb); return this.ChatFriendList; } public uint GetChatMaxFriendCount(int type) { return this.ChatOpenRow(type).friends; } public bool CheckLevelLimit(ChatChannelType type) { int key = XFastEnumIntEqualityComparer.ToInt(type); XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; bool flag = xplayerData != null; return flag && XChatDocument._chatTable.GetByid((uint)key).level <= xplayerData.Level; } public bool CheckGuild() { bool flag = this.guildDoc == null; if (flag) { this.guildDoc = XDocuments.GetSpecificDocument(XGuildDocument.uuID); } return this.guildDoc.bInGuild; } public bool CheckTeam() { bool flag = this.teamDoc == null; if (flag) { this.teamDoc = XDocuments.GetSpecificDocument(XTeamDocument.uuID); } return this.teamDoc.MyTeam != null && this.teamDoc.MyTeam.teamBrief.teamID != 0; } public void ReqGetFlowerLeftTime() { RpcC2G_GetFlowerLeftTime rpc = new RpcC2G_GetFlowerLeftTime(); XSingleton.singleton.Send(rpc); } public void OnGetFlowerLeftTime(GetFlowerLeftTimeRes oRes) { bool flag = oRes.errorCode == ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.GetFlowerRemainTime = (float)oRes.leftTime; this.getFlowerLeftTime = oRes.leftTime; this.canGetFlower = oRes.canGet; bool flag2 = !oRes.canGet; if (flag2) { this.getFlowerLeftTime = 0; } DlgBase.singleton.OnRefreshGetFlowerInfo(); } } public void ReqGetFlower() { RpcC2G_GetFlower rpc = new RpcC2G_GetFlower(); XSingleton.singleton.Send(rpc); } public void OnGetFlower(GetFlowerRes oRes) { bool flag = oRes.errorCode == ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.GetFlowerRemainTime = (float)oRes.leftTime; this.getFlowerLeftTime = oRes.leftTime; this.canGetFlower = oRes.canGet; bool flag2 = !oRes.canGet; if (flag2) { this.getFlowerLeftTime = 0; } DlgBase.singleton.OnRefreshGetFlowerInfo(); } } } }