Beispiel #1
0
        /// <summary>
        /// Usefull function for blindly importing a file.
        /// </summary>
        /// <param name="name">The name of the file.</param>
        /// <param name="archive">The manager to search for the file in.</param>
        /// <returns></returns>
        public List <byte[]> ImportFile(string name, IWitcherArchive archive)
        {
            List <byte[]> ret = new List <byte[]>();

            archive.FileList.ToList().Where(x => x.Name.Contains(name)).ToList().ForEach(x =>
            {
                using (var ms = new MemoryStream())
                {
                    x.Extract(ms);
                    ret.Add(ms.ToArray());
                }
            });
            return(ret);
        }
Beispiel #2
0
 public SpeechEntry(IWitcherArchive bundle, LanguageSpecificID id, UInt32 id_high, UInt32 wem_offs, UInt32 wem_size, UInt32 cr2w_offs, UInt32 cr2w_size, Single duration)
 {
     this.Bundle     = bundle;
     this.id         = id;
     this.id_high    = id_high;
     this.wem_offs   = wem_offs;
     this.wem_size   = wem_size;
     this.cr2w_offs  = cr2w_offs;
     this.cr2w_size  = cr2w_size;
     this.duration   = duration;
     this.Size       = wem_size + cr2w_size;
     this.ZSize      = wem_size + cr2w_size;
     this.Name       = id.ToString() + ".cr2w_wem_pair";
     this.PageOffset = cr2w_offs;
 }
        /*
         * 4 bytes for id (String), usually CPSW
         * 4 bytes for version (Number), usually A2 00 00 00 or A3 00 00 00
         * 2 bytes for key1 (Number), part of the language key
         * variable amount of bytes for wavecr2w pair count
         * for each wemcr2w pair:
         *  4 bytes for language specific id (Number)
         *  4 bytes for some other id (Number)
         *  4 bytes for absolute offset (Number), points at (a) down below
         *  4 bytes of zeros
         *  4 bytes of (wem size + 12) (Number) (c)
         *  4 bytes of zeros
         *  4 bytes for absolute offset (Number), points at (b) down below
         *  4 bytes of zeros
         *  4 bytes of cr2w size (Number) (d)
         *  4 bytes of zeros
         * 2 bytes for key2 (Number), part of the language key
         * for each wemcr2w pair:
         *  4 bytes for wem size (Number) (a)
         *  c - 12 bytes for wem (raw data)
         *  4 bytes for duration in seconds (Float)
         *  4 bytes of 04 00 00 00
         *  d bytes for cr2w (raw data) (b)
         */

        /// <summary>
        /// Parse information about the w3speech format from the BinaryReader.
        /// </summary>
        /// <param name="br">The stream containing the w3speech format to read from.</param>
        /// <returns>All information found inside the stream.</returns>
        /// <exception cref="Exception">Something happened.</exception>
        public static W3Speech Decode(IWitcherArchive parent, BinaryReader br)
        {
            var str            = System.Text.Encoding.Default.GetString(br.ReadBytes(4));
            var version        = br.ReadUInt32();
            var key1           = br.ReadUInt16();
            var item_count     = br.ReadBit6();
            var raw_item_infos = new List <Tuple <uint, uint, uint, uint, uint, uint> >();

            for (var i = 0; i < item_count.value; i += 1)
            {
                var lang_specific_ID = br.ReadUInt32();
                var id_high          = br.ReadUInt32();
                var wave_offs        = br.ReadUInt32() + 4;
                br.ReadUInt32();
                var wave_size = br.ReadUInt32() - 12;
                br.ReadUInt32();
                var cr2w_offs = br.ReadUInt32();
                br.ReadUInt32();
                var cr2w_size = br.ReadUInt32();
                br.ReadUInt32();
                raw_item_infos.Add(Tuple.Create(lang_specific_ID, id_high, wave_offs, wave_size, cr2w_offs, cr2w_size));
            }
            var key2       = br.ReadUInt16(); //BUG: This break sometimes! "D:\\SteamLibrary\\steamapps\\common\\TW3\\bin\\x64\\..\\..\\DLC\\DLC1\\content\\brpc.w3speech"
            var key        = new W3LanguageKey((UInt32)(key1 << 16 | key2));
            var position   = 4 + 4 + 2 + ((UInt64)item_count.length) + ((UInt64)item_count.value * 10 * 4) + 2;
            var item_infos = raw_item_infos
                             .OrderBy(t => t.Item3)
                             .Select(t =>
            {
                var duration_offset = t.Item3 - position + t.Item4;
                StreamTools.Skip(duration_offset, br.BaseStream);
                position    += duration_offset;
                var duration = br.ReadSingle();
                position    += 4;
                return(new SpeechEntry(parent, new LanguageSpecificID(t.Item1), t.Item2, t.Item3, t.Item4, t.Item5, t.Item6, duration));
            })
                             .ToList()
                             .AsReadOnly();

            return(new W3Speech(parent.ArchiveAbsolutePath, str, version, key, item_infos));
        }
Beispiel #4
0
 public IBundleWrapper(IWitcherArchive bundle)
 {
     Bundle = bundle;
 }
Beispiel #5
0
 public SoundCacheItem(IWitcherArchive Parent)
 {
     this.Bundle = Parent;
 }
Beispiel #6
0
 public TextureCacheItem(IWitcherArchive parent)
 {
     Bundle = parent;
 }