Example #1
0
 private void Load(StructureValueCollection values)
 {
     Magic = (int) values.GetInteger("magic");
     ParentMagic = (int) values.GetInteger("parent magic");
     GrandparentMagic = (int) values.GetInteger("grandparent magic");
     // No description stringid :(
 }
Example #2
0
 private void Load(StructureValueCollection values)
 {
     Magic = (int)values.GetInteger("magic");
     ParentMagic = (int)values.GetInteger("parent magic");
     GrandparentMagic = (int)values.GetInteger("grandparent magic");
     Description = new StringID((int)values.GetIntegerOrDefault("stringid", 0));
 }
Example #3
0
        public ThirdGenHeader(StructureValueCollection values, EngineDescription info, string buildString,
			FileSegmenter segmenter)
        {
            BuildString = buildString;
            HeaderSize = info.HeaderSize;
            Load(values, segmenter);
        }
Example #4
0
        private long _offset; // The offset that the reader is currently at

        #endregion Fields

        #region Constructors

        /// <summary>
        ///     (private) Constructs a new StructureReader.
        /// </summary>
        /// <param name="reader">The IReader to read from.</param>
        private StructureReader(IReader reader)
        {
            _reader = reader;
            _baseOffset = reader.Position;
            _offset = _baseOffset;
            _collection = new StructureValueCollection();
        }
 /// <summary>
 ///     Serializes this instance.
 /// </summary>
 /// <returns>A collection of structure values.</returns>
 public StructureValueCollection Serialize()
 {
     var result = new StructureValueCollection();
     result.SetInteger("virtual address", VirtualAddress);
     result.SetInteger("size", Size);
     return result;
 }
 /// <summary>
 ///     Serializes this instance.
 /// </summary>
 /// <returns>The serialized structure values.</returns>
 public StructureValueCollection Serialize()
 {
     var values = new StructureValueCollection();
     values.SetInteger("range start index", (uint) StartIndex);
     values.SetInteger("range size", (uint) Size);
     return values;
 }
Example #7
0
        private long _offset; // The offset that the writer is currently at

        #endregion Fields

        #region Constructors

        private StructureWriter(StructureValueCollection values, IWriter writer)
        {
            _writer = writer;
            _baseOffset = writer.Position;
            _offset = _baseOffset;
            _collection = values;
        }
        public ThirdGenLanguageGlobals(StructureValueCollection values, FileSegmenter segmenter, IPointerConverter localePointerConverter, BuildInformation buildInfo)
        {
            LocaleArea = new FileSegmentGroup(localePointerConverter);

            _languages = LoadLanguages(values, segmenter, buildInfo);
            _alignment = buildInfo.SegmentAlignment;
        }
Example #9
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
			EngineDescription buildInfo)
        {
            Name = new StringID(values.GetInteger("name stringid"));

            LoadPermutations(values, reader, metaArea, buildInfo);
        }
Example #10
0
 public StructureValueCollection Serialize(IList<ITagClass> classList)
 {
     var result = new StructureValueCollection();
     result.SetInteger("memory address", (MetaLocation != null) ? MetaLocation.AsPointer() : 0);
     result.SetInteger("class index", (Class != null) ? (uint) classList.IndexOf(Class) : 0xFFFFFFFF);
     result.SetInteger("datum index salt", Index.Salt);
     return result;
 }
 /// <summary>
 /// Reads all child objects of this reflexive.
 /// </summary>
 /// <param name="values">The values read from the parent.</param>
 /// <param name="reader">The stream to read from.</param>
 /// <param name="metaArea">The meta area of the cache file.</param>
 /// <param name="stringIDs">The string ID source for the cache file.</param>
 /// <param name="buildInfo">The build info for the cache file.</param>
 /// <returns>The objects that were read.</returns>
 public ScriptObject[] ReadObjects(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
 {
     int count = (int)values.GetInteger(_countEntryName);
     uint address = (uint)values.GetInteger(_addressEntryName);
     var layout = buildInfo.GetLayout(_layoutName);
     var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);
     return entries.Select(e => ReadScriptObject(e, reader, metaArea, stringIDs, buildInfo)).ToArray();
 }
