From eb27e5fd31f73b998a4bbd85511a31e40b8c61b7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 21 十一月 2025 17:03:47 +0800
Subject: [PATCH] 0312 关闭游戏内日志

---
 Main/Config/ConfigParse.cs |  132 ++++++++++++++++++++++++++++++++------------
 1 files changed, 96 insertions(+), 36 deletions(-)

diff --git a/Main/Config/ConfigParse.cs b/Main/Config/ConfigParse.cs
index 4ad01b1..da09db2 100644
--- a/Main/Config/ConfigParse.cs
+++ b/Main/Config/ConfigParse.cs
@@ -62,6 +62,7 @@
         return string.Empty;
     }
 
+    //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1|2|3|4
     public static T[] GetMultipleStr<T>(string msg) where T : struct
     {
         string[] segs = GetMultipleStr(msg);
@@ -105,6 +106,8 @@
         return msg.Split('_');
     }
 
+    //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1_2|2_3|3_1|4_3锛�
+    //杩斿洖涓�缁存暟缁勭粨鏋勫 1|2|3|4
     public static T[] GetKeyValueKeys<T>(string msg) where T : struct
     {
         string[] segs = GetMultipleStr(msg);
@@ -124,6 +127,8 @@
         return null;
     }
 
+    //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1_2|2_3|3_1|4_3锛�
+    //杩斿洖涓�缁存暟缁勭粨鏋勫 2|3|1|3
     public static T[] GetKeyValueValues<T>(string msg) where T : struct
     {
         string[] segs = GetMultipleStr(msg);
@@ -143,6 +148,31 @@
         return null;
     }
 
+    //浜岀淮鏁扮粍锛氭潵婧愭牸寮忓 1_2_1|2_3_4|3_1_2|4_3_4
+    public static T[][] GetArray2<T>(string msg) where T : struct
+    {
+        string[] segs = GetMultipleStr(msg);
+        if (segs != null && segs.Length > 0)
+        {
+            T[][] array = new T[segs.Length][];
+            for (int i = 0; i < segs.Length; i++)
+            {
+                string[] pair = GetKeyValue(segs[i]);
+                if (pair.Length > 1)
+                {
+                    array[i] = new T[pair.Length];
+                    for (int j = 0; j < pair.Length; j++)
+                    {
+                        array[i][j] = (T)Convert.ChangeType(pair[j], typeof(T));
+                    }
+                }
+            }
+            return array;
+        }
+        return null;
+    }
+
+    //瀛楀吀锛氭潵婧愭牸寮忓 1_2|2_3|3_1|4_3锛�
     public static Dictionary<T, P> GetDic<T, P>(string msg)
     {
         Dictionary<T, P> dic = null;
@@ -177,7 +207,6 @@
     }
 
     //{'17':['63','6','27'],'65':['800'],'55':['139'],'19':['1000','2600','130']}
-    public static Regex userDataRegex = new Regex(@"'([0-9]+)':\[(.*?)\]", RegexOptions.Singleline);
     public static Dictionary<int, List<int>> Analysis(string val)//姝e垯琛ㄨ揪寮忕殑瀛楃涓插垎鍓�
     {
         string s = ServerStringTrim(val);
@@ -187,50 +216,57 @@
         }
 
         s = s.Replace(" ", string.Empty);
-        if (!userDataRegex.IsMatch(s))
-        {
-            return null;
-        }
-        else
-        {
-            Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
-            foreach (Match match in userDataRegex.Matches(s))
-            {
-                int id = int.Parse(match.Groups[1].Value);
-                string str = match.Groups[2].Value;
-                string[] vals = str.Split(',');
-                List<int> list = new List<int>();
-                for (int i = 0; i < vals.Length; i++)
-                {
-                    int intval = int.Parse(vals[i].Replace('\'', ' '));
-                    list.Add(intval);
-                }
-                if (!dics.ContainsKey(id))
-                {
-                    dics.Add(id, list);
-                }
-            }
-            return dics;
-        }
-    }
 
