From 41b8e2357f49bd12c558d63da9d94c82b9796cc7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 23 一月 2026 14:31:26 +0800
Subject: [PATCH] 0312 设置热更标识 logicversion 和assetversion 两个文件 的内容md5全异或取最后两个字母

---
 Main/System/AssetVersion/AssetVersionUtility.cs |    2 
 Main/System/Login/LoginWin.cs                   |    2 
 Main/System/Login/LoginManager.cs               |  139 +++++++++++++++++++++++++++++++++------------
 Main/Utility/OperationLogCollect.cs             |    4 
 4 files changed, 105 insertions(+), 42 deletions(-)

diff --git a/Main/System/AssetVersion/AssetVersionUtility.cs b/Main/System/AssetVersion/AssetVersionUtility.cs
index db5a9d0..cb0faa2 100644
--- a/Main/System/AssetVersion/AssetVersionUtility.cs
+++ b/Main/System/AssetVersion/AssetVersionUtility.cs
@@ -56,7 +56,7 @@
 
     public static DateTime assetsBuildTime = DateTime.MinValue;
 
-    static Dictionary<string, AssetVersion> assetVersions = new Dictionary<string, AssetVersion>();
+    public static Dictionary<string, AssetVersion> assetVersions = new Dictionary<string, AssetVersion>();
     //鏈湴LogicBytes鏂囦欢鍜� assetVersions 姣旇緝鏄惁闇�瑕佷笅杞�
     static Dictionary<string, AssetVersion> localAssetVersions = new Dictionary<string, AssetVersion>();
     static List<AssetVersion> priorDownLoadAssetVersions = new List<AssetVersion>();
diff --git a/Main/System/Login/LoginManager.cs b/Main/System/Login/LoginManager.cs
index a51c094..1f81e89 100644
--- a/Main/System/Login/LoginManager.cs
+++ b/Main/System/Login/LoginManager.cs
@@ -10,6 +10,8 @@
     public readonly static string USER_ACCOUNT = Application.dataPath + "UserAccount";
     public readonly static string USER_PASSWORD = Application.dataPath + "UserPassword";
 
+    public string hotVersion = "";
+
     public bool sdkLogined
     {
         get;
@@ -302,6 +304,65 @@
         }
     }
 
