Esempio n. 1
0
        public static SwfDecompiledMap ReadSwfMap(string id, string mapid)
        {
            string           path       = (Constants.MapsPath + $"{id}" + "_" + $"{mapid}X.swf");
            SwfReader        Reader     = new SwfReader(path);
            Swf              swf        = Reader.ReadSwf();
            SwfDecompiledMap mapDatas   = null;
            IEnumerator      enumerator = swf.Tags.GetEnumerator();

            while (enumerator.MoveNext())
            {
                BaseTag current = (BaseTag)enumerator.Current;

                if (current.ActionRecCount != 0)
                {
                    string      sb = "";
                    IEnumerator currentenumerator = current.GetEnumerator();
                    while (currentenumerator.MoveNext())
                    {
                        Decompiler decompiler = new Decompiler(swf.Version);
                        ArrayList  actions    = decompiler.Decompile((byte[])currentenumerator.Current);

                        foreach (BaseAction obj in actions)
                        {
                            sb += obj.ToString();
                        }
                    }
                    mapDatas = ParseSwfMapDatas(sb);
                }
            }
            Reader.Close();
            return(mapDatas);
        }
Esempio n. 2
0
        public static List <MapDatas> ReadListSwfMap(string id)
        {
            List <MapDatas> MapList = new List <MapDatas>();
            List <string>   Files   = Directory.GetFiles(Constants.MapsPath, "*.swf").ToList();

            Files = Files.Where(x => x.Contains("\\" + id)).ToList();
            SwfReader Reader;

            foreach (var mapFile in Files)
            {
                string path = mapFile;

                Reader = new SwfReader(path);
                Swf swf = Reader.ReadSwf();

                IEnumerator enumerator = swf.Tags.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    BaseTag current = (BaseTag)enumerator.Current;
                    if (current.ActionRecCount != 0)
                    {
                        string      sb = "";
                        IEnumerator currentenumerator = current.GetEnumerator();
                        while (currentenumerator.MoveNext())
                        {
                            Decompiler decompiler = new Decompiler(swf.Version);
                            ArrayList  actions    = decompiler.Decompile((byte[])currentenumerator.Current);

                            foreach (BaseAction obj in actions)
                            {
                                sb += obj.ToString();
                            }
                        }
                        SwfDecompiledMap content = ParseSwfMapDatas(sb);
                        content.DecypheredMapData = Hash.DecypherData(content.CypheredMapData, MapKeyCracker.MapCrackKey(content.CypheredMapData));
                        GlobalMapsInfos.First(x => x.Id == content.Id).SwfDatas.MapId = path.Substring(path.IndexOf(id) + id.Length + 1, path.IndexOf(".swf") - (path.IndexOf(id) + id.Length + 1));
                        GlobalMapsInfos.First(x => x.Id == content.Id).SwfDatas       = content;
                        MapList.Add(GlobalMapsInfos.First(x => x.SwfDatas == content));
                        sb = "";
                    }
                }
                Reader.Close();
                swf = null;
            }
            string firstValue = MapList.First().SwfDatas.DecypheredMapData;

            if (MapList.All(x => x.SwfDatas.DecypheredMapData == firstValue))
            {
                return new List <MapDatas>()
                       {
                           MapList.First()
                       }
            }
            ;
            return(MapList);
        }
Esempio n. 3
0
        public static MapDatas GetMapContent(string id, string mapid, string map_key = "")
        {
            if (!GamePathFound)
            {
                DownloadMap(id, mapid);
            }

            SwfDecompiledMap map = ReadSwfMap(id, mapid);

            GlobalMapsInfos.First(x => x.Id == map.Id).SwfDatas = map;
            if (map_key != "")
            {
                map.DecypheredMapData = Hash.DecypherData(map.CypheredMapData, map_key);
            }
            return(GlobalMapsInfos.First(x => x.Id == map.Id));
        }
Esempio n. 4
0
        public static SwfDecompiledMap ParseSwfMapDatas(string sb)
        {
            SwfDecompiledMap map = new SwfDecompiledMap
            {
                CypheredMapData = sb.Substring(sb.IndexOf("mapData','") + "mapData','".Length, sb.IndexOf("push") - (sb.IndexOf("mapData','") + "mapData','".Length)).Replace("'", ""),
                OutDoor         = sb.Contains("True")
            };

            sb = sb.Replace(StringHelper.UppercaseFirst(map.OutDoor.ToString()), "");
            sb = sb.Replace("(1 args)", "");
            string          regex   = @"push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push  as bool setVariablepush ([0-9]*?) as var push ([0-9]*?) as int setVariablepush ([0-9]*?) as var push ([0-9]*?) as var setVariableend";
            MatchCollection matches = Regex.Matches(sb, regex);

            map.Id     = int.Parse(matches.First().Groups[1].Value);
            map.Width  = int.Parse(matches.First().Groups[3].Value);
            map.Height = int.Parse(matches.First().Groups[5].Value);
            GlobalMapsInfos.First(x => x.Id == map.Id).SwfDatas = map;

            return(map);
        }