Beispiel #1
0
        private static CompressionState AnalyzeSecondGen(IReader reader, EngineDescription engineInfo)
        {
            // H2 header is uncompressed, so the cache file needs to be loaded enough to check if the tag table is readable
            var segmenter = new FileSegmenter(engineInfo.SegmentAlignment);

            reader.SeekTo(0);
            StructureValueCollection headerValues = StructureReader.ReadStructure(reader, engineInfo.Layouts.GetLayout("header"));

            var  metaOffset     = (int)headerValues.GetInteger("meta offset");
            var  metaSize       = (int)headerValues.GetInteger("meta size");
            uint metaOffsetMask = (uint)headerValues.GetInteger("meta offset mask");

            var metaSegment = new FileSegment(
                segmenter.DefineSegment(metaOffset, metaSize, 0x200, SegmentResizeOrigin.Beginning), segmenter);
            var MetaArea = new FileSegmentGroup(new MetaOffsetConverter(metaSegment, metaOffsetMask));

            MetaArea.AddSegment(metaSegment);

            if (MetaArea.Offset >= reader.Length)
            {
                return(CompressionState.Compressed);
            }

            reader.SeekTo(MetaArea.Offset);
            StructureValueCollection tagTableValues = StructureReader.ReadStructure(reader, engineInfo.Layouts.GetLayout("meta header"));

            if ((uint)tagTableValues.GetInteger("magic") != CharConstant.FromString("tags"))
            {
                return(CompressionState.Compressed);
            }

            return(CompressionState.Decompressed);
        }
Beispiel #2
0
		private void Load(IReader reader, StructureValueCollection headerValues, FileSegmentGroup metaArea,
			EngineDescription buildInfo)
		{
			if ((uint)headerValues.GetInteger("magic") != CharConstant.FromString("tags"))
				throw new ArgumentException("Invalid index table header magic");

			// Tags
			var numTags = (int)headerValues.GetInteger("number of tags");

			// TODO (Dragon): idk if this is acceptable
			uint tagTableOffset;
			if (buildInfo.BuildVersion == "02.01.07.4998" || buildInfo.BuildVersion == "02.06.28.07902")
			{
				//tagTableOffset = (uint)(metaArea.Offset + (uint)headerValues.GetInteger("tag table offset") - metaArea.BasePointer);
				tagTableOffset = (uint)(metaArea.Offset + (uint)headerValues.GetInteger("tag table offset") - (uint)headerValues.GetInteger("meta header mask"));
			}
			else
			{
				tagTableOffset = (uint)(metaArea.Offset + (uint)headerValues.GetInteger("tag table offset") - metaArea.BasePointer);
			}

			// Offset is relative to the header
			// hack to "spoof" a group table since firstgen has none
			_groups = ReadGroups(reader, tagTableOffset, numTags, buildInfo);
			_groupsById = BuildGroupLookup(_groups);

			_tags = ReadTags(reader, tagTableOffset, numTags, buildInfo, metaArea);
		}
Beispiel #3
0
        public void LoadNewTagEntry(TagEntry tag)
        {
            _tag = tag;

            // Load Plugin Path
            string groupName = VariousFunctions.SterilizeTagGroupName(CharConstant.ToString(_tag.RawTag.Group.Magic)).Trim();

            _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                                        _buildInfo.Settings.GetSetting <string>("plugins"), groupName);

            if (_buildInfo.Settings.PathExists("fallbackPlugins"))
            {
                _fallbackPluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                                                    _buildInfo.Settings.GetSetting <string>("fallbackPlugins"), groupName);
            }

            // Set Option boxes
            cbShowInvisibles.IsChecked  = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles;
            cbShowComments.IsChecked    = App.AssemblyStorage.AssemblySettings.PluginsShowComments;
            cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation;

            cbEnumPrefix.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.PluginsEnumPrefix;

            // Load Meta
            RefreshEditor(MetaReader.LoadType.File);
        }
        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;
        }
