0312 设置热更标识 logicversion 和assetversion 两个文件 的内容md5全异或取最后两个字母
4个文件已修改
147 ■■■■ 已修改文件
Main/System/AssetVersion/AssetVersionUtility.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Login/LoginManager.cs 139 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Login/LoginWin.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Utility/OperationLogCollect.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>();
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 和assetversion 两个文件 的内容md5全异或取最后两个字母
    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;
Main/System/Login/LoginWin.cs
@@ -89,7 +89,7 @@
    {
        base.OnPreOpen();
        Debug.Log("打开登录窗口");
        LoginManager.Instance.RefreshHotVersion();
        ServerListCenter.Instance.serverSelectEvent += OnServerChange;
        ServerListCenter.Instance.onServerListRefreshEvent += OnServerListRefresh;
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(), ";");