private void LoadSoundNames(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo)
        {
            var count   = (int)values.GetInteger("number of sound names");
            var address = values.GetInteger("sound name table address");
            var layout  = buildInfo.Layouts.GetLayout("sound names");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            SoundNames = entries.Select(e => new StringID(e.GetInteger("name index"))).ToArray();
        }
        private ThirdGenCacheFileReference[] LoadExternalFiles(StructureValueCollection values, IReader reader)
        {
            var             count   = (int)values.GetInteger("number of external cache files");
            uint            address = values.GetInteger("external cache file table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("external cache file table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => new ThirdGenCacheFileReference(e)).ToArray());
        }
Beispiel #3
0
        private List <ITagClass> LoadClasses(IReader reader, StructureValueCollection headerValues)
        {
            var             count   = (int)headerValues.GetInteger("number of classes");
            uint            address = headerValues.GetInteger("class table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("class entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select <StructureValueCollection, ITagClass>(e => new ThirdGenTagClass(e)).ToList());
        }
Beispiel #4
0
        private List <Script> LoadScripts(IReader reader, StructureValueCollection values)
        {
            var             count   = (int)values.GetInteger("number of scripts");
            uint            address = values.GetInteger("script table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("script entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => new Script(e, reader, _metaArea, _stringIDs, _buildInfo)).ToList());
        }
Beispiel #5
0
        private void LoadScales(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo)
        {
            var count   = (int)values.GetInteger("number of scales");
            var address = values.GetInteger("scales table address");
            var layout  = buildInfo.Layouts.GetLayout("sound scales");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            SoundScales = (from entry in entries
                           select new FourthGenSoundScale(entry)).ToArray <ISoundScale>();
        }
        public IEnumerable <ResourcePointer> LoadPointers(IReader reader, IList <ResourcePage> pages)
        {
            StructureValueCollection values = LoadTag(reader);
            var             count           = (int)values.GetInteger("number of raw segments");
            uint            address         = values.GetInteger("raw segment table address");
            StructureLayout layout          = _buildInfo.Layouts.GetLayout("raw segment table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => LoadPointer(e, pages)));
        }
Beispiel #7
0
        /// <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, EngineDescription buildInfo)
        {
            var             count   = (int)values.GetInteger(_countEntryName);
            uint            address = values.GetInteger(_addressEntryName);
            StructureLayout layout  = buildInfo.Layouts.GetLayout(_layoutName);

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);
            return(entries.Select(e => ReadScriptObject(e, reader, metaArea, stringIDs, buildInfo)).ToArray());
        }