Beispiel #5
0
        private static void DumpSharedResources(string mapPath, EngineDatabase db)
        {
            ICacheFile    cacheFile;
            ResourceTable resources;

            using (var reader = new EndianReader(File.OpenRead(mapPath), Endian.BigEndian))
            {
                cacheFile = CacheFileLoader.LoadCacheFile(reader, db);
                resources = cacheFile.Resources.LoadResourceTable(reader);
            }

            using (var output = new StreamWriter(Path.ChangeExtension(mapPath, ".txt")))
            {
                output.WriteLine("Shared resources referenced by {0}:", Path.GetFileName(mapPath));
                output.WriteLine();
                output.WriteLine("Rsrc Datum  Map File      Class  Tag");
                output.WriteLine("----------  --------      -----  ---");

                foreach (Resource resource in resources.Resources.Where(r => r.Location != null && r.ParentTag != null))
                {
                    // If either page has a null file path, then it's shared
                    ResourcePointer loc           = resource.Location;
                    string          primaryFile   = (loc.PrimaryPage != null) ? loc.PrimaryPage.FilePath : null;
                    string          secondaryFile = (loc.SecondaryPage != null) ? loc.SecondaryPage.FilePath : null;
                    if (primaryFile != null || secondaryFile != null)
                    {
                        string className = CharConstant.ToString(resource.ParentTag.Class.Magic);
                        string name      = cacheFile.FileNames.GetTagName(resource.ParentTag) ?? resource.ParentTag.Index.ToString();
                        string fileName  = primaryFile ?? secondaryFile;
                        fileName = fileName.Substring(fileName.IndexOf('\\') + 1);
                        output.WriteLine("{0}  {1, -12}  {2}   {3}", resource.Index, fileName, className, name);
                    }
                }
            }
        }
        public PluginEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parent, MetaEditor sibling)
        {
            InitializeComponent();

            txtPlugin.TextArea.TextEntered += PluginTextEntered;

            _parent  = parent;
            _sibling = sibling;

            LoadSyntaxHighlighting();
            SetHighlightColor();
            LoadCodeCompletion();

            App.AssemblyStorage.AssemblySettings.PropertyChanged += Settings_SettingsChanged;

            string groupName = VariousFunctions.SterilizeTagGroupName(CharConstant.ToString(tag.RawTag.Group.Magic)).Trim();

            _pluginPath =
                string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                              buildInfo.Settings.GetSetting <string>("plugins"), groupName.Trim());

            if (buildInfo.Settings.PathExists("fallbackPlugins"))
            {
                _fallbackPluginPath =
                    string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                                  buildInfo.Settings.GetSetting <string>("fallbackPlugins"), groupName.Trim());
            }
            LoadPlugin();
        }
        public static void LoadTags(Models.Project project, ICacheFile cacheFile,
                                    string projectDirectory, Trie stringIdTrie)
        {
            var tagsDirectory = Path.Combine(projectDirectory, project.Properties.TagsFolder);

            if (!Directory.Exists(tagsDirectory))
            {
                Directory.CreateDirectory(tagsDirectory);
            }

            // Generate Tag List
            var tags = cacheFile.Tags
                       .Where(tag => tag != null && tag.Class != null && tag.MetaLocation != null)
                       .Select(tag =>
            {
                var className = CharConstant.ToString(tag.Class.Magic).Trim();
                var name      = cacheFile.FileNames.GetTagName(tag);
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = tag.Index.ToString();
                }

                var directory        = tagsDirectory;
                var tagFileName      = $"{name}.{className}";
                var indexOfSeparator = tagFileName.LastIndexOf('\\');
                if (indexOfSeparator > -1)
                {
                    directory = Path
                                .Combine(tagsDirectory, tagFileName.Remove(indexOfSeparator))
                                .Replace('\\', Path.DirectorySeparatorChar);

                    tagFileName = tagFileName.Remove(0, indexOfSeparator + 1);
                }

                return(new TagEntry(tag, className, name, tagFileName, directory));
            });

            // Extract Tag Data
            foreach (var tag in tags)
            {
                // Create Directory
                if (!Directory.Exists(tag.Directory))
                {
                    Directory.CreateDirectory(tag.Directory);
                }

                using (var reader = XmlReader.Create($"data/plugins/halo3/{PlatformHelpers.EscapePath(tag.ClassName)}.xml"))
                {
                    var pluginVisitor = new JsonPluginVisitor(tags, stringIdTrie, cacheFile.MetaArea);
                    JsonPluginLoader.LoadPlugin(reader, pluginVisitor);

                    File.WriteAllText(tag.FullPath,
                                      JsonConvert.SerializeObject(pluginVisitor.TagData, Formatting.Indented, new JsonSerializerSettings
                    {
                        TypeNameHandling = TypeNameHandling.Auto
                    }));
                }
            }
        }
