コード例 #1
0
ファイル: SongInformation.cs プロジェクト: KHCmaster/PPD
        /// <summary>
        /// 難易度の数値化したデータを取得します。
        /// </summary>
        /// <param name="difficulty">難易度。</param>
        /// <returns>数値化された難易度。</returns>
        public ScoreDifficultyMeasureResult CalculateDifficulty(Difficulty difficulty)
        {
            var path = Path.Combine(DirectoryPath, String.Format("{0}.ppd", difficulty));

            MarkDataBase[] data = null;
            if (IsOld)
            {
                data = PPDReader.Read(path);
            }
            else
            {
                try
                {
                    using (PackReader pr = new PackReader(path))
                    {
                        var pppsr = pr.Read("ppd");
                        data = PPDReader.Read(pppsr);
                    }
                }
                catch
                {
                    try
                    {
                        data = PPDReader.Read(path);
                    }
                    catch
                    {
                    }
                }
            }
            return(ScoreDifficultyMeasure.Measure(data));
        }
コード例 #2
0
        public static PPDPlayDecorder FromBytes(byte[] bytes)
        {
            int             version = 0;
            PPDPlayDecorder ret     = null;

            using (MemoryStream stream = new MemoryStream(bytes))
                using (PackReader reader = new PackReader(stream))
                {
                    foreach (string name in reader.FileList)
                    {
                        var streamReader = reader.Read(name);
                        switch (name)
                        {
                        case "Version":
                            version = streamReader.ReadByte();
                            break;

                        case "Data":
                            ret = FromStream(streamReader);
                            break;
                        }
                    }
                }
            if (version != 2)
            {
                throw new Exception(String.Format("Not Supported Replay Data:{0}", version));
            }
            return(ret);
        }
コード例 #3
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void Save()
        {
            var path     = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");
            var contents = File.ReadAllBytes(path);
            var tempPath = Path.GetTempFileName();

            using (var pf = new PackFile(path))
            {
                pf.Save(tempPath);
            }

            using (var pf = new PackFile(tempPath))
            {
                var entry = pf.GetEntry(@"data\local\xml\auctioncategory.english.txt");
                Assert.NotEqual(null, entry);

                using (var sr = new StreamReader(entry.GetDataAsFileStream()))
                {
                    Assert.Equal(sr.ReadLine(), "1\tMelee Weapon");
                    Assert.Equal(sr.ReadLine(), "2\tOne-Handed");
                    Assert.Equal(sr.ReadLine(), "3\tTwo-Handed");
                }
            }

            File.Delete(tempPath);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("PPDUnpack.exe [packfile]");
                return;
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("File does not exist.");
                return;
            }

            var baseDir = Path.GetFileNameWithoutExtension(args[0]);

            using (PackReader reader = new PackReader(args[0]))
            {
                foreach (var name in reader.FileList)
                {
                    var    r = reader.Read(name);
                    byte[] b = new byte[r.Length];
                    r.Read(b, 0, b.Length);
                    var fileName = Path.Combine(baseDir, name);
                    var dirName  = Path.GetDirectoryName(fileName);
                    if (!String.IsNullOrEmpty(dirName))
                    {
                        Directory.CreateDirectory(dirName);
                    }
                    File.WriteAllBytes(fileName, b);
                }
            }
        }
コード例 #5
0
        private void Initialize(string resourceFilePath, string spriteDirName)
        {
            soundDict       = new Dictionary <string, byte[]>();
            othersDict      = new Dictionary <string, byte[]>();
            createdVertices = new List <VertexInfo>();
            pathManager     = new PathManager("");

            if (File.Exists(resourceFilePath))
            {
                try
                {
                    using (PackReader packReader = new PackReader(resourceFilePath))
                    {
                        UnPackAll(packReader, spriteDirName, File.GetLastWriteTime(resourceFilePath));
                    }
                    initialized = true;
                }
                catch (Exception e)
                {
#if DEBUG
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
#endif
                }
            }
        }
