Beispiel #1
0
        public static bool CheckMd5(string path, string file_md5, bool full = false)
        {
            byte[] buffs;
            bool   dataToFile = Pathtool.GetDataToFile(path, out buffs);

            if (dataToFile)
            {
                string md5temp = Md5Helper.Md5Buffer(buffs);
                string md5     = md5temp;
                if (!full)
                {
                    md5 = md5temp.Remove(8);
                }
                if (md5.Equals(file_md5))
                {
                    return(true);
                }
                bool openDownloadLog = AppConst.OpenDownloadLog;
                if (openDownloadLog)
                {
                    Debug.Log(string.Format("res md5 not same, res path:{0},self md5:{1},check md5:{2}", path, md5, file_md5));
                }
            }
            else
            {
                bool openDownloadLog2 = AppConst.OpenDownloadLog;
                if (openDownloadLog2)
                {
                    Debug.Log(string.Format("res md5 not same, res path not exist:{0}", path));
                }
            }
            return(false);
        }
        private void UpdateInfosLoading()
        {
            int count = this.m_update_infos.Count;

            if (this.m_loadind_map.Count < this.m_max_count && count > 0 && !this.m_stop_update_state)
            {
                UpdateInfo info = this.m_update_infos[count - 1];
                this.m_update_infos.RemoveAt(count - 1);
                MemoryLoadCallbackFunc delay_func = delegate(bool is_suc, byte[] buffer)
                {
                    bool flag3 = this.m_loadind_map.ContainsKey(info.file_path);
                    if (flag3)
                    {
                        this.m_loadind_map.Remove(info.file_path);
                    }
                    if (is_suc)
                    {
                        bool state = true;
                        bool flag4 = info.func != null;
                        if (flag4)
                        {
                            bool flag5 = !AppConst.UseUpdatOriModeReal;
                            if (flag5)
                            {
                                state = info.func(buffer);
                            }
                            else
                            {
                                state = false;
                                string file_path = info.file_path;
                                byte[] buffs;
                                bool   dataToFile = Pathtool.GetDataToFile(file_path, out buffs);
                                if (dataToFile)
                                {
                                    state = info.func(buffs);
                                }
                                buffs = null;
                            }
                        }
                        string md5_exit = GameConfig.Instance.GetValue("OpenMd5ErrorExitState");
                        bool   flag7    = state || md5_exit.Equals("0");
                        if (flag7)
                        {
                            this.m_loaded_count++;
                            this.m_lase_update_size += (float)info.file_size;
                            this.m_cur_update_size  += (float)info.file_size;
                            bool flag8 = this.m_last_download_time == 0f;
                            if (flag8)
                            {
                                this.m_download_speed     = 100f;
                                this.m_last_download_time = Time.time;
                            }
                            else
                            {
                                float pass_time = Time.time - this.m_last_download_time;
                                bool  flag9     = pass_time > 1f;
                                if (flag9)
                                {
                                    this.m_last_download_time = Time.time;
                                    this.m_download_speed     = this.m_lase_update_size / pass_time;
                                    this.m_lase_update_size   = 0f;
                                }
                            }
                        }
                        else
                        {
                            LogMgr.Log("download md5 error {0}", info.file_path);
                            bool random_state = info.random_state;
                            if (random_state)
                            {
                                this.m_stop_update_state = true;
                                string md5_error = GameConfig.Instance.GetValue("UpdateFileMd5ErrorMsg");
                                BusinessManager.Instance.SendMessage(ModuleDef.LaunchModule, "SendMessageCommand", "UPDATE_RES_MD5_ERROR", md5_error);
                            }
                            else
                            {
                                LogMgr.Log("md5 check error {0}", info.file_path);
                                info.count = 0;
                                string[] array = info.http_str.Split(new char[]
                                {
                                    '?'
                                });
                                bool flag10 = array.Length != 0;
                                if (flag10)
                                {
                                    string new_httpstr = array[0] + "?v=" + Util.GetTimeStamp();
                                    info.http_str       = new_httpstr;
                                    info.random_state   = true;
                                    info.www            = null;
                                    info.request        = null;
                                    info.download_again = true;
                                    this.m_update_infos.Add(info);
                                }
                            }
                        }
                    }
                    else
                    {
                        info.www            = null;
                        info.request        = null;
                        info.download_again = true;
                        bool flag11 = info.count < 3;
                        if (flag11)
                        {
                            info.count++;
                            this.m_update_infos.Add(info);
                        }
                        else
                        {
                            info.count = 0;
                            this.m_update_infos.Add(info);
                        }
                        LogMgr.Log("download again {0}", info.file_path);
                    }
                };
                MemoryQuest memory_quest = new MemoryQuest();
                memory_quest.RelativePath = info.http_str;
                memory_quest.timeout      = AppConst.UpdateFileTimeout;
                if (AppConst.UseUpdatOriModeReal)
                {
                    memory_quest.save_path = info.file_path;
                }
                if (info.download_again)
                {
                    memory_quest.timeout = AppConst.UpdateFileTimeout * 4;
                }
                if (AppConst.OpenDownloadLog)
                {
                    LogMgr.Log("res start update, res path:{0}", info.http_str);
                }
                ResRequest.Instance.RequestMemoryAsync(memory_quest, delay_func);
                if (memory_quest.Www != null)
                {
                    info.www = (memory_quest.Www as WWW);
                }
                else
                {
                    info.request = memory_quest.request;
                }
                this.m_loadind_map.Add(info.file_path, info);
            }
        }