// Token: 0x060004F2 RID: 1266 RVA: 0x0001CB50 File Offset: 0x0001AD50 private static void ParseMapFiles() { if (MapHack._maps != null) { return; } Dictionary <string, Tile[]> dictionary = new Dictionary <string, Tile[]>(); foreach (object obj in new ResourceManager(typeof(Resources)).GetResourceSet(CultureInfo.CurrentUICulture, true, true)) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; string text = dictionaryEntry.Key.ToString(); if (text.StartsWith("map_")) { byte[] array = dictionaryEntry.Value as byte[]; if (array != null) { using (MemoryStream memoryStream = new MemoryStream(MapHack.Unzip(array))) { BinaryReader binaryReader = new BinaryReader(memoryStream); List <Tile> list = new List <Tile>(); while (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { ushort type = binaryReader.ReadUInt16(); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { byte[] array2 = binaryReader.ReadBytes(3); if (array2.Length == 3) { MapHack.ShortPos shortPos = MapHack.ShortPos.Decompress(array2); list.Add(new Tile(shortPos.X, shortPos.Y, type)); } } } dictionary.Add(text.Replace('_', ' '), list.ToArray()); } } } } MapHack._maps = new Dictionary <string, Tile[]>(dictionary.Count); MapHack._realms = new Dictionary <byte, Dictionary <MapHack.ShortPos, ushort> >(); foreach (KeyValuePair <string, Tile[]> keyValuePair in dictionary) { if (keyValuePair.Key.StartsWith("Realm of the Mad God World ") && keyValuePair.Key.EndsWith(" sand")) { string text2 = keyValuePair.Key.Substring(27); byte key = byte.Parse(text2.Substring(0, (text2[1] != ' ') ? 2 : 1)); Dictionary <MapHack.ShortPos, ushort> value = keyValuePair.Value.ToDictionary((Tile tile) => new MapHack.ShortPos(tile.X, tile.Y), (Tile tile) => tile.Type); MapHack._realms.Add(key, value); } else { Tile[] value2 = keyValuePair.Value.ToArray <Tile>(); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(keyValuePair.Key); MapHack._maps.Add(fileNameWithoutExtension, value2); } } }
// Token: 0x060004F4 RID: 1268 RVA: 0x0001CFF8 File Offset: 0x0001B1F8 public void Update(UpdatePacket update) { if (!Settings.Default.EnableMapHack) { return; } if (this._needsNewTiles && MapHack._maps != null) { if (this._needsScan && this.client.MapName == "Realm of the Mad God") { this._realmTiles.AddRange(update.Tiles); foreach (KeyValuePair <byte, Dictionary <MapHack.ShortPos, ushort> > keyValuePair in MapHack._realms) { int num = this._mapScores[(int)keyValuePair.Key]; foreach (Tile tile in this._realmTiles) { MapHack.ShortPos key = new MapHack.ShortPos(tile.X, tile.Y); if (keyValuePair.Value.ContainsKey(key) && keyValuePair.Value[key] == tile.Type) { num++; } } this._mapScores[(int)keyValuePair.Key] = num; if (num > 250) { this._realmTiles.Clear(); if (!MapHack._fpMap.ContainsKey(this._fp)) { MapHack._fpMap.Add(this._fp, (int)keyValuePair.Key); } else { MapHack._fpMap[this._fp] = (int)keyValuePair.Key; } this._needsScan = false; this._mapToReplace = MapHack._maps[string.Format("Realm of the Mad God World {0}", keyValuePair.Key)]; break; } } } if (this._mapToReplace == null) { return; } List <Tile> list = new List <Tile>(Math.Min(this._mapToReplace.Length + update.Tiles.Length, 2048)); list.AddRange(update.Tiles); int i; for (i = this._index; i < this._mapToReplace.Length; i++) { list.Add(this._mapToReplace[i]); if (list.Count == 2048) { break; } } this._index = i; update.Tiles = list.ToArray(); if (i == this._mapToReplace.Length) { Console.WriteLine(string.Format("Finished replacing whole map! {0} total tiles replaced", this._index)); this._needsNewTiles = false; } } }