public void LoadStory(string storyName, Action <string> onComplete) { DataTableInterfaceProxy table = new DataTableInterfaceProxy(onComplete); DataLoadRequest req = CreateRequestLoadTable(storyName, table, false, null); Request(req); }
private DataLoadRequest CreateRequestLoadTable(string name, IDataTable table, bool downloadOnly = false, Action <byte[]> processBinary = null) { if (downloadOnly || forceLoadCSV) { processBinary = null; } DataLoadRequest dataLoadRequest = CreateRequest(name, manifest.GetTableHash(name), DATA_TABLE_DIRECTORY, downloadOnly); dataLoadRequest.processCompressedTextData = delegate(byte[] bytes) { if (table != null) { if (bytes.Length < 256) { throw new ApplicationException("seek error"); } string text = DecompressToString(bytes); if (!string.IsNullOrEmpty(text)) { table.CreateTable(text); } else if (text == null) { throw new ApplicationException(); } } }; if (processBinary != null) { dataLoadRequest.SetupLoadBinary(manifest, processBinary); } return(dataLoadRequest); }
private bool Verify(DataLoadRequest req, byte[] bytes) { bool flag = false; using (MemoryStream memoryStream = new MemoryStream(bytes)) { int num = 256; byte[] array = new byte[num]; memoryStream.Read(array, 0, num); try { flag = Cipher.verifyBytes(memoryStream, array); } catch (Exception ex) { flag = false; Log.Error(LOG.DATA_TABLE, "verify exception({0}): {1}", req.name, ex); } if (flag) { return(flag); } MD5Hash mD5Hash = MD5Hash.Calc(bytes); return(req.OnVerifyError(mD5Hash.ToString())); } }
public List <DataLoadRequest> LoadInitialTable(Action onComplete, bool downloadOnly = false) { if (!downloadOnly) { loadStatus = LoadStatus.LoadingInitialTable; } RequestParam[] array = new RequestParam[21] { new RequestParam("AvatarTable", null), new RequestParam("CreateEquipItemTable", null), new RequestParam("CreatePickupItemTable", null), new RequestParam("DeliveryTable", null), new RequestParam("EquipItemTable", null), new RequestParam("EquipModelTable", null), new RequestParam("GrowSkillItemTable", null), new RequestParam("HomeThemeTable", null), new RequestParam("CountdownTable", null), new RequestParam("NPCMessageTable", null), new RequestParam("NPCTable", null), new RequestParam("QuestTable", null), new RequestParam("SkillItemTable", null), new RequestParam("ExceedSkillItemTable", null), new RequestParam("StageTable", null), new RequestParam("TutorialMessageTable", null), new RequestParam("StampTypeTable", null), new RequestParam("EquipItemExceedParamTable", null), new RequestParam("RegionTable", null), new RequestParam("FieldMapTable", null), new RequestParam("FieldMapPortalTable", null) }; List <DataLoadRequest> list = new List <DataLoadRequest>(); int i = 0; for (int num = array.Length; i < num; i++) { RequestParam requestParam = array[i]; DataLoadRequest item = CreateRequestLoadTable(requestParam.tableName, downloadOnly, requestParam.processBinary); list.Add(item); } SetDepends(list); int reqCount = list.Count; foreach (DataLoadRequest item2 in list) { item2.onComplete += delegate { reqCount--; if (reqCount <= 0) { onComplete(); if (!downloadOnly) { loadStatus = LoadStatus.LoadingAllTable; } } }; } Request(list); return(list); }
private IEnumerator LoadCompressedBinary(DataLoadRequest req, byte[] bytes, Action <DataTableLoadError> onEnd, bool useQueue) { bool wait = true; DataTableLoadError error = DataTableLoadError.None; Action act = delegate { try { if (((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes != null) { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cerror_003E__1 = ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003C_003Ef__this.Save(((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).req, ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes); } else { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes = ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003C_003Ef__this.cache.Load(((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).req); } if (((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes != null) { if (((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003C_003Ef__this.Verify(((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).req, ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes)) { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cerror_003E__1 = ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003C_003Ef__this.ProcessCompressedBinary(((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).req, ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/).bytes); } else { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cerror_003E__1 = DataTableLoadError.VerifyError; } } else { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cerror_003E__1 = DataTableLoadError.FileReadError; } } catch (Exception) { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cerror_003E__1 = DataTableLoadError.FileReadError; } finally { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0030: stateMachine*/)._003Cwait_003E__0 = false; } }; if (useQueue) { taskRunner.Add(req.name, act); } else { ThreadPoolWrapper.QueueUserWorkItem(delegate { ((_003CLoadCompressedBinary_003Ec__Iterator236) /*Error near IL_0072: stateMachine*/)._003Cact_003E__2(); }); } while (wait) { yield return((object)null); } onEnd(error); }
private void RemoveQueue(DataLoadRequest req) { requestList.Remove(req); if (0 >= requestList.Count) { taskRunner.DestroyThread(); } }
public DataLoadRequest RequestLoadTable(string name, IDataTable table, Action onComplete, bool downloadOnly = false) { DataLoadRequest dataLoadRequest = CreateRequestLoadTable(name, table, downloadOnly, null); dataLoadRequest.onComplete += onComplete; Request(dataLoadRequest); return(dataLoadRequest); }
public DataLoadRequest RequestLoadTable(string name, Action onComplete, bool downloadOnly = false) { tables.TryGetValue(name, out DataTableContainer value); DataLoadRequest dataLoadRequest = CreateRequestLoadTable(name, value, downloadOnly, null); dataLoadRequest.onComplete += onComplete; Request(dataLoadRequest); return(dataLoadRequest); }
private string GetCachePathGeneratedMD5(DataLoadRequest req, byte[] data) { using (MD5 md5Hash = MD5.Create()) { return(Path.Combine(cachePath, req.filename + "." + GetMd5Hash(md5Hash, data))); IL_002e: string result; return(result); } }
private void Retry() { int i = 0; for (int count = erroredRequests.Count; i < count; i++) { DataLoadRequest dataLoadRequest = erroredRequests[i]; dataLoadRequest.Reset(); dataLoader.Request(dataLoadRequest); } erroredRequests.Clear(); }
private IEnumerator Download(DataLoadRequest req, Action <byte[]> onComplete, Action <DataTableLoadError> onError) { while (downloadCount >= 5) { yield return((object)null); } downloadCount++; string host = NetworkManager.TABLE_HOST + MonoBehaviourSingleton <ResourceManager> .I.tableIndex.ToString() + "/"; WWW www = new WWW(host + req.path); float progress = 0f; float timeOut = 15f; while (!www.get_isDone()) { yield return((object)null); timeOut -= Time.get_unscaledDeltaTime(); if (www.get_progress() != progress) { progress = www.get_progress(); timeOut = 15f; } if (timeOut < 0f) { onError(DataTableLoadError.DownloadTimeOut); www.Dispose(); downloadCount--; yield break; } } if (!string.IsNullOrEmpty(www.get_error())) { if (www.get_error().Contains("404")) { onError(DataTableLoadError.AssetNotFoundError); } else { onError(DataTableLoadError.NetworkError); } www.Dispose(); downloadCount--; } else { byte[] bytes = www.get_bytes(); www.Dispose(); downloadCount--; onComplete(bytes); } }
public DataLoadRequest RequestLoadTable(string name, Action <byte[]> processBinaryData, Action onComplete, bool downloadOnly = false) { tables.TryGetValue(name, out DataTableContainer value); DataLoadRequest dataLoadRequest = CreateRequestLoadTable(name, value, downloadOnly, null); dataLoadRequest.onComplete += onComplete; if (processBinaryData != null) { dataLoadRequest.processCompressedBinaryData = processBinaryData; } Request(dataLoadRequest); return(dataLoadRequest); }
public void ChangePriorityTop(string tableName) { taskRunner.ChangePriorityTop(tableName); DataLoadRequest dataLoadRequest = requestList.Find((DataLoadRequest o) => o.name == tableName); if (dataLoadRequest != null && dataLoadRequest.depReqs != null) { dataLoadRequest.depReqs.ForEach(delegate(DataLoadRequest o) { taskRunner.ChangePriorityTop(o.name); }); } }
private DataTableLoadError ProcessCompressedBinary(DataLoadRequest req, byte[] bytes) { DataTableLoadError result = DataTableLoadError.None; try { req.processCompressedBinaryData(bytes); return(result); } catch (Exception ex) { Log.Error(LOG.DATA_TABLE, "DataLoadError({0}): {1}", req.name, ex); return(DataTableLoadError.FileReadError); } }
private DataTableLoadError Save(DataLoadRequest req, byte[] bytes) { DataTableLoadError result = DataTableLoadError.None; try { cache.Save(req, bytes); return(result); } catch (Exception ex) { Log.Error(LOG.DATA_TABLE, "SaveError({0}): {1}", req.name, ex); return(DataTableLoadError.FileWriteError); } }
public void Save(DataLoadRequest req, byte[] data) { string[] files = Directory.GetFiles(cachePath, req.filename + "*"); string[] array = files; foreach (string path in array) { try { File.Delete(path); } catch (Exception ex) { Log.Error(LOG.DATA_TABLE, "cache delete exception({0}): {1}\n{2}\n{3}", ex, req.filename, ex.Message, ex.StackTrace); } } string cachePathGeneratedMD = GetCachePathGeneratedMD5(req, data); File.WriteAllBytes(cachePathGeneratedMD, data); }
private void SetDepends(List <DataLoadRequest> reqs) { int i = 0; for (int count = reqs.Count; i < count; i++) { DataLoadRequest dataLoadRequest = reqs[i]; DataTableContainer value = null; if (tables.TryGetValue(dataLoadRequest.name, out value)) { DataTableContainer dependency = value.GetDependency(); if (dependency != null) { DataLoadRequest dataLoadRequest2 = reqs.Find((DataLoadRequest o) => o.name == dependency.name); if (dataLoadRequest2 != null) { dataLoadRequest.DependsOn(dataLoadRequest2); } } } } }
public void UpdateManifest(Action onComplete) { int version = lastReceiveManifestVersion; DataLoadRequest dataLoadRequest = CreateRequest(MANIFEST_NAME, new ManifestVersion(version), DATA_TABLE_DIRECTORY, false); dataLoadRequest.processCompressedTextData = delegate(byte[] bytes) { try { string csv = DecompressToString(bytes); manifest = DataTableManifest.Create(csv, version); } catch (Exception ex) { Log.Error(LOG.DATA_TABLE, "manifest load error: {0}", ex.ToString()); throw; IL_0040 :; } }; dataLoadRequest.onComplete += onComplete; dataLoader.RequestManifest(dataLoadRequest); }
private DataLoadRequest CreateRequest(string name, IDataTableRequestHash hash, string directory, bool downloadOnly = false) { DataLoadRequest req = new DataLoadRequest(name, hash, directory, downloadOnly); req.onVerifyError += delegate(string filehash) { ReportVerifyError(name, filehash); if (reportOnly) { Log.Error(LOG.DATA_TABLE, "VerifyError(report-only): {0}", req.name); return(true); } if (!verifyErroredRequest.Contains(req)) { Log.Error(LOG.DATA_TABLE, "VerifyError(auto-retry): {0}", req.name); cache.Remove(req); verifyErroredRequest.Add(req); } return(false); }; req.onError += delegate(DataTableLoadError error) { Log.Error(LOG.DATA_TABLE, "load error ({1}): {0}", req.name, error.ToString()); erroredRequests.Add(req); cache.Remove(req); if (this.onError != null) { this.onError(error, Retry); } }; req.onComplete += delegate { verifyErroredRequest.Remove(req); }; return(req); }
public byte[] Load(DataLoadRequest req) { string cachePath = GetCachePath(req); return(File.ReadAllBytes(cachePath)); }
public void RequestManifest(DataLoadRequest req) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) this.StartCoroutine(Load(req, req.downloadOnly, false, true)); }
private string GetCachePath(DataLoadRequest req) { return(Path.Combine(cachePath, req.filename + "." + req.hash.ToString())); }
public List <DataLoadRequest> LoadAllTable(Action onComplete, bool downloadOnly = false) { RequestParam[] array = new RequestParam[43] { new RequestParam("AbilityDataTable", null), new RequestParam("AbilityTable", null), new RequestParam("AudioSettingTable", null), new RequestParam("DeliveryRewardTable", null), new RequestParam("EnemyTable", null), new RequestParam("EquipItemExceedTable", null), new RequestParam("EvolveEquipItemTable", null), new RequestParam("GrowEnemyTable", null), new RequestParam("ItemTable", null), new RequestParam("SETable", null), new RequestParam("StringTable", null), new RequestParam("TaskTable", null), new RequestParam("UserLevelTable", null), new RequestParam("GrowEquipItemTable", null), new RequestParam("GrowEquipItemNeedItemTable", null), new RequestParam("GrowEquipItemNeedUniqueItemTable", null), new RequestParam("MissionTable", null), new RequestParam("RegionTable", null), new RequestParam("FieldMapTable", null), new RequestParam("FieldMapPortalTable", null), new RequestParam("FieldMapEnemyPopTable", null), new RequestParam("FieldMapGatherPointTable", null), new RequestParam("FieldMapGatherPointViewTable", null), new RequestParam("FieldMapGimmickPointTable", null), new RequestParam("FieldMapGimmickActionTable", null), new RequestParam("QuestToFieldTable", null), new RequestParam("ItemToFieldTable", null), new RequestParam("EnemyHitTypeTable", null), new RequestParam("EnemyHitMaterialTable", null), new RequestParam("EnemyPersonalityTable", null), new RequestParam("PointShopGetPointTable", null), new RequestParam("DegreeTable", null), new RequestParam("DamageDistanceTable", null), new RequestParam("GachaSearchEnemyTable", null), new RequestParam("BuffTable", null), new RequestParam("FieldBuffTable", null), new RequestParam("LimitedEquipItemExceedTable", null), new RequestParam("PlayDataTable", null), new RequestParam("ArenaTable", null), new RequestParam("EnemyAngryTable", null), new RequestParam("EnemyActionTable", null), new RequestParam("NpcLevelTable", null), new RequestParam("FieldMapEnemyPopTimeZoneTable", null) }; List <DataLoadRequest> list = new List <DataLoadRequest>(); int i = 0; for (int num = array.Length; i < num; i++) { RequestParam requestParam = array[i]; DataLoadRequest item = CreateRequestLoadTable(requestParam.tableName, downloadOnly, requestParam.processBinary); list.Add(item); } SetDepends(list); int reqCount = list.Count; foreach (DataLoadRequest item2 in list) { item2.onComplete += delegate { reqCount--; if (reqCount <= 0) { onComplete(); if (!downloadOnly) { loadStatus = LoadStatus.LoadComplete; } } }; } Request(list); return(list); }
public void Remove(DataLoadRequest req) { string cachePath = GetCachePath(req); File.Delete(cachePath); }
private void Request(DataLoadRequest req) { dataLoader.Request(req); }
public void DependsOn(DataLoadRequest depReq) { depReqs.Add(depReq); }
private IEnumerator Load(DataLoadRequest req, bool downloadOnly, bool useQueue, bool forceDownload = false) { int i = 0; for (int len = req.depReqs.Count; i < len; i++) { while (!req.depReqs[i].isCompleted) { yield return((object)null); } } DataTableLoadError error = DataTableLoadError.None; byte[] bytes = null; if (!cache.IsCached(req) || forceDownload) { IEnumerator download = Download(req, delegate(byte[] b) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_00f7: stateMachine*/)._003Cbytes_003E__3 = b; }, delegate(DataTableLoadError e) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_0103: stateMachine*/)._003Cerror_003E__2 = e; }); while (download.MoveNext()) { yield return(download.Current); } if (error != 0) { if (useQueue) { RemoveQueue(req); } if (req.enableLoadBinaryData) { req.enableLoadBinaryData = false; Request(req); } else { req.OnError(error); } yield break; } } if (downloadOnly) { bool wait = true; ThreadPoolWrapper.QueueUserWorkItem(delegate { try { if (((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003Cbytes_003E__3 != null) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003Cerror_003E__2 = ((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003C_003Ef__this.Save(((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/).req, ((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003Cbytes_003E__3); } } catch (Exception) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003Cerror_003E__2 = DataTableLoadError.FileReadError; } finally { ((_003CLoad_003Ec__Iterator234) /*Error near IL_01cc: stateMachine*/)._003Cwait_003E__6 = false; } }); while (wait) { yield return((object)null); } if (error == DataTableLoadError.None) { req.OnComplete(); } else { req.OnError(error); } if (useQueue) { RemoveQueue(req); } } else { Stopwatch sw = Stopwatch.StartNew(); IEnumerator loading; if (req.enableLoadBinaryData) { loading = LoadCompressedBinary(req, bytes, delegate(DataTableLoadError e) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_027b: stateMachine*/)._003Cerror_003E__2 = e; }, useQueue); while (loading.MoveNext()) { yield return(loading.Current); } if (error != 0) { if (useQueue) { requestList.Remove(req); } req.enableLoadBinaryData = false; Request(req); yield break; } } else { loading = LoadCompressedTextWithSignature(req, bytes, delegate(DataTableLoadError e) { ((_003CLoad_003Ec__Iterator234) /*Error near IL_0330: stateMachine*/)._003Cerror_003E__2 = e; }, useQueue); } while (loading.MoveNext()) { yield return(loading.Current); } sw.Stop(); if (error != 0) { req.OnError(error); } else { req.OnComplete(); } if (useQueue) { RemoveQueue(req); } } }
public bool IsCached(DataLoadRequest req) { return(File.Exists(GetCachePath(req))); }