Beispiel #8
0
        /// <summary>
        ///     Writes the header for a new block.
        /// </summary>
        /// <param name="id">The name of the block. Can be no more than 4 characters long.</param>
        /// <param name="version">The block's version number.</param>
        public void StartBlock(string id, byte version)
        {
            if (id.Length > 4)
            {
                throw new ArgumentException("Container block IDs can be no more than 4 bytes long");
            }

            id = id.PadRight(4);
            StartBlock((uint)CharConstant.FromString(id), version);
        }
Beispiel #9
0
 private void LoadSimulationDefinitions(IReader reader)
 {
     if (_tags != null && _buildInfo.Layouts.HasLayout("scnr") && _buildInfo.Layouts.HasLayout("simulation definition table element"))
     {
         ITag scnr = _tags.GetGlobalTag(CharConstant.FromString("scnr"));
         if (scnr != null)
         {
             _simulationDefinitions = new ThirdGenSimulationDefinitionTable(scnr, _tags, reader, MetaArea, Allocator, _buildInfo, _expander);
         }
     }
 }
Beispiel #10
0
 private void LoadEffects(IReader reader)
 {
     if (_tags != null && _buildInfo.Layouts.HasLayout("scnr") && _buildInfo.Layouts.HasLayout("structured effect interop element"))
     {
         ITag scnr = _tags.GetGlobalTag(CharConstant.FromString("scnr"));
         if (scnr != null)
         {
             _effects = new EffectInterop(scnr, reader, MetaArea, Allocator, _buildInfo, _expander);
         }
     }
 }
 private void LoadEffects(IReader reader)
 {
     if (_tags != null && _buildInfo.Layouts.HasLayout("scnr") && _buildInfo.Layouts.HasLayout("compiled effect entry"))
     {
         ITag scnr = _tags.GetImportantTag(CharConstant.FromString("scnr"));
         if (scnr != null)
         {
             _effects = new EffectStorage(scnr, reader, MetaArea, Allocator, _buildInfo, _expander);
         }
     }
 }
Beispiel #12
0
 private void RevisionViewer()
 {
     if (_pluginVisitor != null && _pluginVisitor.PluginRevisions != null)
     {
         MetroPluginRevisionViewer.Show(_pluginVisitor.PluginRevisions, CharConstant.ToString(_tag.RawTag.Group.Magic));
     }
     else
     {
         MetroMessageBox.Show("Press RB to...wait...how'd you do that?",
                              "How did you load the plugin revision viewer before you loaded a plugin? wat.");
     }
 }
Beispiel #13
0
        public HsdtScriptFile(ITag hsdtTag, string tagName, FileSegmentGroup metaArea, EngineDescription buildInfo, StringIDSource stringIDs, IPointerExpander expander)
        {
            if (CharConstant.ToString(hsdtTag.Group.Magic) != "hsdt")
            {
                throw new ArgumentException("Invalid tag. The tag must belong to the hsdt group.");
            }

            _hsdtTag   = hsdtTag;
            Name       = tagName.Substring(tagName.LastIndexOf('\\') + 1) + ".hsc";
            _metaArea  = metaArea;
            _buildInfo = buildInfo;
            _stringIDs = stringIDs;
            _expander  = expander;
        }
