public bool LoadServerList(string url, ref string errorMessage) { bool result; try { IL_00: this.m_serverListSelectIndex = 0; this.m_serverList.Clear(); if (!url.StartsWith("http")) { url = string.Format("http://{0}", url); } HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Timeout = 5000; HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); Stream responseStream = httpWebResponse.GetResponseStream(); NDataReader nDataReader = new NDataReader(); if (nDataReader.LoadFrom(responseStream, Encoding.UTF8)) { NDataSection nDataSection = nDataReader["list"]; int dataCount = nDataSection.DataCount; int[] array = new int[dataCount]; for (int i = 0; i < dataCount; i++) { array[i] = 0; } Random random = new Random(DateTime.Now.Millisecond); foreach (NDataReader.Row row in nDataSection) { ParallelServer.ServerInfo item = default(ParallelServer.ServerInfo); item.serverIP = row.GetColumn(0); item.serverPORT = Convert.ToInt32(row.GetColumn(1)); int num; do { num = random.Next(dataCount); }while (array[num] != 0); item.index = num; array[num] = 1; this.m_serverList.Add(item); } this.m_serverList.Sort((ParallelServer.ServerInfo a1, ParallelServer.ServerInfo a2) => a1.index.CompareTo(a2.index)); result = true; } else { result = false; } } catch (Exception ex) { if (this.m_retryCount++ < this.m_retryCountMax) { goto IL_00; } errorMessage = ex.Message; result = false; } return(result); }
private bool ReadFinalList2(ref NDataReader dr) { this.m_LoadPatchListVersion = 0f; string text = string.Empty; NDataSection nDataSection = dr["Header"]; text = nDataSection["PatchVersion"]; bool bUserReplaceWord = nDataSection["UseListCompressor"]; if (text.ToLower().Equals("final")) { this.m_LoadPatchListVersion = PatchFileInfo.VER_FINAL; } else { float.TryParse(text, out this.m_LoadPatchListVersion); } bool result; try { ListCompressor listCompressor = new ListCompressor(bUserReplaceWord); StringBuilder stringBuilder = new StringBuilder(512); StringBuilder stringBuilder2 = new StringBuilder(512); StringBuilder stringBuilder3 = new StringBuilder(512); this.UseFieldNames = dr.ReadFieldNames(); if (this.UseFieldNames) { this._idx_CRC = dr.GetFieldIndex("CRC"); this._idx_PatchLevel = dr.GetFieldIndex("PatchLevel"); this._idx_LangCode = dr.GetFieldIndex("LangCode"); this._idx_Prepack = dr.GetFieldIndex("UsePrepack"); } if (dr.BeginSection("[FinalList2]")) { foreach (NDataReader.Row row in dr) { if (row.LineType == NDataReader.Row.TYPE.LINE_DATA) { stringBuilder.Length = 0; stringBuilder.Append(row[0].str); stringBuilder = listCompressor.ReplaceWord(stringBuilder, false); if (stringBuilder[0] == '?') { stringBuilder.Remove(0, 1); stringBuilder3.Length = 0; stringBuilder3.Append(stringBuilder.ToString()); } else { PatchFileInfo patchFileInfo = new PatchFileInfo(); patchFileInfo.SetDataFrom(this, row); stringBuilder2.Length = 0; stringBuilder2.AppendFormat("{0}/{1}", stringBuilder3, stringBuilder); stringBuilder2 = stringBuilder2.Replace("//", "/"); string text2 = stringBuilder2.ToString(); if (this.UpdateCustomCacheInfo != null) { patchFileInfo.bUseCustomCache = this.UpdateCustomCacheInfo.CheckCustomCacheInfo(text2); } if (this.FilesList.ContainsKey(text2)) { PatchFileInfo patchFileInfo2 = new PatchFileInfo(); this.FilesList.TryGetValue(text2, out patchFileInfo2); this._OutputDebug(string.Format("Warning - duplicated patch list item : {0} / already:{1} new:{2}", text2, patchFileInfo2.Version, patchFileInfo.Version)); if (patchFileInfo2.Version < patchFileInfo.Version) { this.FilesList[text2] = patchFileInfo; } } if (patchFileInfo.bUsePrepack && !this.preResourceLastVersionList.Contains(patchFileInfo.VersionString)) { this.preResourceLastVersionList.Add(patchFileInfo.VersionString); } this.FilesList.Add(text2, patchFileInfo); } } } this.preResourceLastVersionList.Sort(); if (dr.BeginSection("[prepackVersionList]")) { string text3 = string.Empty; foreach (NDataReader.Row row2 in dr) { text3 = row2.GetColumn(0); if (!this.preResourceAllVersionList.Contains(text3)) { this.preResourceAllVersionList.Add(text3); } } this.preResourceAllVersionList.Sort(); } result = true; } else { result = false; } } catch (Exception ex) { this._OutputDebug(ex.ToString()); result = false; } return(result); }