コード例 #6
0
        public static GitObjectBase ReadGitObject(string repositoryPath, ObjectHash hash)
        {
            var gitObject = PackReader.GetObject(hash);

            if (gitObject != null)
            {
                return(gitObject);
            }

            var fileContent  = HashContent.FromFile(repositoryPath, hash.ToString());
            var contentIndex = fileContent.AsSpan(7).IndexOf <byte>(0) + 8;

            if (IsCommit(fileContent))
            {
                return(new Commit(hash, fileContent.AsSpan(contentIndex).ToArray()));
            }

            if (IsTree(fileContent))
            {
                return(new Tree(hash, fileContent.AsMemory(contentIndex)));
            }

            if (IsTag(fileContent))
            {
                return(new Tag(hash, fileContent.AsMemory(contentIndex)));
            }

            // TODO blobs probably not working atm
            if (IsBlob(fileContent))
            {
                return(new Blob(hash, fileContent.AsMemory(contentIndex)));
            }

            return(null);
        }
コード例 #7
0
        public void Create()
        {
            try
            {
                tcpClient = new TcpClient(LocalHost, Port);

                var bytes = GetBytes(new string[] { MethodName }, writer =>
                {
                    switch (writer.Filename)
                    {
                    case MethodName:
                        WriteString(writer, GetFileList);
                        break;
                    }
                });
                Send(bytes);
                bytes = Read(tcpClient.GetStream());
                string[] fileNames;
                using (MemoryStream stream = new MemoryStream(bytes))
                    using (PackReader reader = new PackReader(stream))
                    {
                        var ret = ParseString(reader, Return);
                        fileNames = ret.Split(',');
                    }

                foreach (var fileName in fileNames)
                {
                    bytes = GetBytes(new string[] { MethodName, FileName }, writer =>
                    {
                        switch (writer.Filename)
                        {
                        case MethodName:
                            WriteString(writer, GetBreakPoints);
                            break;

                        case FileName:
                            WriteString(writer, fileName);
                            break;
                        }
                    });
                    Send(bytes);
                    bytes = Read(tcpClient.GetStream());
                    using (MemoryStream stream = new MemoryStream(bytes))
                        using (PackReader reader = new PackReader(stream))
                        {
                            var ret = ParseString(reader, Return);
                            if (!String.IsNullOrEmpty(ret))
                            {
                                breakPoints.Add(fileName, ret.Split(',').Select(s => int.Parse(s)).ToArray());
                            }
                        }
                }

                connected = true;
            }
            catch
            {
            }
        }
コード例 #8
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void OpenReader()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");

            using (var pf = new PackFile(path))
            {
                Assert.InRange(pf.Count, 1, 100000);
            }
        }
コード例 #9
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
 public void OpenReaderWithInvalidPath()
 {
     Assert.Throws(typeof(ArgumentException), () =>
     {
         using (var pr = new PackReader("some/path/that/hopefully/doesn't/exist"))
         {
         }
     });
 }
コード例 #10
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
        public void GetEntry()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            using (var pr = new PackReader(path))
            {
                var entry = pr.GetEntry(@"data\db\race.xml");
                Assert.NotEqual(null, entry);
            }
        }
コード例 #11
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void GetEntry()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");

            using (var pf = new PackFile(path))
            {
                var entry = pf.GetEntry(@"data\local\xml\arbeit.english.txt");
                Assert.NotEqual(null, entry);
            }
        }
コード例 #12
0
        /// <summary>
        /// Closes open pack reader.
        /// </summary>
        public void ClosePackReader()
        {
            if (_packReader == null)
            {
                return;
            }

            _packReader.Close();
            _packReader = null;
        }
コード例 #13
0
        private Version ReadVersion(PackReader reader, string key)
        {
            var str = ReadString(reader, key);

            if (String.IsNullOrEmpty(str))
            {
                return(new Version("0.0.0.0"));
            }
            return(new Version(str));
        }
コード例 #14
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
        public void OpenReader()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            using (var pr = new PackReader(path))
            {
                Assert.InRange(pr.Count, 1, 100000);
                Assert.InRange(pr.PackCount, 1, 1000);
            }
        }