-    public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr)
-    {
-        if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
-        {
-            return new Dictionary<int, List<int>>();
-        }
-        var dict = JsonMapper.ToObject<Dictionary<string, List<int>>>(jsonStr);
+
+        var dict = JsonMapper.ToObject<Dictionary<string, string[]>>(s);
+
+        if (dict == null || dict.Count == 0)
+            return null;
+
         Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();
 
         foreach (var item in dict)
         {
-            result[int.Parse(item.Key)] = item.Value;
+            List<int> list = new List<int>();
+            for (int i = 0; i < item.Value.Length; i++)
+            {
+                list.Add(int.Parse(item.Value[i]));
+            }
+            if (list.Count != 0)
+                result[int.Parse(item.Key)] = list;
         }
 
         return result;
+
+        //if (!userDataRegex.IsMatch(s))
+        //{
+        //    return null;
+        //}
+        //else
+        //{
+        //    Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
+        //    foreach (Match match in userDataRegex.Matches(s))
+        //    {
+        //        int id = int.Parse(match.Groups[1].Value);
+        //        string str = match.Groups[2].Value;
+        //        string[] vals = str.Split(',');
+        //        List<int> list = new List<int>();
+        //        for (int i = 0; i < vals.Length; i++)
+        //        {
+        //            int intval = int.Parse(vals[i].Replace('\'', ' '));
+        //            list.Add(intval);
+        //        }
+        //        if (!dics.ContainsKey(id))
+        //        {
+        //            dics.Add(id, list);
+        //        }
+        //    }
+        //    return dics;
+        //}
     }
 
+
+    //json鏍煎紡锛� {"1":1}
     public static Dictionary<int, int> ParseIntDict(string jsonStr)
     {
         if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
@@ -248,6 +284,7 @@
         return result;
     }
 
+    //json鏍煎紡锛� {"1":[1,2],"2":[3,4]}
     public static Dictionary<int, int[]> ParseIntArrayDict(string jsonStr)
     {
         if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
@@ -265,6 +302,7 @@
         return result;
     }
 
+    //json鏍煎紡锛� {"1":[[1,2],[3,4]]}
     public static Dictionary<int, int[][]> ParseIntArray2Dict(string jsonStr)
     {
         if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
@@ -282,13 +320,35 @@
         return result;
     }
 
+    //json鏍煎紡锛� {"1":{"1":1,"2":2},"2":{"3":3,"4":4}}
+    public static Dictionary<int, Dictionary<int, int>> ParseDictInDict(string jsonStr)
+    {
+        if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
+        {
+            return new Dictionary<int, Dictionary<int, int>>();
+        }
+        var dict = JsonMapper.ToObject<Dictionary<string, Dictionary<string, int>>>(jsonStr);
+        Dictionary<int, Dictionary<int, int>> result = new Dictionary<int, Dictionary<int, int>>();
+
+        foreach (var item in dict)
+        {
+            Dictionary<int, int> subDict = new Dictionary<int, int>();
+            foreach (var subItem in item.Value)
+            {
+                subDict[int.Parse(subItem.Key)] = subItem.Value;
+            }
+            result[int.Parse(item.Key)] = subDict;
+        }
+        
+        return result;
+    }
 
     //涓囧垎鐜囪浆涓烘瘡涓猧d瀵瑰簲鐨勬鐜� [[涓囧垎姒傜巼锛宨d1],[涓囧垎姒傜巼锛宨d2]]
     public static Dictionary<int, int> GetRateDict(int[][] rateArray)
     {
         Dictionary<int, int> dic = new Dictionary<int, int>();
         //姒傜巼涓� 鍑忓幓涓婁竴涓鐜囩殑鍊煎嵆涓哄綋鍓岻D姒傜巼
-        for (int i = 0;i< rateArray.Length; i++)
+        for (int i = 0; i < rateArray.Length; i++)
         {
             if (i > 0)
             {

--
Gitblit v1.8.0