Example #12
0
        public static void WriteStructure(StructureValueCollection values, StructureLayout layout, IWriter writer)
        {
            var structWriter = new StructureWriter(values, writer);
            layout.Accept(structWriter);

            if (layout.Size > 0)
                structWriter.SeekWriter(layout.Size);
        }
Example #13
0
 public static void Free(StructureValueCollection values, MetaAllocator allocator)
 {
     FreeBitArray(values, "number of raw pool bitfields", "raw pool bitfield table address", allocator);
     FreeBitArray(values, "number of raw pool 2 bitfields", "raw pool 2 bitfield table address", allocator);
     FreeBitArray(values, "number of raw pool 3 bitfields", "raw pool 3 bitfield table address", allocator);
     FreeBitArray(values, "number of tag bitfields", "tag bitfield table address", allocator);
     FreeBitArray(values, "number of tag 2 bitfields", "tag 2 bitfield table address", allocator);
 }
Example #14
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
			EngineDescription buildInfo)
        {
            ModelResourceIndex = new DatumIndex(values.GetInteger("model resource datum index"));

            LoadSections(values, reader, metaArea, buildInfo);
            LoadBoundingBoxes(values, reader, metaArea, buildInfo);
        }
        private List<ThirdGenLanguage> LoadLanguages(StructureValueCollection values, FileSegmenter segmenter, BuildInformation buildInfo)
        {
            StructureValueCollection[] languageSet = values.GetArray("languages");

            var result = from language in languageSet
                         select new ThirdGenLanguage(language, segmenter, LocaleArea, buildInfo);
            return result.ToList<ThirdGenLanguage>();
        }
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            ResourceIndex = new DatumIndex(values.GetInteger("resource datum index"));

            LoadRegions(values, reader, metaArea, buildInfo);
            LoadSections(values, reader, metaArea, buildInfo);
            LoadBoundingBox(values, reader, metaArea, buildInfo);
        }
        private void Load(StructureValueCollection values, IModelSubmesh[] submeshes)
        {
            IndexBufferStart = (int)values.GetInteger("index buffer start");
            IndexBufferCount = (int)values.GetInteger("index buffer count");
            VertexBufferCount = (int)values.GetInteger("vertex buffer count");

            int submeshIndex = (int)values.GetInteger("parent submesh index");
            Submesh = submeshes[submeshIndex];
        }
Example #18
0
        public ThirdGenGlobal(StructureValueCollection values, ExpressionTable allExpressions)
        {
            Name = values.GetString("name");
            Type = (short)values.GetInteger("type");

            DatumIndex valueIndex = new DatumIndex(values.GetInteger("expression index"));
            if (valueIndex.IsValid)
                Value = allExpressions.FindExpression(valueIndex);
        }
Example #19
0
 public ThirdGenLanguage(StructureValueCollection values, FileSegmenter segmenter, FileSegmentGroup localeArea, BuildInformation buildInfo)
 {
     _pointerLayout = buildInfo.GetLayout("locale index table entry");
     _encryptionKey = buildInfo.LocaleKey;
     _symbols = buildInfo.LocaleSymbols;
     _localeArea = localeArea;
     _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1;
     Load(values, segmenter, localeArea);
 }
        private List<ThirdGenLanguage> LoadLanguages(StructureValueCollection values, FileSegmenter segmenter,
			EngineDescription buildInfo)
        {
            StructureValueCollection[] languageSet = values.GetArray("languages");

            IEnumerable<ThirdGenLanguage> result =
                languageSet.Select((l, i) => new ThirdGenLanguage((GameLanguage) i, l, segmenter, LocaleArea, buildInfo));
            return result.ToList();
        }