Beispiel #14
0
        private static void MapLoadUnitTest()
        {
            string targetFile = Core.Util.VisualStudioProvider.TryGetSolutionDirectoryInfo().FullName + "\\" + TARGET_MAP_FILE;

            using (BlamCacheFile blamCacheFile = new BlamCacheFile(targetFile))
            {
                const int          VEHICLE_MODEL_OFFSET = 0x34;
                ICacheFile         cacheFile            = blamCacheFile.Get();
                IEnumerable <ITag> vehicleTags          = cacheFile.Tags.FindTagsByGroup("vehi");
                StructureLayout    layout = blamCacheFile.BuildInfo.Layouts.GetLayout("tag reference");
                foreach (ITag vehicleTag in vehicleTags)
                {
                    string name = cacheFile.FileNames.GetTagName(vehicleTag);

                    //This is where in the memory region that the map exists a structure for the meta data exists
                    long tagRefPointer = vehicleTag.MetaLocation.AsOffset() + VEHICLE_MODEL_OFFSET;
                    blamCacheFile.Reader.SeekTo(tagRefPointer);
                    StructureValueCollection collection = StructureReader.ReadStructure(blamCacheFile.Reader, layout); //Try to read it

                    //Extract fields
                    ulong      groupMagic = collection.GetInteger("tag group magic");
                    DatumIndex datumIndex = new DatumIndex(collection.GetInteger("datum index"));
                    //Is this a valid datum?
                    bool isValid = cacheFile.Tags.IsValidIndex(datumIndex);

                    ITag   vehicleModelTag  = cacheFile.Tags[datumIndex];
                    string vehicleModelName = cacheFile.FileNames.GetTagName(vehicleModelTag);
                    string group            = CharConstant.ToString(vehicleModelTag.Group.Magic);
                    if (!TARGET_MODEL.Equals(vehicleModelName))
                    {
                        continue;
                    }

                    tagRefPointer = vehicleModelTag.MetaLocation.AsOffset();
                    blamCacheFile.Reader.SeekTo(tagRefPointer);
                    collection = StructureReader.ReadStructure(blamCacheFile.Reader, layout);
                    groupMagic = collection.GetInteger("tag group magic");
                    datumIndex = new DatumIndex(collection.GetInteger("datum index"));

                    isValid = cacheFile.Tags.IsValidIndex(datumIndex);

                    ITag   vehicleRenderModelTag = cacheFile.Tags[datumIndex];
                    string renderModelTagName    = CharConstant.ToString(vehicleRenderModelTag.Group.Magic);

                    BlamRenderModel warthogModel = new BlamRenderModel(vehicleRenderModelTag, blamCacheFile);
                }
            }
            Logger.LogReport("MapLoadUnitTest: Success!");
        }
Beispiel #15
0
        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 groupName = VariousFunctions.SterilizeTagGroupName(CharConstant.ToString(tag.RawTag.Group.Magic)).Trim();

            _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                                        _buildInfo.Settings.GetSetting <string>("plugins"), groupName);

            if (_buildInfo.Settings.PathExists("fallbackPlugins"))
            {
                _fallbackPluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins",
                                                    _buildInfo.Settings.GetSetting <string>("fallbackPlugins"), groupName);
            }

            // Set Option boxes
            cbShowInvisibles.IsChecked  = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles;
            cbShowComments.IsChecked    = App.AssemblyStorage.AssemblySettings.PluginsShowComments;
            cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation;

            cbEnumPrefix.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.PluginsEnumPrefix;

            // Load Meta
            RefreshEditor(MetaReader.LoadType.File);

            // Load Info
            lblTagName.Text = tag.TagFileName != null
                                ? tag.TagFileName + "." + tag.GroupName
                                : "0x" + tag.RawTag.Index.Value.ToString("X");

            lblDatum.Text   = string.Format("{0}", tag.RawTag.Index);
            lblAddress.Text = string.Format("0x{0:X8}", tag.RawTag.MetaLocation.AsPointer());
            lblOffset.Text  = string.Format("0x{0:X}", tag.RawTag.MetaLocation.AsOffset());

            // Set init finished
            hasInitFinished = true;
        }