コード例 #15
0
ファイル: SongInformation.cs プロジェクト: KHCmaster/PPD
        private static SongInformation AnalyzeEVD(string path, SongInformation si, Difficulty difficulty)
        {
            try
            {
                IEVDData[] data = null;
                if (si.IsOld)
                {
                    data = EVDReader.Read(path);
                }
                else
                {
                    var pr    = new PackReader(path);
                    var pppsr = pr.Read("evd");
                    data = EVDReader.Read(pppsr);
                    pr.Close();
                }
                foreach (ChangeVolumeEvent evddata in Array.FindAll(data, (evd) => (evd is ChangeVolumeEvent)))
                {
                    if (evddata.Channel == 0 && evddata.Time == 0)
                    {
                        si.MovieVolume = -100 * (100 - evddata.Volume);
                        break;
                    }
                }
                foreach (ChangeNoteTypeEvent evddata in Array.FindAll(data, (evd) => (evd is ChangeNoteTypeEvent)))
                {
                    if (evddata.NoteType == NoteType.AC || evddata.NoteType == NoteType.ACFT)
                    {
                        switch (difficulty)
                        {
                        case PPDFrameworkCore.Difficulty.Easy:
                            si.EasyNoteType = evddata.NoteType;
                            break;

                        case PPDFrameworkCore.Difficulty.Normal:
                            si.NormalNoteType = evddata.NoteType;
                            break;

                        case PPDFrameworkCore.Difficulty.Hard:
                            si.HardNoteType = evddata.NoteType;
                            break;

                        case PPDFrameworkCore.Difficulty.Extreme:
                            si.ExtremeNoteType = evddata.NoteType;
                            break;
                        }
                        break;
                    }
                }
            }
            catch
            {
            }
            return(si);
        }
コード例 #16
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
        public void GetEntriesByFileName()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            using (var pr = new PackReader(path))
            {
                var entries = pr.GetEntriesByFileName("money.raw");
                Assert.True(entries.Count > 0);
                Assert.Single(entries, a => a.RelativePath == @"color\money.raw");
            }
        }
コード例 #17
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void GetEntriesByFileName()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");

            using (var pf = new PackFile(path))
            {
                var entries = pf.GetEntriesByFileName(@"auctioncategory.english.txt");
                Assert.True(entries.Count > 0);
                Assert.Single(entries, a => a.RelativePath == @"xml\auctioncategory.english.txt");
            }
        }
コード例 #18
0
        /// <summary>
        /// Returns pack reader to read files inside packages from.
        /// </summary>
        /// <returns></returns>
        public PackReader GetPackReader()
        {
            lock (_syncLock)
            {
                if (_packReader == null)
                {
                    _packReader = new PackReader(this.PackagePath);
                }
            }

            return(_packReader);
        }
コード例 #19
0
        public World(PackReader pack)
        {
            this.Regions = new List <Region>();

            Dictionary <int, PropClass> propClasses;

            using (var ms = pack.GetEntry(@"db\propdb.xml").GetDataAsStream())
                propClasses = PropClass.ReadFromXml(ms);

            FeaturesFile features;

            using (var ms = pack.GetEntry(@"features.xml.compiled").GetDataAsStream())
                features = new FeaturesFile(ms, "Regular, USA");

            using (var ms = pack.GetEntry(@"world\world.trn").GetDataAsStream())
                using (var trnReader = XmlReader.Create(ms))
                {
                    if (!trnReader.ReadToDescendant("regions"))
                    {
                        return;
                    }

                    using (var trnRegionsReader = trnReader.ReadSubtree())
                    {
                        var i = 1;
                        while (trnRegionsReader.ReadToFollowing("region"))
                        {
                            var workDir  = trnRegionsReader.GetAttribute("workdir");
                            var fileName = trnReader.GetAttribute("name");

                            Console.Write("\r".PadRight(70) + "\r");
                            Console.Write("Reading {0}: {1}...", i++, fileName);

                            var region = new Region(pack, workDir, fileName, propClasses, features);
                            this.Regions.Add(region);
                        }

                        Console.WriteLine("\r".PadRight(70) + "\r");
                    }
                }

            Regions = Regions.OrderBy(a => a.RegionId).ToList();
            Regions.ForEach(region =>
            {
                region.Areas = region.Areas.ToList();
                region.Areas.ForEach(area =>
                {
                    area.Props  = area.Props.OrderBy(prop => prop.PropId).ToList();
                    area.Events = area.Events.OrderBy(ev => ev.EventId).ToList();
                });
            });
        }
コード例 #20
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
        public void GetData()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            using (var pr = new PackReader(path))
            {
                var itemdb = pr.GetEntry(@"data\db\itemdb.xml");
                Assert.NotEqual(null, itemdb);

                var data = itemdb.GetData();
                Assert.Equal("FF-FE-3C-00-3F-00-78-00-6D-00-6C-00-20-00-76-00-65-00-72-00-73-00-69-00-6F-00-6E-00-3D-00-22-00-31-00-2E-00-30-00-22-00-20-00-65-00-6E-00-63-00-6F-00-64-00-69-00-6E-00-67-00-3D-00-22-00-75-00-74-00-66-00-2D-00-31-00-36-00-22-00-3F-00-3E-00-0D-00-0A-00-3C-00-21-00-2D-00-2D-00-20-00-44-00-4F-00-20-00-4E-00-4F-00-54-00-20-00-45-00-44-00-49-00-54-00-20-00-54-00-48-00-49-00-53-00-20-00-46-00-49-00-4C-00-45-00-21-00-20-00-2D-00-2D-00-3E-00-0D-00-0A-00-3C-00-49-00-74-00-65-00-6D-00-73-00-3E-00", BitConverter.ToString(data, 0, 164));
            }
        }
