public SecondGenHeader(StructureValueCollection values, EngineDescription info, string buildString, FileSegmenter segmenter) { BuildString = buildString; HeaderSize = info.HeaderSize; Load(values, segmenter); }
/// <summary> /// Reads the vertex buffers for a model from a stream and passes them to an IModelProcessor. /// </summary> /// <param name="reader">The stream to read the vertex buffers from.</param> /// <param name="model">The model's metadata.</param> /// <param name="sectionsToRead"> /// A BitArray controlling which sections to read. Indices which are set to to true will be /// read. /// </param> /// <param name="buildInfo">Information about the cache file's target engine.</param> /// <param name="processor">The IModelProcessor to pass the read model data to.</param> private static void ReadVertexBuffers(IReader reader, IRenderModel model, BitArray sectionsToRead, EngineDescription buildInfo, IModelProcessor processor) { for (int i = 0; i < model.Sections.Length; i++) ReadSectionVertices(reader, model.Sections[i], model.BoundingBoxes[0], buildInfo, sectionsToRead[i] ? processor : null); }
public ThirdGenCacheFile(IReader reader, EngineDescription buildInfo, string buildString) { _buildInfo = buildInfo; _segmenter = new FileSegmenter(buildInfo.SegmentAlignment); Allocator = new MetaAllocator(this, 0x10000); Load(reader, buildString); }
/// <summary> /// Loads a cache file from a stream. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="engineDb">The engine database to use to process the cache file.</param> /// <param name="engineInfo">On output, this will contain the cache file's engine description.</param> /// <returns>The cache file that was loaded.</returns> /// <exception cref="ArgumentException">Thrown if the cache file is invalid.</exception> /// <exception cref="NotSupportedException">Thrown if the cache file's target engine is not supported.</exception> public static ICacheFile LoadCacheFile(IReader reader, EngineDatabase engineDb, out EngineDescription engineInfo) { // Set the reader's endianness based upon the file's header magic reader.SeekTo(0); byte[] headerMagic = reader.ReadBlock(4); reader.Endianness = DetermineCacheFileEndianness(headerMagic); // Load engine version info var version = new CacheFileVersionInfo(reader); if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration) throw new NotSupportedException("Engine not supported"); // Load build info engineInfo = engineDb.FindEngineByVersion(version.BuildString); if (engineInfo == null) throw new NotSupportedException("Engine version \"" + version.BuildString + "\" not supported"); // Load the cache file depending upon the engine version switch (version.Engine) { case EngineType.SecondGeneration: return new SecondGenCacheFile(reader, engineInfo, version.BuildString); case EngineType.ThirdGeneration: return new ThirdGenCacheFile(reader, engineInfo, version.BuildString); default: throw new NotSupportedException("Engine not supported"); } }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { Name = new StringID(values.GetInteger("name stringid")); LoadPermutations(values, reader, metaArea, buildInfo); }
public FourthGenCacheFile(IReader map_reader, IReader tag_reader, IReader string_reader, IReader tagnames_reader, EngineDescription buildInfo, string buildString) { _buildInfo = buildInfo; _segmenter = new FileSegmenter(buildInfo.SegmentAlignment); Allocator = new MetaAllocator(this, 0x10000); Load(map_reader, tag_reader, string_reader, tagnames_reader, buildString); }
public MetaEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parentContainer, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _parentMetaContainer = parentContainer; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _fileManager = streamManager; _rteProvider = rteProvider; _searchTimer = new Timer(SearchTimer); _stringIdTrie = stringIDTrie; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting<string>("plugins"), className); // Set Option boxes cbShowInvisibles.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles; cbShowComments.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowComments; cbShowEnumIndex.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowEnumIndex; cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation; // Load Meta RefreshEditor(MetaReader.LoadType.File); // Set init finished hasInitFinished = true; }
/// <summary> /// Loads a cache file from a stream. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="engineDb">The engine database to use to process the cache file.</param> /// <param name="engineInfo">On output, this will contain the cache file's engine description.</param> /// <returns>The cache file that was loaded.</returns> /// <exception cref="ArgumentException">Thrown if the cache file is invalid.</exception> /// <exception cref="NotSupportedException">Thrown if the cache file's target engine is not supported.</exception> public static ICacheFile LoadCacheFile(IReader map_reader, IReader tag_reader, IReader string_reader, out string tagnamesLocation, string filesLocation, EngineDatabase engineDb, out EngineDescription engineInfo) { // Set the reader's endianness based upon the file's header magic map_reader.SeekTo(0); byte[] headerMagic = map_reader.ReadBlock(4); Endian engianess = DetermineCacheFileEndianness(headerMagic); map_reader.Endianness = engianess; if(tag_reader != null) tag_reader.Endianness = engianess; if (tag_reader != null) string_reader.Endianness = engianess; // Load engine version info var version = new CacheFileVersionInfo(map_reader); if (version.Engine != EngineType.SecondGeneration && version.Engine != EngineType.ThirdGeneration && version.Engine != EngineType.FourthGeneration) throw new NotSupportedException("Engine not supported"); // Load build info engineInfo = engineDb.FindEngineByVersion(version.BuildString); if (engineInfo == null) throw new NotSupportedException("Engine version \"" + version.BuildString + "\" not supported"); // Load the cache file depending upon the engine version switch (version.Engine) { case EngineType.SecondGeneration: tagnamesLocation = null; return new SecondGenCacheFile(map_reader, engineInfo, version.BuildString); case EngineType.ThirdGeneration: tagnamesLocation = null; return new ThirdGenCacheFile(map_reader, engineInfo, version.BuildString); case EngineType.FourthGeneration: if (tag_reader == null || tag_reader.BaseStream.Length == 0) throw new Exception("Can't load version 4 cache file without tags file. Please make sure that tags.dat is in the same folder at the map file."); if (string_reader == null || tag_reader.BaseStream.Length == 0) throw new Exception("Can't load version 4 cache file without strings file. Please make sure that tags.dat is in the same folder at the map file."); // Load the tag names csv file string tagnames_filename = "tagnames_" + version.BuildString + ".csv"; string tagnames_location = filesLocation != null ? filesLocation + tagnames_filename : ""; if (!File.Exists(tagnames_location)) tagnames_location = "tagnames\\" + tagnames_filename; if (!File.Exists(tagnames_location)) tagnames_location = null; FileStream tagnamesFileStream = tagnames_location != null ? TryInitFilestream(tagnames_location) : null; EndianReader tagnames_reader = null; if (tagnamesFileStream != null) { tagnames_reader = new EndianReader(tagnamesFileStream, Endian.BigEndian); tagnames_reader.Endianness = engianess; } tagnamesLocation = tagnames_location; FourthGenCacheFile cache_file = new FourthGenCacheFile(map_reader, tag_reader, string_reader, tagnames_reader, engineInfo, version.BuildString); tagnamesFileStream.Close(); return cache_file; default: throw new NotSupportedException("Engine not supported"); } }
public FourthGenResourceLayoutTable(ITag playTag, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _tag = playTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; }
/// <summary> /// Initializes a new instance of the <see cref="FourthGenLanguagePackLoader" /> class. /// </summary> /// <param name="cacheFile">The cache file.</param> /// <param name="languageGlobals">The language globals.</param> /// <param name="buildInfo">Information about the cache file's engine.</param> /// <param name="reader">The stream to read from.</param> public FourthGenLanguagePackLoader(ICacheFile cacheFile, FourthGenLanguageGlobals languageGlobals, EngineDescription buildInfo, IReader reader) { _buildInfo = buildInfo; _languageGlobals = languageGlobals; _languages = languageGlobals.Languages.Where(l => l.StringCount != 0).Select(l => l.Language).ToList(); LoadGroups(reader, cacheFile); }
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); }
public FourthGenHeader(StructureValueCollection map_values, StructureValueCollection tag_values, StructureValueCollection string_values, EngineDescription info, string buildString, FileSegmenter segmenter) { EngineInfo = info; BuildString = buildString; HeaderSize = info.HeaderSize; Load(map_values, tag_values, string_values, segmenter); }
public FourthGenLanguage(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); }
public FourthGenTagTable(IReader reader, MetaAllocator allocator, EngineDescription buildInfo) { //_indexHeaderLocation = indexHeaderLocation; //_metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
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(); }
/// <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(); }
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(); }
public FourthGenZoneSetTable(FourthGenResourceGestalt gestalt, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _gestalt = gestalt; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public ScriptEditor(EngineDescription buildInfo, IScriptFile scriptFile, IStreamManager streamManager) { _buildInfo = buildInfo; _scriptFile = scriptFile; InitializeComponent(); var thrd = new Thread(DecompileScripts); thrd.SetApartmentState(ApartmentState.STA); thrd.Start(streamManager); }
/// <summary> /// Initializes a new instance of the <see cref="ThirdGenResourceManager" /> class. /// </summary> /// <param name="gestalt">The cache file's resource gestalt.</param> /// <param name="layoutTable">The cache file's resource layout table.</param> /// <param name="tags">The cache file's tag table.</param> /// <param name="metaArea">The cache file's meta area.</param> /// <param name="allocator">The cache file's tag data allocator.</param> /// <param name="buildInfo">The cache file's build information.</param> public ThirdGenResourceManager(ThirdGenResourceGestalt gestalt, ThirdGenResourceLayoutTable layoutTable, TagTable tags, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _gestalt = gestalt; _layoutTable = layoutTable; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; }
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 ThirdGenSoundScale(entry)).ToArray<ISoundScale>(); }
/// <summary> /// View the selected offset as every meta value type. /// </summary> /// <param name="cacheFile">The cache file which is being read from.</param> /// <param name="buildInfo">Build information for the engine.</param> /// <param name="streamManager">The stream manager to open the file with.</param> /// <param name="fields">The fields to display in the viewer.</param> /// <param name="cacheOffset">The initial offset to display.</param> public static void Show(ICacheFile cacheFile, EngineDescription buildInfo, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset) { var valueAs = new ViewValueAs(cacheFile, buildInfo, streamManager, fields, cacheOffset) { Owner = App.AssemblyStorage.AssemblySettings.HomeWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; valueAs.Show(); }
public ThirdGenTagTable(IReader reader, SegmentPointer indexHeaderLocation, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _indexHeaderLocation = indexHeaderLocation; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public ThirdGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator, StringIDSource stringIDs, EngineDescription buildInfo) { _tag = zoneTag; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader, stringIDs); }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { LoadSoundNames(values, reader, metaArea, buildInfo); LoadPlatformCodecs(values, reader, metaArea, buildInfo); LoadPlaybackParameters(values, reader, metaArea, buildInfo); LoadScales(values, reader, metaArea, buildInfo); LoadSoundPlaybacks(values, reader, metaArea, buildInfo); LoadSoundPermutations(values, reader, metaArea, buildInfo); LoadSoundPermutationChunks(values, reader, metaArea, buildInfo); }
/// <summary> /// Reads the resource data for a model from a stream and passes it to an IModelProcessor. /// </summary> /// <param name="reader">The stream to read the model data from.</param> /// <param name="model">The model's metadata.</param> /// <param name="sectionsToRead"> /// A BitArray controlling which sections to read. Indices which are set to to true will be /// read. /// </param> /// <param name="buildInfo">Information about the cache file's target engine.</param> /// <param name="processor">The IModelProcessor to pass the read model data to.</param> public static void ReadModelData(IReader reader, IRenderModel model, BitArray sectionsToRead, EngineDescription buildInfo, IModelProcessor processor) { processor.BeginModel(model); ReadVertexBuffers(reader, model, sectionsToRead, buildInfo, processor); ReadIndexBuffers(reader, model, sectionsToRead, buildInfo, processor); processor.EndModel(model); }
private void LoadPlatformCodecs(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { var count = (int)values.GetInteger("number of platform codecs"); var address = values.GetInteger("platform codecs table address"); var layout = buildInfo.Layouts.GetLayout("sound platform codecs"); var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); SoundPlatformCodecs = (from entry in entries select new FourthGenSoundPlatformCodec(entry)).ToArray<ISoundPlatformCodec>(); }
private void LoadSoundPermutations(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription buildInfo) { var count = (int)values.GetInteger("number of sound permutations"); var address = values.GetInteger("sound permutation table address"); var layout = buildInfo.Layouts.GetLayout("sound permutations"); var entries = ReflexiveReader.ReadReflexive(reader, count, address, layout, metaArea); SoundPermutations = (from entry in entries select new FourthGenSoundPermutation(entry, SoundNames)).ToArray<ISoundPermutation>(); }
private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, EngineDescription 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); }
public FourthGenSimulationDefinitionTable(ITag scenario, TagTable tags, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo) { _scenario = scenario; _tags = tags; _metaArea = metaArea; _allocator = allocator; _buildInfo = buildInfo; Load(reader); }
public CacheStructureReader(IReader reader, ICacheFile cache, EngineDescription buildInfo) : base(reader) { _cache = cache; _buildInfo = buildInfo; }
/// <summary> /// Reads a structure from a stream by following a predefined structure layout. /// </summary> /// <param name="reader">The IReader to read the structure from.</param> /// <param name="cache">The cache file to read from.</param> /// <param name="buildInfo"></param> /// <param name="layout">The structure layout to follow.</param> /// <returns>A collection of the values that were read.</returns> /// <seealso cref="StructureLayout" /> public static StructureValueCollection ReadStructure(IReader reader, ICacheFile cache, EngineDescription buildInfo, StructureLayout layout) { var structReader = new CacheStructureReader(reader, cache, buildInfo); layout.Accept(structReader); if (layout.Size > 0) { structReader.SeekReader(layout.Size); } return(structReader._collection); }