Beispiel #16
0
        private void Load(IReader reader)
        {
            _header    = LoadHeader(reader, out uint mask);
            _tags      = LoadTagTable(reader, mask);
            _fileNames = LoadFileNames(reader);

            _stringIDs = LoadStringIDs(reader);

            //header doesn't contain a scenario path, but later engines do so might as well grab it
            ITag scenario = _tags.GetGlobalTag(CharConstant.FromString("scnr"));

            _header.ScenarioName = _fileNames.GetTagName(scenario.Index);

            LoadScriptFiles();
        }
Beispiel #17
0
        public ScnrScriptFile(ITag scnrTag, string tagName, FileSegmentGroup metaArea, EngineDescription buildInfo, StringIDSource stringIDs, IPointerExpander expander, MetaAllocator allocator)
        {
            if (CharConstant.ToString(scnrTag.Group.Magic) != "scnr")
            {
                throw new ArgumentException("Invalid tag. The tag must belong to the scnr group.");
            }

            _scnrTag   = scnrTag;
            Name       = tagName.Substring(tagName.LastIndexOf('\\') + 1) + ".hsc";;
            _metaArea  = metaArea;
            _buildInfo = buildInfo;
            _stringIDs = stringIDs;
            _expander  = expander;
            _allocator = allocator;
        }
Beispiel #18
0
        private bool FindLanguageTable(out ITag tag, out StructureLayout layout)
        {
            tag    = null;
            layout = null;

            if (_tags == null)
            {
                return(false);
            }

            if (_buildInfo.Layouts.HasLayout("matg"))
            {
                tag    = _tags.GetGlobalTag(CharConstant.FromString("matg"));
                layout = _buildInfo.Layouts.GetLayout("matg");
            }
            return(tag != null && layout != null && tag.MetaLocation != null);
        }
Beispiel #19
0
        private StructureValueCollection LoadHeader(StructureLayout headerLayout, IReader reader)
        {
            if (_metaArea == null)
            {
                return(null);
            }

            reader.SeekTo(_metaArea.Offset);
            StructureValueCollection result = StructureReader.ReadStructure(reader, headerLayout);

            if ((uint)result.GetInteger("magic") != CharConstant.FromString("tags"))
            {
                throw new ArgumentException("Invalid index table header magic. This map could be compressed, try the Compressor in the Tools menu before reporting.");
            }

            return(result);
        }
Beispiel #20
0
        private void LoadSoundResourceManager(IReader reader)
        {
            ITag ughTag        = _tags.GetGlobalTag(CharConstant.FromString("ugh!"));
            bool haveUghLayout = _buildInfo.Layouts.HasLayout("sound resource gestalt");
            bool canLoadUgh    = ughTag != null && ughTag.MetaLocation != null && haveUghLayout;

            if (ughTag != null && ughTag.MetaLocation != null && haveUghLayout)
            {
                SoundResourceGestalt gestalt = null;
                if (canLoadUgh)
                {
                    gestalt = new SoundResourceGestalt(reader, ughTag, MetaArea, Allocator, _buildInfo, _expander);
                }

                _soundGestalt = new SoundResourceManager(gestalt, _tags, MetaArea, Allocator, _buildInfo, _expander);
            }
        }
Beispiel #21
0
        public void VisitTagRef(TagRefData field)
        {
            SeekToOffset(field.Offset);

            TagGroup   tagGroup = null;
            DatumIndex index;

            if (field.WithGroup)
            {
                // Read the datum index based upon the layout
                StructureValueCollection values = StructureReader.ReadStructure(_reader, _tagRefLayout);
                index = new DatumIndex(values.GetInteger("datum index"));

                // Check the group, in case the datum index is null
                var magic = values.GetInteger("tag group magic");
                var str   = CharConstant.ToString((int)magic);
                tagGroup = field.Tags.Groups.FirstOrDefault(c => c.TagGroupMagic == str);
            }
            else
            {
                // Just read the datum index at the current position
                index = DatumIndex.ReadFrom(_reader);
            }

            TagEntry tag = null;

            if (index.IsValid && index.Index < field.Tags.Entries.Count)
            {
                tag = field.Tags.Entries[index.Index];
                if (tag == null || tag.RawTag == null || tag.RawTag.Index != index)
                {
                    tag = null;
                }
            }

            if (tag != null)
            {
                field.Group = field.Tags.Groups.FirstOrDefault(c => c.RawGroup == tag.RawTag.Group);
                field.Value = tag;
            }
            else
            {
                field.Group = tagGroup;
                field.Value = null;
            }
        }