コード例 #21
0
 private string ReadString(PackReader reader, string key, string defaultValue = "")
 {
     using (PPDPackStreamReader packReader = reader.Read(key))
     {
         if (packReader == null)
         {
             return(defaultValue);
         }
         byte[] bytes = new byte[packReader.Length];
         packReader.Read(bytes, 0, bytes.Length);
         return(Encoding.UTF8.GetString(bytes));
     }
 }
コード例 #22
0
        protected int ParseInt(PackReader reader, string keyName)
        {
            if (reader.FileList.Contains(keyName))
            {
                using (PPDPackStreamReader packStreamReader = reader.Read(keyName))
                {
                    byte[] data = new byte[sizeof(int)];
                    packStreamReader.Read(data, 0, data.Length);
                    var ret = BitConverter.ToInt32(data, 0);
                    return(ret);
                }
            }

            return(0);
        }
コード例 #23
0
ファイル: Pack.cs プロジェクト: dlamkins/TmfLib
        private async Task <IPackCollection> LoadMapFromOptimizedMarkerPackAsync(int mapId, IPackCollection packCollection, PackReaderSettings packReaderSettings = null)
        {
            var collection = packCollection ?? new PackCollection();

            var reader = new PackReader(collection, this.ResourceManager, packReaderSettings);

            await reader.PopulatePackFromStream(await _dataReader.GetFileStreamAsync(PackConstImpl.FILE_OPTIMIZED_MARKERCATEGORIES));

            if (_dataReader.FileExists(string.Format(PackConstImpl.FILE_OPTIMIZED_MAPPATHABLES, mapId)))
            {
                await reader.PopulatePackFromStream(await _dataReader.GetFileStreamAsync(string.Format(PackConstImpl.FILE_OPTIMIZED_MAPPATHABLES, mapId)));
            }

            return(collection);
        }
コード例 #24
0
        private bool CheckNearTime()
        {
            bool found             = false;
            var  checkTimeInterval = 1 / 60f;

            foreach (AvailableDifficulty difficulty in EditorForm.DifficultyArray)
            {
                if (difficulty == AvailableDifficulty.None)
                {
                    continue;
                }
                if ((PublishDifficulty & difficulty) == difficulty)
                {
                    var filePath = Path.Combine(WindowUtility.MainForm.CurrentProjectDir, difficulty + ".ppd");
                    using (PackReader reader = new PackReader(filePath))
                    {
                        if (reader.FileList.Contains("ppd"))
                        {
                            var r         = reader.Read("ppd");
                            var data      = PPDReader.Read(r);
                            var timeDatas = new Dictionary <ButtonType, SortedSet <float> >();
                            foreach (var d in data)
                            {
                                if (!timeDatas.TryGetValue(d.ButtonType, out SortedSet <float> set))
                                {
                                    set = new SortedSet <float>();
                                    timeDatas.Add(d.ButtonType, set);
                                }
                                foreach (var setVal in set)
                                {
                                    if (Math.Abs(setVal - d.Time) <= checkTimeInterval)
                                    {
                                        MessageBox.Show(Utility.Language["NearTimeWarning"] + "\n" +
                                                        Utility.Language["Difficulty"] + ":" + difficulty + "\n" +
                                                        Utility.Language["Time"] + ":" + d.Time + "\n" +
                                                        Utility.Language["ButtonType"] + ":" + Utility.Language[d.ButtonType.ToString()] + "\n");
                                        found = true;
                                        break;
                                    }
                                }
                                set.Add(d.Time);
                            }
                        }
                    }
                }
            }
            return(!found);
        }