Beispiel #8
0
        private IList <ScriptParameter> LoadParameters(IReader reader, StructureValueCollection values,
                                                       FileSegmentGroup metaArea, EngineDescription buildInfo)
        {
            var             count   = (int)values.GetInteger("number of parameters");
            uint            address = values.GetInteger("address of parameter list");
            StructureLayout layout  = buildInfo.Layouts.GetLayout("script parameter entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);
            return(entries.Select(e => new ScriptParameter(e)).ToList());
        }
        private void LoadSoundPlaybacks(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo)
        {
            var count   = (int)values.GetInteger("number of playbacks");
            var address = values.GetInteger("playback table address");
            var layout  = buildInfo.Layouts.GetLayout("sound playbacks");
            var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            SoundPlaybacks = (from entry in entries
                              select new ThirdGenSoundPlayback(entry, SoundNames)).ToArray <ISoundPlayback>();
        }
Beispiel #10
0
        private StructureValueCollection[] ReadReflexive(StructureValueCollection values, IReader reader, string countName, string addressName, string layoutName)
        {
            var  count   = (int)values.GetInteger(countName);
            uint address = (uint)values.GetInteger(addressName);

            long expand = _expander.Expand(address);

            StructureLayout layout = _buildInfo.Layouts.GetLayout(layoutName);

            return(ReflexiveReader.ReadReflexive(reader, count, expand, layout, _metaArea));
        }
Beispiel #11
0
        private List <ITag> LoadTags(IReader reader, StructureValueCollection headerValues, IList <ITagClass> classes)
        {
            var             count   = (int)headerValues.GetInteger("number of tags");
            uint            address = headerValues.GetInteger("tag table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("tag entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return
                (entries.Select <StructureValueCollection, ITag>((e, i) => new NewThirdGenTag(e, (ushort)i, _metaArea, classes))
                 .ToList());
        }
        private List <ScriptGlobal> LoadGlobals(IReader reader, StructureValueCollection values)
        {
            var             count   = (int)values.GetInteger("number of script globals");
            uint            address = values.GetInteger("script global table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("script global entry");

            address = (uint)addrFix + (address & 0xFFFFFFF);

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => new ScriptGlobal(e)).ToList());
        }
        private List <ScriptGlobal> LoadGlobals(IReader reader, StructureValueCollection values)
        {
            var  count   = (int)values.GetInteger("number of script globals");
            uint address = (uint)values.GetInteger("script global table address");

            long expand = _expander.Expand(address);

            StructureLayout layout = _buildInfo.Layouts.GetLayout("script global entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, expand, layout, _metaArea);
            return(entries.Select(e => new ScriptGlobal(e, _stringIDs)).ToList());
        }
        private void LoadVertexGroups(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
                                      EngineDescription buildInfo, IModelSubmesh[] submeshes)
        {
            var             count   = (int)values.GetInteger("number of vertex groups");
            uint            address = values.GetInteger("vertex group table address");
            StructureLayout layout  = buildInfo.Layouts.GetLayout("model vertex group");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            VertexGroups = (from entry in entries
                            select new FourthGenModelVertexGroup(entry, submeshes)).ToArray();
        }
        private void Load(IReader reader)
        {
            reader.SeekTo(_scenario.MetaLocation.AsOffset());
            var scenarioLayout = _buildInfo.Layouts.GetLayout("scnr");
            var scenarioData   = StructureReader.ReadStructure(reader, scenarioLayout);

            var count       = (int)scenarioData.GetInteger("simulation definition table count");
            var address     = scenarioData.GetInteger("simulation definition table address");
            var entryLayout = _buildInfo.Layouts.GetLayout("simulation definition table entry");

            _table = ReflexiveReader.ReadReflexive(reader, count, address, entryLayout, _metaArea).Select((e) => _tags[new DatumIndex(e.GetInteger("datum index"))]).ToList();
        }
        private void LoadSubmeshes(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
                                   EngineDescription buildInfo)
        {
            var             count   = (int)values.GetInteger("number of submeshes");
            uint            address = (uint)values.GetInteger("submesh table address");
            StructureLayout layout  = buildInfo.Layouts.GetLayout("model submesh");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            Submeshes = (from entry in entries
                         select new ThirdGenModelSubmesh(entry)).ToArray();
        }
Beispiel #17
0
        private void LoadSections(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
                                  EngineDescription buildInfo)
        {
            var             count   = (int)values.GetInteger("number of sections");
            uint            address = values.GetInteger("section table address");
            StructureLayout layout  = buildInfo.Layouts.GetLayout("model section");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea);

            Sections = (from entry in entries
                        select new FourthGenModelSection(entry, reader, metaArea, buildInfo)).ToArray();
        }
Beispiel #18
0
        private void LoadBoundingBoxes(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
                                       EngineDescription buildInfo)
        {
            var             count   = (int)values.GetInteger("number of bounding boxes");
            uint            address = values.GetInteger("bounding box table address");
            StructureLayout layout  = buildInfo.Layouts.GetLayout("model bounding box");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, 1, address, layout, metaArea);

            BoundingBoxes = (from entry in entries
                             select BoundingBox.Deserialize(entry)).ToArray();
        }
Beispiel #19
0
        private IEnumerable <ResourceDefinitionFixup> LoadDefinitionFixups(StructureValueCollection values, IReader reader)
        {
            var             count   = (int)values.GetInteger("number of definition fixups");
            uint            address = values.GetInteger("definition fixup table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("definition fixup entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => new ResourceDefinitionFixup
            {
                Offset = (int)e.GetInteger("offset"),
                Type = (int)e.GetInteger("type index")
            }));
        }
Beispiel #20
0
        public List <ResourceSize> LoadSizes(IReader reader)
        {
            StructureValueCollection values = LoadTag(reader);
            var  count   = (int)values.GetInteger("number of raw sizes");
            uint address = (uint)values.GetInteger("raw size table address");

            long expand = _expander.Expand(address);

            StructureLayout layout = _buildInfo.Layouts.GetLayout("raw size table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, expand, layout, _metaArea);
            return(entries.Select((e, i) => LoadSize(e, i, reader)).ToList());
        }
        public IEnumerable <ResourcePage> LoadPages(IReader reader)
        {
            StructureValueCollection values = LoadTag(reader);

            ThirdGenCacheFileReference[] files = LoadExternalFiles(values, reader);

            var             count   = (int)values.GetInteger("number of raw pages");
            uint            address = values.GetInteger("raw page table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("raw page table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select((e, i) => LoadPage(e, i, files)));
        }
Beispiel #22
0
        public IEnumerable <Resource> LoadResources(IReader reader, TagTable tags, IList <ResourcePointer> pointers)
        {
            StructureValueCollection values = LoadTag(reader);

            byte[] infoBuffer = LoadResourceInfoBuffer(values, reader);

            var             count   = (int)values.GetInteger("number of resources");
            uint            address = values.GetInteger("resource table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("resource table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select((e, i) => LoadResource(e, i, tags, pointers, infoBuffer, reader)));
        }
        private IEnumerable <ThirdGenZoneSet> ReadZoneSetTable(StructureValueCollection tagValues, string countName, string addressName, IReader reader)
        {
            if (!tagValues.HasInteger(countName) || !tagValues.HasInteger(addressName))
            {
                return(Enumerable.Empty <ThirdGenZoneSet>());
            }

            var             count   = (int)tagValues.GetInteger(countName);
            uint            address = tagValues.GetInteger(addressName);
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("zone set definition");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select(e => new ThirdGenZoneSet(e, reader, _metaArea)));
        }
