Beispiel #1
0
        public bool Patch(string filepath, SpeechSkipType speechSkipType, bool makeBackup, bool patchExternalFiles)
        {
            IEnumerable <Asset> dtaFiles = BuildDTAAssetList(filepath, patchExternalFiles);

            foreach (Asset asset in dtaFiles)
            {
                if (makeBackup && !CreateBackup(asset.Filepath))
                {
                    return(false);
                }

                if (!PatchSpeechSkipType(asset.Filepath, asset.Offset, speechSkipType))
                {
                    return(false);
                }
            }

            IEnumerable <Asset> acFiles = BuildACAssetList(filepath, patchExternalFiles);

            foreach (Asset asset in acFiles)
            {
                if (makeBackup && !CreateBackup(asset.Filepath))
                {
                    return(false);
                }

                PatchSetSkipSpeechFunction(asset.Filepath);
            }

            return(true);
        }
Beispiel #2
0
        private bool PatchSpeechSkipType(string filepath, long offset, SpeechSkipType type)
        {
            long patchOffset = GetSpeechSkipOffset(filepath, offset);

            if (patchOffset < 0)
            {
                return(false);
            }

            return(SetSpeechSkipType(filepath, patchOffset, type));
        }
Beispiel #3
0
        private bool SetSpeechSkipType(string filename, long offset, SpeechSkipType type)
        {
            using (FileStream file = new FileStream(filename, FileMode.Open, FileAccess.Write))
            {
                using (BinaryWriter writer = new BinaryWriter(file, Windows1252))
                {
                    long position = writer.BaseStream.Seek(offset, SeekOrigin.Begin);
                    if (position != offset)
                    {
                        return(false);
                    }

                    writer.Write((Int32)type);
                }
            }

            return(true);
        }