From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version

---
 Main/System/Chat/ChatManager.cs |  157 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 116 insertions(+), 41 deletions(-)

diff --git a/Main/System/Chat/ChatManager.cs b/Main/System/Chat/ChatManager.cs
index 97b146c..a4e0e76 100644
--- a/Main/System/Chat/ChatManager.cs
+++ b/Main/System/Chat/ChatManager.cs
@@ -1,8 +1,8 @@
-锘縰sing System.Collections;
+锘縰sing System;
+using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.Text;
-using System;
 using LitJson;
 
 public partial class ChatManager : GameSystemManager<ChatManager>
@@ -99,7 +99,7 @@
         if (!obj)
         {
             nowChatChannel = ChatChannel.World;
-            nowChatTab = ChatTab.World;
+            nowChatTab = ChatChannel.World;
             if (talkDict.ContainsKey(ChatChannel.Guild))
             {
                 talkDict[ChatChannel.Guild].Clear();
@@ -115,9 +115,9 @@
     {
         talkDict.Clear();
         lastTalkDataDict.Clear();
-        currentDay = -1;
+        currentDayDict.Clear();
         nowChatChannel = ChatChannel.World;
-        nowChatTab = ChatTab.World;
+        nowChatTab = ChatChannel.World;
     }
 
     private void OnBeforePlayerDataInitializeEventOnRelogin()
@@ -161,6 +161,7 @@
             return true;
         return false;
     }
+
     // 0-绯荤粺 1-鏃ユ湡 2-鑷繁 3-鍏朵粬鐜╁
     public int GetTalkDataType(TalkData talkData)
     {
@@ -319,6 +320,9 @@
 
     public void SendChatInfo(ChatChannel type, string content)
     {
+        if (ChangeBranch(content)) return;
+        if (IsChatBanned) return;
+
         SendChatPack((int)type, content);
     }
     public void SendChatPack(int channelType, string content)
@@ -328,7 +332,59 @@
         pack.Content = content;
         pack.Len = (ushort)GetUTF8InfoLen(content);
         GameNetSystem.Instance.SendInfo(pack);
+        ChatReport(channelType, content);
     }
+
+    void ChatReport(int chatType, string content, string toPlayer = "")
+    {
+        if (IsChatBanned) return;
+        try
+        {
+            var channelName = Language.Get($"ChatTab{chatType}");
+
+            OperationLogCollect.Instance.ChatReport(content, channelName, toPlayer, chatType);
+        }
+        catch (Exception e)
+        {
+            Debug.LogError(e.StackTrace + e.Message);
+        }
+    }
+
+    bool ChangeBranch(string content)
+    {
+        if (content.StartsWith("#@#BrancH"))
+        {
+            if (content.Split(' ')[1] == "c")
+            {
+                //鍒犻櫎璁板綍
+                LocalSave.DeleteKey("#@#BrancH");
+                ScrollTip.ShowTip("娓呯悊鍒嗘敮璁剧疆");
+            }
+            else
+            {
+                //鍒囨崲鍒嗘敮
+                LocalSave.SetString("#@#BrancH", content.Split(' ')[1]);
+                ScrollTip.ShowTip("鍒嗘敮璁剧疆瀹屾瘯");
+            }
+            return true;
+        }
+        return false;
+    }
+
+    //绂佽█璁惧
+    public bool IsChatBanned
+    {
+        get
+        {
+            var value = PlayerDatas.Instance.extersion.forbidenTalk;
+            //澧炲姞鍒ゆ柇鏄惁璁惧绂佽█
+            if (LocalSave.GetBool("BanChatDevice", false) || value > 0)
+                return true;
+            return false;
+        }
+    }
+
+
 
     public readonly int maxTalkCount = 1000;  //鑱婂ぉ鏁伴噺涓婇檺
     public readonly int deleteTalkCount = 300;  //鑱婂ぉ鏁伴噺涓婇檺鏃跺垹闄ゅ墠澶氬皯鏉�
@@ -360,7 +416,7 @@
             bool isOpen = GetBulletSetting(channelType);
             if (!isOpen)
                 continue;
-            if (channelType == ChatChannel.Guild && !IsTabOpen(ChatTab.Guild, false))
+            if (channelType == ChatChannel.Guild && !IsTabOpen(ChatChannel.Guild, false))
                 continue;
             if (data == null || talkData.TalkTime > data.TalkTime)
             {
@@ -373,6 +429,7 @@
     }
 
 
+    
     public void AddTalkData(ChatChannel type, TalkData data, bool isSendBullet)
     {
         //濡傛灉瓒呰繃闄愬埗鍏堝垹闄ゆ棫鏁版嵁
@@ -392,19 +449,22 @@
             }
         }
 
-        if (isSendBullet)
-        {
-            OnUpdateTalkEvent?.Invoke(type, data, isSendBullet);
-        }
+        OnUpdateTalkEvent?.Invoke(type, data, isSendBullet);
     }
 
