コード例 #1
0
ファイル: CacheFile.cs プロジェクト: Vegetal-Pole/Adjutant
        private T ReadMetadataInternal <T>()
        {
            long             address;
            DependencyReader reader;

            if (ClassCode == "sbsp")
            {
                var translator = new BSPAddressTranslator(cache, Id);
                reader  = cache.CreateReader(translator);
                address = translator.TagAddress;
            }
            else
            {
                reader  = cache.CreateReader(cache.MetadataTranslator);
                address = MetaPointer.Address;
            }

            using (reader)
            {
                reader.RegisterInstance <IIndexItem>(this);
                reader.Seek(address, SeekOrigin.Begin);
                var result = (T)reader.ReadObject(typeof(T), (int)cache.CacheType);

                if (CacheFactory.SystemClasses.Contains(ClassCode))
                {
                    metadataCache = result;
                }

                return(result);
            }
        }
コード例 #2
0
ファイル: CacheFile.cs プロジェクト: Vegetal-Pole/Adjutant
        internal void ReadItems()
        {
            using (var reader = cache.CreateReader(cache.HeaderTranslator))
            {
                var indices = new int[cache.Header.StringCount];
                reader.Seek(cache.Header.StringTableIndexAddress, SeekOrigin.Begin);
                for (int i = 0; i < cache.Header.StringCount; i++)
                {
                    indices[i] = reader.ReadInt32();
                }

                using (var reader2 = reader.CreateVirtualReader(cache.Header.StringTableAddress))
                {
                    for (int i = 0; i < cache.Header.StringCount; i++)
                    {
                        if (indices[i] < 0)
                        {
                            continue;
                        }

                        reader2.Seek(indices[i], SeekOrigin.Begin);
                        items[i] = reader2.ReadNullTerminatedString();
                    }
                }
            }
        }
コード例 #3
0
ファイル: CacheFile.cs プロジェクト: Vegetal-Pole/Adjutant
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator))
            {
                reader.Seek(TagDataAddress.Address, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    //Halo2Vista multiplayer maps have empty tags in them
                    var item = reader.ReadObject(new IndexItem(cache));
                    if (item.Id < 0)
                    {
                        continue;
                    }

                    items.Add(i, item);

                    //Halo2Vista multiplayer maps have two ugh! tags
                    if (CacheFactory.SystemClasses.Contains(item.ClassCode) && !sysItems.ContainsKey(item.ClassCode))
                    {
                        sysItems.Add(item.ClassCode, item);
                    }
                }

                reader.Seek(cache.Header.FileTableIndexOffset, SeekOrigin.Begin);
                var indices = reader.ReadEnumerable <int>(TagCount).ToArray();

                for (int i = 0; i < TagCount; i++)
                {
                    reader.Seek(cache.Header.FileTableAddress + indices[i], SeekOrigin.Begin);
                    Filenames.Add(i, reader.ReadNullTerminatedString());
                }
            }
        }