Beispiel #22
0
        private void Load(IReader reader)
        {
            _header    = LoadHeader(reader, out uint primaryMask);
            _tags      = LoadTagTable(reader, primaryMask);
            _fileNames = LoadFileNames(reader);
            _stringIDs = LoadStringIDs(reader);

            LoadLanguageGlobals(reader);
            LoadScriptFiles();
            LoadSimulationDefinitions(reader);

            if (string.IsNullOrEmpty(_header.ScenarioName))
            {
                //header didn't contain a scenario path yet, but later engines do so might as well grab it
                ITag scenario = _tags.GetGlobalTag(CharConstant.FromString("scnr"));
                _header.ScenarioName = _fileNames.GetTagName(scenario.Index);
            }
        }
Beispiel #23
0
        private StructureValueCollection LoadHeader(IReader reader)
        {
            if (_indexHeaderLocation == null)
            {
                return(null);
            }

            reader.SeekTo(_indexHeaderLocation.AsOffset());
            StructureLayout          headerLayout = _buildInfo.Layouts.GetLayout("index header");
            StructureValueCollection result       = StructureReader.ReadStructure(reader, headerLayout);

            if (result.GetInteger("magic") != CharConstant.FromString("tags"))
            {
                throw new ArgumentException("Invalid index table header magic");
            }

            return(result);
        }
Beispiel #24
0
        private void LoadScriptFiles()
        {
            if (_tags != null)
            {
                ScriptFiles = new IScriptFile[0];

                if (_buildInfo.Layouts.HasLayout("scnr"))
                {
                    //caches are intended for 1 scenario, so only load the *real* one
                    ITag hs = _tags.GetGlobalTag(CharConstant.FromString("scnr"));
                    if (hs != null)
                    {
                        ScriptFiles    = new IScriptFile[1];
                        ScriptFiles[0] = new ScnrScriptFile(hs, _fileNames.GetTagName(hs.Index), MetaArea, _buildInfo, StringIDs, _expander, Allocator);
                    }
                }
            }
        }
Beispiel #25
0
        public void LoadNewTagEntry(TagEntry tag)
        {
            _tag = tag;

            // 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);
        }
Beispiel #26
0
        /// <summary>
        ///     Jumps to the next block and reads its header.
        ///     The <see cref="BlockID" />, <see cref="BlockName" />, <see cref="BlockSize" />, and <see cref="BlockVersion" />
        ///     properties will be updated to hold information about the block.
        /// </summary>
        /// <returns><c>true</c> if another block was available, or <c>false</c> otherwise.</returns>
        public bool NextBlock()
        {
            // If we're at the end of the parent block, then we're done here
            if (_blockEnds.Count > 0 && _currentBlockEnd + BlockHeaderSize > _blockEnds.Peek())
            {
                return(false);
            }

            // Skip to the end of the current block
            _reader.SeekTo(_currentBlockEnd);

            // Read a new block header
            BlockID      = _reader.ReadUInt32();
            BlockName    = CharConstant.ToString((int)BlockID);
            BlockSize    = _reader.ReadInt32() - BlockHeaderSize;
            BlockVersion = _reader.ReadByte();

            _currentBlockEnd = _reader.Position + BlockSize;
            return(true);
        }