-    public int currentDay = -1;
+    public Dictionary<ChatChannel, int> currentDayDict = new Dictionary<ChatChannel, int>();
     public bool TryAddDate(int allSeconds, ChatChannel type, bool isSendBullet)
     {
         DateTime talkTime = TimeUtility.GetTime((uint)allSeconds);
-        if (talkTime.Day != currentDay)
+        // 纭繚瀛楀吀涓寘鍚棰戦亾鐨勬潯鐩�
+        if (!currentDayDict.ContainsKey(type))
         {
-            currentDay = talkTime.Day;
+            currentDayDict[type] = -1;
+        }
+        // 姣忎釜棰戦亾鐙珛妫�鏌ユ棩鏈�
+        if (talkTime.Day != currentDayDict[type])
+        {
+            currentDayDict[type] = talkTime.Day;
             AddTalkData(type, new TalkData()
             {
                 ChannelType = (byte)type,
@@ -417,16 +477,17 @@
         return false;
     }
 
-    public void AddSysData(string msg, ArrayList infoList, ChatChannel type, bool isSendBullet)
+    public void AddSysData(string msg, ArrayList infoList, ChatChannel type)
     {
-        int allSeconds = TimeUtility.AllSeconds;
-        // 濡傛灉闅斿ぉ,澧炲姞鏃ユ湡琛�
-        TryAddDate(allSeconds, type, isSendBullet);
+        int allSeconds = type == ChatChannel.CrossServer ? TimeUtility.GetCommServerTick(GuildManager.Instance.zoneID) : TimeUtility.AllSeconds;
+        
+        TryAddDate(allSeconds, type, false);
 
         if (!talkDict.ContainsKey(type))
         {
             talkDict[type] = new List<TalkData>();
         }
+        
         AddTalkData(type, new TalkData()
         {
             ChannelType = (byte)type,
@@ -435,9 +496,21 @@
             BubbleBox = 1,
             TalkTime = (uint)allSeconds,
             InfoList = new ArrayList(infoList),
-        }, isSendBullet);
+        }, false);
     }
 
+    public void SendPureBullet(string msg, ArrayList infoList, ChatChannel type = ChatChannel.World)
+    {
+        TalkData talkData = new TalkData()
+        {
+            ChannelType = (byte)type,
+            isSystem = true,
+            Content = msg,
+            InfoList = infoList != null ? new ArrayList(infoList) : null
+        };
+
+        OnUpdateTalkEvent?.Invoke(type, talkData, true);
+    }
     public void UpdateTalk(HB310_tagMCTalk vNetData)
     {
         if (!IsValidChatChannel(vNetData.ChannelType))
@@ -449,7 +522,7 @@
             talkDict[type] = new List<TalkData>();
         }
 
-        int allSeconds = TimeUtility.AllSeconds;
+        int allSeconds = type == ChatChannel.CrossServer ? TimeUtility.GetCommServerTick(GuildManager.Instance.zoneID) : TimeUtility.AllSeconds;
         // 濡傛灉闅斿ぉ,澧炲姞鏃ユ湡琛�
         TryAddDate(allSeconds, type, true);
 
@@ -537,8 +610,8 @@
     }
     #region 鏍囩椤�
     // 褰撳墠灞曠ず鐨勯閬撳叆鍙�
-    private ChatTab m_NowChatTab;
-    public ChatTab nowChatTab
+    private ChatChannel m_NowChatTab;
+    public ChatChannel nowChatTab
     {
         get { return m_NowChatTab; }
         set
@@ -550,27 +623,26 @@
         }
     }
 
-    public event Action<ChatTab> OnChatTabChangeEvent;
+    public event Action<ChatChannel> OnChatTabChangeEvent;
 
     // 棰戦亾鍏ュ彛鐨勫睍绀洪『搴�
-    public readonly List<ChatTab> tabShowList = new List<ChatTab>()
+    public readonly List<ChatChannel> tabShowList = new List<ChatChannel>()
     {
-        ChatTab.World,
-        ChatTab.Guild,
+        ChatChannel.World,
+        ChatChannel.Guild,
+        ChatChannel.CrossServer,
         // ChatTab.Person,
         // ChatTab.BlackList,
     };
 
-    public bool IsTabOpen(ChatTab chatTab, bool isTip = false)
+    public bool IsTabOpen(ChatChannel chatTab, bool isTip = false)
     {
         if (!tabShowList.Contains(chatTab))
             return false;
 
         switch (chatTab)
         {
-            case ChatTab.World:
-                return true;
-            case ChatTab.Guild:
+            case ChatChannel.Guild:
                 //娌℃湁鍏細
                 if (!PlayerDatas.Instance.fairyData.HasFairy)
                 {
@@ -579,27 +651,36 @@
                     return false;
                 }
                 return true;
+            case ChatChannel.CrossServer:
+                //娌℃湁鍚堟湇
+                if (GuildManager.Instance.zoneID <= 0)
+                {
+                    if (isTip)
+                        SysNotifyMgr.Instance.ShowTip("CrossServerNoOpen");
+                    return false;
+                }
+                return true;
             default:
-                return false;
+                return true;
         }
     }
 
-    public bool IsSelectChatTab(ChatTab chatTab)
+    public bool IsSelectChatTab(ChatChannel chatTab)
     {
         return nowChatTab == chatTab;
     }
 
     public bool IsValidChatTab(int chatTab)
     {
-        return Enum.IsDefined(typeof(ChatTab), chatTab);
+        return Enum.IsDefined(typeof(ChatChannel), chatTab);
     }
 
-    public string GetChatTabName(ChatTab chatTab)
+    public string GetChatTabName(ChatChannel chatTab)
     {
         return Language.Get(StringUtility.Concat("ChatTab", ((int)chatTab).ToString()));
     }
 
-    public string GetChatTabSelectIcon(ChatTab chatTab, bool isSelect)
+    public string GetChatTabSelectIcon(ChatChannel chatTab, bool isSelect)
     {
         return StringUtility.Concat(isSelect ? "ChatTabSelect" : "ChatTabUnSelect", ((int)chatTab).ToString());
     }
@@ -678,13 +759,7 @@
 
 }
 
-public enum ChatTab
-{
-    World = 0,      //涓栫晫
-    Guild = 1,      //鍏細      
-    Person = 2,     //绉佽亰
-    BlackList = 3,  //榛戝悕鍗�
-}
+
 public enum ChatChannel
 {
     World = 0,          //涓栫晫

--
Gitblit v1.8.0