コード例 #25
0
        protected string ParseString(PackReader reader, string keyName)
        {
            if (reader.FileList.Contains(keyName))
            {
                using (PPDPackStreamReader packStreamReader = reader.Read(keyName))
                {
                    using (StreamReader streamReader = new StreamReader(packStreamReader, Encoding.UTF8))
                    {
                        var ret = streamReader.ReadToEnd();
                        return(ret);
                    }
                }
            }

            return(null);
        }
コード例 #26
0
        /// <summary>
        /// Returns the path of the package folder.
        /// </summary>
        /// <returns></returns>
        public static string GetPackagePath()
        {
            if (Directory.Exists("package"))
            {
                return("package");
            }

            var mabiPackagePath = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            if (Directory.Exists(mabiPackagePath))
            {
                return(mabiPackagePath);
            }

            return(null);
        }
コード例 #27
0
ファイル: PackReader.cs プロジェクト: xyfc/MackLib
        public void ReadingFileStream()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package");

            using (var pr = new PackReader(path))
            {
                var itemdb = pr.GetEntry(@"data\db\keyword.xml");
                Assert.NotEqual(null, itemdb);

                using (var sr = new StreamReader(itemdb.GetDataAsFileStream()))
                {
                    Assert.Equal(sr.ReadLine(), "<?xml version=\"1.0\" encoding=\"utf-16\"?>");
                    Assert.Equal(sr.ReadLine(), "<!-- DO NOT EDIT THIS FILE! -->");
                    Assert.Equal(sr.ReadLine(), "<Keyword>");
                }
            }
        }
コード例 #28
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void ReadingFileStream()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");

            using (var pf = new PackFile(path))
            {
                var entry = pf.GetEntry(@"data\local\xml\arbeit.english.txt");
                Assert.NotEqual(null, entry);

                using (var sr = new StreamReader(entry.GetDataAsFileStream()))
                {
                    Assert.Equal(sr.ReadLine(), "1\tGeneral");
                    Assert.Equal(sr.ReadLine(), "2\tGrocery Store");
                    Assert.Equal(sr.ReadLine(), "3\tChurch");
                }
            }
        }
コード例 #29
0
ファイル: Program.cs プロジェクト: twwilliams/GitRewrite
        static void Main(string[] args)
        {
            if (!CommandLineOptions.TryParse(args, out var options))
            {
                return;
            }

            PackReader.InitializePackFiles(options.RepositoryPath);

            if (options.FixTrees)
            {
                var defectiveCommits = FindCommitsWithDuplicateTreeEntries(options.RepositoryPath).ToList();

                var rewrittenCommits = FixDefectiveCommits(options.RepositoryPath, defectiveCommits);
                if (rewrittenCommits.Any())
                {
                    Refs.Update(options.RepositoryPath, rewrittenCommits);
                }
            }
            else if (options.FilesToDelete.Any() || options.FoldersToDelete.Any())
            {
                using (var task = new DeletionTask(options.RepositoryPath, options.FilesToDelete, options.FoldersToDelete, options.ProtectRefs))
                    task.Run();
            }
            else if (options.RemoveEmptyCommits)
            {
                using (var removeEmptyCommitsTask = new RemoveEmptyCommitsTask(options.RepositoryPath))
                    removeEmptyCommitsTask.Run();
            }
            else if (!string.IsNullOrWhiteSpace(options.ContributorMappingFile))
            {
                using (var rewriteContributorTask = new RewriteContributorTask(options.RepositoryPath, options.ContributorMappingFile))
                    rewriteContributorTask.Run();
            }
            else if (options.ListContributorNames)
            {
                foreach (var contributor in CommitWalker.CommitsRandomOrder(options.RepositoryPath)
                         .SelectMany(commit => new[] { commit.GetAuthorName(), commit.GetCommitterName() })
                         .Distinct()
                         .AsParallel()
                         .OrderBy(x => x))
                {
                    Console.WriteLine(contributor);
                }
            }
        }
コード例 #30
0
ファイル: PackFile.cs プロジェクト: xyfc/MackLib
        public void FullPath()
        {
            var path = Path.Combine(PackReader.GetMabinogiDirectory(), "package", "language.pack");

            using (var pf = new PackFile(path))
            {
                // Previously the base path was ignored, which meant that
                // entries from language.pack were put into the root folder,
                // and would've been found there. This messes up the folder
                // structure, and this file should actually not be found
                // in this location.

                var entry = pf.GetEntry(@"local\world.english.txt");
                Assert.Equal(null, entry);

                entry = pf.GetEntry(@"data\local\world.english.txt");
                Assert.NotEqual(null, entry);
            }
        }