Beispiel #27
0
        private void Load(IReader reader)
        {
            StructureValueCollection headerValues = LoadHeader(reader);

            if (headerValues == null)
            {
                return;
            }

            var  numGroups = (int)headerValues.GetInteger("number of tag groups");
            uint groupTableOffset;

            uint tagTableOffset;
            var  numTags = (int)headerValues.GetInteger("number of tags");

            // xbox hax
            if (headerValues.HasInteger("meta header mask"))
            {
                groupTableOffset = (uint)headerValues.GetInteger("tag group table offset") - (uint)headerValues.GetInteger("meta header mask") + (uint)_metaArea.Offset;
                tagTableOffset   = (uint)(_metaArea.Offset + (uint)headerValues.GetInteger("tag table offset")) - (uint)headerValues.GetInteger("meta header mask");
            }
            else
            {
                groupTableOffset = (uint)(_metaArea.Offset + (uint)headerValues.GetInteger("tag group table offset"));
                tagTableOffset   = (uint)(_metaArea.Offset + (uint)headerValues.GetInteger("tag table offset"));
            }

            // offsets are relative to the header
            _groups     = LoadGroups(reader, groupTableOffset, numGroups, _buildInfo);
            _groupsById = BuildGroupLookup(_groups);

            _tags = LoadTags(reader, tagTableOffset, numTags, _buildInfo, _metaArea);

            _globalTags = new Dictionary <int, ITag>();
            //store global tags
            _globalTags[CharConstant.FromString("scnr")] = _tags[(int)headerValues.GetInteger("scenario datum index") & 0xFFFF];
            if (headerValues.HasInteger("map globals datum index"))
            {
                _globalTags[CharConstant.FromString("matg")] = _tags[(int)headerValues.GetInteger("map globals datum index") & 0xFFFF];
            }
        }
Beispiel #28
0
        private bool FindLanguageTable(out ITag tag, out StructureLayout layout)
        {
            tag    = null;
            layout = null;

            if (_tags == null)
            {
                return(false);
            }

            // Check for a PATG tag, and if one isn't found, then use MATG
            if (_buildInfo.Layouts.HasLayout("patg"))
            {
                tag    = _tags.GetGlobalTag(CharConstant.FromString("patg"));
                layout = _buildInfo.Layouts.GetLayout("patg");
            }
            if (tag == null && _buildInfo.Layouts.HasLayout("matg"))
            {
                tag    = _tags.GetGlobalTag(CharConstant.FromString("matg"));
                layout = _buildInfo.Layouts.GetLayout("matg");
            }
            return(tag != null && layout != null);
        }
Beispiel #29
0
        private void Load(IReader reader, StructureValueCollection headerValues, FileSegmentGroup metaArea,
                          EngineDescription buildInfo)
        {
            if ((uint)headerValues.GetInteger("magic") != CharConstant.FromString("tags"))
            {
                throw new ArgumentException("Invalid index table header magic");
            }

            // Groups
            var numGroups        = (int)headerValues.GetInteger("number of tag groups");
            var groupTableOffset = (uint)(metaArea.Offset + (uint)headerValues.GetInteger("tag group table offset"));

            // Offset is relative to the header
            _groups     = ReadGroups(reader, groupTableOffset, numGroups, buildInfo);
            _groupsById = BuildGroupLookup(_groups);

            // Tags
            var numTags        = (int)headerValues.GetInteger("number of tags");
            var tagTableOffset = (uint)(metaArea.Offset + (uint)headerValues.GetInteger("tag table offset"));

            // Offset is relative to the header
            _tags = ReadTags(reader, tagTableOffset, numTags, buildInfo, metaArea);
        }
Beispiel #30
0
        private static CompressionState AnalyzeFirstGen(IReader reader, EngineDescription engineInfo)
        {
            reader.SeekTo(0);
            StructureValueCollection headerValues = StructureReader.ReadStructure(reader, engineInfo.Layouts.GetLayout("header"));

            var metaOffset = (int)headerValues.GetInteger("meta offset");

            if (metaOffset >= reader.Length)
            {
                return(CompressionState.Compressed);
            }


            reader.SeekTo(metaOffset);

            StructureValueCollection tagTableValues = StructureReader.ReadStructure(reader, engineInfo.Layouts.GetLayout("meta header"));

            if ((uint)tagTableValues.GetInteger("magic") != CharConstant.FromString("tags"))
            {
                return(CompressionState.Compressed);
            }

            return(CompressionState.Decompressed);
        }