Example #21
0
 private void Load(StructureValueCollection values)
 {
     ShaderIndex = (int) values.GetInteger("shader index");
     IndexBufferStart = (int) values.GetInteger("index buffer start");
     IndexBufferCount = (int) values.GetInteger("index buffer count");
     VertexGroupStart = (int) values.GetInteger("vertex group start");
     VertexGroupCount = (int) values.GetInteger("vertex group count");
     VertexBufferCount = (int) values.GetInteger("vertex buffer count");
 }
Example #22
0
        public ThirdGenLanguage(GameLanguage language, StructureValueCollection values, FileSegmenter segmenter,
			FileSegmentGroup localeArea, EngineDescription buildInfo)
        {
            Language = language;
            _pointerLayout = buildInfo.Layouts.GetLayout("locale index table entry");
            _encryptionKey = buildInfo.LocaleKey;
            _sizeAlign = (_encryptionKey != null) ? AES.BlockSize : 1;
            Load(values, segmenter, localeArea);
        }
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            VertexFormat = (int)values.GetInteger("vertex format");
            ExtraElementsPerVertex = (int)values.GetInteger("extra elements per vertex");
            ExtraElementsType = (ExtraVertexElementType)values.GetInteger("extra element type");

            LoadSubmeshes(values, reader, metaArea, buildInfo);
            LoadVertexGroups(values, reader, metaArea, buildInfo, Submeshes);
        }
        /// <summary>
        ///     Serializes the language data into a StructureValueCollection.
        /// </summary>
        /// <returns>The StructureValueCollection that was created from the language table.</returns>
        public StructureValueCollection Serialize()
        {
            var languageSet = new StructureValueCollection[Languages.Count];
            for (int i = 0; i < Languages.Count; i++)
                languageSet[i] = Languages[i].Serialize();

            var result = new StructureValueCollection();
            result.SetArray("languages", languageSet);
            return result;
        }
        private void LoadVertexGroups(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, IModelSubmesh[] submeshes)
        {
            int count = (int)values.GetInteger("number of vertex groups");
            uint address = values.GetInteger("vertex group table address");
            var layout = buildInfo.GetLayout("model vertex group");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            VertexGroups = (from entry in entries
                            select new ThirdGenModelVertexGroup(entry, submeshes)).ToArray();
        }
        private void LoadSubmeshes(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of submeshes");
            uint address = values.GetInteger("submesh table address");
            var layout = buildInfo.GetLayout("model submesh");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            Submeshes = (from entry in entries
                         select new ThirdGenModelSubmesh(entry)).ToArray();
        }
Example #27
0
        private void LoadPermutations(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of permutations");
            uint address = values.GetInteger("permutation table address");
            var layout = buildInfo.GetLayout("model permutation");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            Permutations = (from entry in entries
                            select new ThirdGenModelPermutation(entry)).ToArray();
        }
        private void LoadFileReferences(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo)
        {
            int count = (int)values.GetInteger("number of external cache files");
            uint address = values.GetInteger("external cache file table address");
            var layout = buildInfo.GetLayout("external cache file table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            FileReferences = (from entry in entries
                              select new ThirdGenCacheFileReference(entry)).ToArray();
        }
        private void Load(StructureValueCollection values, ThirdGenCacheFileReference[] externalFiles)
        {
            int fileIndex = (int)values.GetInteger("shared cache file index");
            if (fileIndex >= 0 && fileIndex < externalFiles.Length)
                _externalFile = externalFiles[fileIndex];

            Offset = (int)values.GetInteger("compressed block offset");
            CompressedSize = (int)values.GetInteger("compressed block size");
            UncompressedSize = (int)values.GetInteger("uncompressed block size");
        }
        private void LoadSegments(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, BuildInformation buildInfo, ThirdGenResourcePage[] pages)
        {
            int count = (int)values.GetInteger("number of raw segments");
            uint address = values.GetInteger("raw segment table address");
            var layout = buildInfo.GetLayout("raw segment table entry");
            var entries = ReflexiveReader.ReadReflexive(count, address, reader, layout, metaArea);

            Segments = (from entry in entries
                        select new ThirdGenResourceSegment(entry, pages)).ToArray();
        }