Пример #1
0
    // 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);
            }
        }
    }
Пример #2
0
 // Token: 0x060004F6 RID: 1270 RVA: 0x0001D2CC File Offset: 0x0001B4CC
 public void text(PlayerTextPacket playerText)
 {
     if (Settings.Default.EnableMapHack && playerText.Text == "/world" && this.client.MapName == "Realm of the Mad God")
     {
         playerText.Send = false;
         this.client._RUDdpffUqrc18m4ldj2l3yrb1t9(MapHack._fpMap.ContainsKey(this._fp) ? ("World: " + MapHack._fpMap[this._fp].ToString()) : "Unknown world");
         return;
     }
     if (playerText.Text == "/savemap")
     {
         playerText.Send = false;
         using (MemoryStream memoryStream = new MemoryStream())
         {
             BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
             Dictionary <ushort, List <byte[]> > dictionary = new Dictionary <ushort, List <byte[]> >();
             foreach (Square tiles in this.client.Tiles)
             {
                 if (tiles != null)
                 {
                     if (!dictionary.ContainsKey(tiles.Type))
                     {
                         dictionary.Add(tiles.Type, new List <byte[]>());
                     }
                     dictionary[tiles.Type].Add(MapHack.ShortPos.Compress(tiles.X, tiles.Y));
                 }
             }
             foreach (KeyValuePair <ushort, List <byte[]> > keyValuePair in dictionary)
             {
                 binaryWriter.Write(keyValuePair.Key);
                 binaryWriter.Write(keyValuePair.Value.Count);
                 foreach (byte[] buffer in keyValuePair.Value)
                 {
                     binaryWriter.Write(buffer);
                 }
             }
             byte[] bytes = MapHack.Zip(memoryStream.ToArray());
             File.WriteAllBytes(string.Concat(new string[]
             {
                 "map_",
                 this.client.MapName,
                 " ",
                 Environment.TickCount.ToString(),
                 ".gz"
             }), bytes);
         }
     }
 }
Пример #3
0
 // Token: 0x060004F3 RID: 1267 RVA: 0x0001CE34 File Offset: 0x0001B034
 public void MapInfo(MapInfoPacket mapInfo)
 {
     this._index = 0;
     if (MapHack._maps != null)
     {
         this._needsNewTiles = (this._needsScan = (mapInfo.Name == "Realm of the Mad God"));
         foreach (KeyValuePair <string, Tile[]> keyValuePair in MapHack._maps)
         {
             if (keyValuePair.Key == mapInfo.Name)
             {
                 this._mapToReplace  = keyValuePair.Value;
                 this._needsNewTiles = true;
                 this._needsScan     = false;
                 break;
             }
         }
         this._fp = mapInfo.Fp.ToString();
         if (mapInfo.Name == "Realm of the Mad God")
         {
             if (MapHack._fpMap.ContainsKey(this._fp))
             {
                 Console.WriteLine(string.Format("Using map {0} {1}", this._fp, MapHack._fpMap[this._fp]));
                 this._mapToReplace  = MapHack._maps[string.Format("Realm of the Mad God World {0}", MapHack._fpMap[this._fp])];
                 this._needsNewTiles = true;
                 this._needsScan     = false;
                 return;
             }
             this._realmTiles = new List <Tile>();
             this._mapScores  = new Dictionary <int, int>();
             foreach (KeyValuePair <byte, Dictionary <MapHack.ShortPos, ushort> > keyValuePair2 in MapHack._realms)
             {
                 this._mapScores.Add((int)keyValuePair2.Key, 0);
             }
         }
         return;
     }
     Console.WriteLine("Maps list is null, unable to replace maps, trying to parse again");
     MapHack.ParseMapFiles();
 }
Пример #4
0
 // Token: 0x060004F0 RID: 1264 RVA: 0x0001CAF4 File Offset: 0x0001ACF4
 static MapHack()
 {
     MapHack.ParseMapFiles();
 }