+    //logicversion 鍜宎ssetversion 涓や釜鏂囦欢 鐨勫唴瀹筸d5鍏ㄥ紓鎴栧彇鏈�鍚庝袱涓瓧姣�
+    public void RefreshHotVersion()
+    {
+        try
+        {
+            string logicVersionMd5 = "";
+            string assetVersionMd5 = "";
+            // 鍒濆鍖栫粨鏋滃瓧鑺傛暟缁�(MD5 鏄� 16 瀛楄妭)
+            byte[] resultBytes = new byte[16];
+            foreach (var item in LocalResManager.Instance.assetVersions)
+            {
+                // 瀵规瘡涓� MD5 杩涜寮傛垨杩愮畻
+                byte[] md5Bytes = HexStringToByteArray(item.Value.md5);
+                for (int j = 0; j < 16; j++)
+                {
+                    resultBytes[j] ^= md5Bytes[j];
+                }
+
+            }
+            //鍙栨渶鍚庝袱浣�
+            logicVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
+
+            resultBytes = new byte[16];
+            foreach (var item in AssetVersionUtility.assetVersions)
+            {
+                // 瀵规瘡涓� MD5 杩涜寮傛垨杩愮畻
+                byte[] md5Bytes = HexStringToByteArray(item.Value.md5);
+                for (int j = 0; j < 16; j++)
+                {
+                    resultBytes[j] ^= md5Bytes[j];
+                }
+
+            }
+            assetVersionMd5 = BitConverter.ToString(resultBytes).Replace("-", "").ToLower().Substring(14, 2);
+            hotVersion = logicVersionMd5 + assetVersionMd5;
+            Debug.Log($"RefreshHotVersion {hotVersion}");
+        }
+        catch
+        {
+            Debug.LogError("RefreshHotVersion 閿欒");            
+        }
+    }
+
+    
+
+    // 杈呭姪鏂规硶:鍗佸叚杩涘埗瀛楃涓茶浆瀛楄妭鏁扮粍
+    private byte[] HexStringToByteArray(string hex)
+    {
+        byte[] bytes = new byte[hex.Length / 2];
+        for (int i = 0; i < hex.Length; i += 2)
+        {
+            bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
+        }
+        return bytes;
+    }
+
+
+
+
     public C0101_tagCPlayerLogin Get0101SendPackage(H0101_tagServerPrepared _serverInfo)
     {
         GameNetSystem.Instance.SetIsWaitLogin(false);
@@ -328,46 +389,48 @@
                 send.Extra = "";
                 break;
             case VersionAuthority.Release:
-            {
-                var deviceInfo = DeviceUtility.GetDeviceModel();
-                deviceInfo.Replace(" ", "").Replace("=", "").Replace("%", "").Replace("-", "").Replace("|", "");
-                var versionStr = StringUtility.Concat(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex.ToString(), "_", deviceInfo);
-
-                send.Extra = StringUtility.Concat(VersionConfig.Get().SpID, "|",
-                                                    SDKUtils.Instance.Device.uniqueID, "|",
-                                                    sdkLoginResult.token, "|",
-                                                    sdkLoginResult.qkUserName, "|",
-                                                    versionStr.Substring(0, Math.Min(24, versionStr.Length)));
-
-
-                Debug.Log("=====> extra: " + send.Extra);
-                send.ExtraLen = (ushort)send.Extra.Length;
-
-                send.IDType = (byte)SDKUtils.Instance.ChannelPlatform;
-                send.Password = sdkLoginResult.token;
-                send.AccID = sdkLoginResult.account;
-                send.MAC = DeviceUtility.GetMac();
-                send.Version = _serverInfo.Version;
-                send.LineNO = 255;
-                send.AppID = VersionConfig.Get().appId;
-                send.AccountID = (uint)sdkLoginResult.accountID;
-                send.TokenExpire = sdkLoginResult.tokenExpire;
-                send.Phone = (byte)sdkLoginResult.phone;
-                send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
-                if (sdkIDCheckIDAuthentication.type == "1")
                 {
-                    send.Adult = 1;
+                    var deviceInfo = DeviceUtility.GetDeviceModel();
+                    deviceInfo.Replace(" ", "").Replace("=", "").Replace("%", "").Replace("-", "").Replace("|", "");
+                    var versionStr = StringUtility.Concat(VersionConfig.Get().version, "_",
+                    VersionConfig.Get().buildIndex.ToString(), "_",
+                    hotVersion, "-", deviceInfo);
+
+                    send.Extra = StringUtility.Concat(VersionConfig.Get().SpID, "|",
+                                                        SDKUtils.Instance.Device.uniqueID, "|",
+                                                        sdkLoginResult.token, "|",
+                                                        sdkLoginResult.qkUserName, "|",
+                                                        versionStr.Substring(0, Math.Min(24, versionStr.Length)));
+
+
+                    Debug.Log("=====> extra: " + send.Extra);
+                    send.ExtraLen = (ushort)send.Extra.Length;
+
+                    send.IDType = (byte)SDKUtils.Instance.ChannelPlatform;
+                    send.Password = sdkLoginResult.token;
+                    send.AccID = sdkLoginResult.account;
+                    send.MAC = DeviceUtility.GetMac();
+                    send.Version = _serverInfo.Version;
+                    send.LineNO = 255;
+                    send.AppID = VersionConfig.Get().appId;
+                    send.AccountID = (uint)sdkLoginResult.accountID;
+                    send.TokenExpire = sdkLoginResult.tokenExpire;
+                    send.Phone = (byte)sdkLoginResult.phone;
+                    send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag;
+                    if (sdkIDCheckIDAuthentication.type == "1")
+                    {
+                        send.Adult = 1;
+                    }
+                    else if (sdkIDCheckIDAuthentication.type == "2")
+                    {
+                        send.Adult = MathUtility.CheckAdult(sdkIDCheckIDAuthentication.card_id) ? (byte)1 : (byte)0;
+                    }
+                    else
+                    {
+                        send.Adult = 0;
+                    }
+                    break;
                 }
-                else if (sdkIDCheckIDAuthentication.type == "2")
-                {
-                    send.Adult = MathUtility.CheckAdult(sdkIDCheckIDAuthentication.card_id) ? (byte)1 : (byte)0;
-                }
-                else
-                {
-                    send.Adult = 0;
-                }
-                break;
-            }
         }
 
         return send;
diff --git a/Main/System/Login/LoginWin.cs b/Main/System/Login/LoginWin.cs
index 301ef5c..e81f412 100644
--- a/Main/System/Login/LoginWin.cs
+++ b/Main/System/Login/LoginWin.cs
@@ -89,7 +89,7 @@
     {
         base.OnPreOpen();
         Debug.Log("鎵撳紑鐧诲綍绐楀彛");
-
+        LoginManager.Instance.RefreshHotVersion();
 
         ServerListCenter.Instance.serverSelectEvent += OnServerChange;
         ServerListCenter.Instance.onServerListRefreshEvent += OnServerListRefresh;
diff --git a/Main/Utility/OperationLogCollect.cs b/Main/Utility/OperationLogCollect.cs
index 58acbe5..7b83620 100644
--- a/Main/Utility/OperationLogCollect.cs
+++ b/Main/Utility/OperationLogCollect.cs
@@ -129,7 +129,7 @@
 
         var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
         contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_", 
-            VersionConfig.Get().buildIndex.ToString()), Language.Id, ";");
+            VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
         contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
         contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
         contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
@@ -162,7 +162,7 @@
 
             var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
             contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_",
-                VersionConfig.Get().buildIndex.ToString()), Language.Id, ";");
+                VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
             contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
             contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
             contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");

--
Gitblit v1.8.0