Beispiel #24
0
        private List <IPolyart> LoadPolyart(IReader reader, StructureValueCollection headerValues)
        {
            if (!headerValues.HasInteger("number of polyart fixups"))
            {
                return(null);
            }

            var             count   = (int)headerValues.GetInteger("number of polyart fixups");
            long            address = (long)headerValues.GetInteger("polyart fixup table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("polyart table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(entries.Select <StructureValueCollection, IPolyart>(e => new ThirdGenPolyart(e, _metaArea)).ToList());
        }
Beispiel #25
0
        private void LoadResourceTypes(StructureValueCollection values, IReader reader, StringIDSource stringIDs)
        {
            if (!values.HasInteger("number of resource types") || !values.HasInteger("resource type table address"))
            {
                return;
            }

            var             count   = (int)values.GetInteger("number of resource types");
            uint            address = values.GetInteger("resource type table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("resource type entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            _resourceTypes = entries.Select(e => new FourthGenResourceType(e, stringIDs)).ToArray();
        }
Beispiel #26
0
        private IEnumerable <ResourceFixup> LoadResourceFixups(StructureValueCollection values, IReader reader)
        {
            var  count   = (int)values.GetInteger("number of resource fixups");
            uint address = (uint)values.GetInteger("resource fixup table address");

            long expand = _expander.Expand(address);

            StructureLayout layout = _buildInfo.Layouts.GetLayout("resource fixup entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, expand, layout, _metaArea);
            return(entries.Select(e => new ResourceFixup
            {
                Offset = (int)e.GetInteger("offset"),
                Address = (uint)e.GetInteger("address")
            }));
        }
        private void FreeZoneSetsInTable(StructureValueCollection tagValues, string countName, string addressName, IReader reader)
        {
            if (!tagValues.HasInteger(countName) || !tagValues.HasInteger(addressName))
            {
                return;
            }

            var             count   = (int)tagValues.GetInteger(countName);
            uint            address = tagValues.GetInteger(addressName);
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("zone set definition");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            foreach (StructureValueCollection entry in entries)
            {
                ThirdGenZoneSet.Free(entry, _allocator);
            }
        }
Beispiel #28
0
        private ScriptObject[] ReadPointSets(IReader reader, StructureValueCollection values)
        {
            // Point sets are nested in another reflexive for whatever reason
            // Seems like the length of the outer is always 1, so just take the first entry and process it
            var count = (int)values.GetInteger("point set data count");

            if (count == 0)
            {
                return(new ScriptObject[0]);
            }

            uint            address = values.GetInteger("point set data address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("point set data entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            return(ReadObjects(reader, entries.First(), _pointSets));
        }
Beispiel #29
0
        private Dictionary <int, ITag> LoadImportant(IReader reader, StructureValueCollection headerValues, List <ITag> tags)
        {
            var  count   = (int)headerValues.GetInteger("number of important tags");
            long address = (long)headerValues.GetInteger("important tag table address");

            StructureLayout layout = _buildInfo.Layouts.GetLayout("important tag entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);

            Dictionary <int, ITag> output = new Dictionary <int, ITag>();

            foreach (StructureValueCollection ent in entries)
            {
                output[(int)ent.GetInteger("class magic")] = tags[(int)ent.GetInteger("datum index") & 0xFFFF];
            }

            return(output);
        }
Beispiel #30
0
        private void FreeResources(StructureValueCollection values, IReader reader)
        {
            var             count   = (int)values.GetInteger("number of resources");
            uint            address = values.GetInteger("resource table address");
            StructureLayout layout  = _buildInfo.Layouts.GetLayout("resource table entry");

            StructureValueCollection[] entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, _metaArea);
            foreach (StructureValueCollection entry in entries)
            {
                FreeResource(entry);
            }

            int size = count * layout.Size;

            if (address >= 0 && size > 0)
            {
                _allocator.Free(address, size);
            }
        }