Ejemplo n.º 1
0
 public StringIDData(string name, uint offset, uint address, StringID sid, StringIDSource source, Trie autocompleteTrie, uint pluginLine)
     : base(name, offset, address, pluginLine)
 {
     _value = sid;
     _source = source;
     _autocompleteTrie = autocompleteTrie;
 }
Ejemplo n.º 2
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, 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();
 }
Ejemplo n.º 3
0
        private void Load(StructureValueCollection values, StringIDSource stringIDs)
        {
            Name = values.HasInteger("name index")
                                ? stringIDs.GetString(new StringID(values.GetInteger("name index")))
                                : values.GetString("name");

            Type            = (short)values.GetInteger("type");
            ExpressionIndex = new DatumIndex(values.GetInteger("expression index"));
        }
        public ThirdGenScenarioScriptFile(ITag scenarioTag, string scenarioName, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
        {
            _tag = scenarioTag;
            _stringIDs = stringIDs;
            _metaArea = metaArea;
            _buildInfo = buildInfo;
            Name = scenarioName.Substring(scenarioName.LastIndexOf('\\') + 1) + ".hsc";

            DefineScriptObjectReflexives();
        }
Ejemplo n.º 5
0
        public FourthGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator,
                                        StringIDSource stringIDs, EngineDescription buildInfo)
        {
            _tag       = zoneTag;
            _metaArea  = metaArea;
            _allocator = allocator;
            _buildInfo = buildInfo;

            Load(reader, stringIDs);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 8
0
        public ThirdGenPluginVisitor(TagHierarchy tags, StringIDSource stringIDs, Trie stringIDTrie, FileSegmentGroup metaArea, bool showInvisibles)
        {
            _tags = tags;
            _stringIDs = stringIDs;
            _stringIDTrie = stringIDTrie;
            _metaArea = metaArea;

            Values = new ObservableCollection<MetaField>();
            Reflexives = new ObservableCollection<ReflexiveData>();
            _showInvisibles = showInvisibles;
        }
Ejemplo n.º 9
0
        public ThirdGenScenarioScriptFile(ITag scenarioTag, string scenarioName, FileSegmentGroup metaArea,
                                          StringIDSource stringIDs, EngineDescription buildInfo)
        {
            _tag       = scenarioTag;
            _stringIDs = stringIDs;
            _metaArea  = metaArea;
            _buildInfo = buildInfo;
            Name       = scenarioName.Substring(scenarioName.LastIndexOf('\\') + 1) + ".hsc";

            DefineScriptObjectReflexives();
        }
Ejemplo n.º 10
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
        {
            Name = values.HasInteger("name index") ? stringIDs.GetString(new StringID(values.GetInteger("name index"))) : values.GetString("name");
            ExecutionType = (short)values.GetInteger("execution type");
            ReturnType = (short)values.GetInteger("return type");
            RootExpressionIndex = new DatumIndex(values.GetInteger("first expression index"));
            if (Name == null)
                Name = "script_" + RootExpressionIndex.Value.ToString("X8");

            Parameters = LoadParameters(reader, values, metaArea, buildInfo);
        }
Ejemplo n.º 11
0
		private ScriptObject ReadScriptObject(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
			StringIDSource stringIDs, EngineDescription buildInfo)
		{
			string name = GetObjectName(values, stringIDs);
			var result = new ScriptObject(name);

			foreach (ScriptObjectReflexive child in _children)
				result.RegisterChildren(child, child.ReadObjects(values, reader, metaArea, stringIDs, buildInfo));

			return result;
		}
Ejemplo n.º 12
0
        public ThirdGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator,
                                       StringIDSource stringIDs, EngineDescription buildInfo, IPointerExpander expander)
        {
            _tag       = zoneTag;
            _metaArea  = metaArea;
            _allocator = allocator;
            _buildInfo = buildInfo;
            _expander  = expander;

            Load(reader, stringIDs);
        }
        public ThirdGenScenarioScriptFile(ITag scenarioTag, string tagName, FileSegmentGroup metaArea,
                                          StringIDSource stringIDs, EngineDescription buildInfo, IPointerExpander expander)
        {
            _scenarioTag = _scriptTag = scenarioTag;
            _expander    = expander;
            _stringIDs   = stringIDs;
            _metaArea    = metaArea;
            _buildInfo   = buildInfo;
            Name         = tagName.Substring(tagName.LastIndexOf('\\') + 1) + ".hsc";

            DefineScriptObjectReflexives();
        }
Ejemplo n.º 14
0
        private void Load(IReader reader, StructureValueCollection values, FileSegmentGroup metaArea, StringIDSource stringIDs, ExpressionTable expressions, BuildInformation buildInfo)
        {
            Name = stringIDs.GetString(new StringID((int)values.GetInteger("name index")));
            ExecutionType = (short)values.GetInteger("execution type");
            ReturnType = (short)values.GetInteger("return type");
            DatumIndex rootExpr = new DatumIndex(values.GetInteger("first expression index"));
            if (rootExpr.IsValid)
                RootExpression = expressions.FindExpression(rootExpr);
            if (Name == null)
                Name = "script_" + rootExpr.Value.ToString("X8");

            Parameters = LoadParameters(reader, values, metaArea, buildInfo);
        }
		public FourthGenScenarioScriptFile(ITag scenarioTag, string scenarioName, FileSegmentGroup metaArea,
			StringIDSource stringIDs, EngineDescription buildInfo)
		{
			_tag = scenarioTag;
			_stringIDs = stringIDs;
			_metaArea = metaArea;
			_buildInfo = buildInfo;
			Name = scenarioName.Substring(scenarioName.LastIndexOf('\\') + 1) + ".hsc";

			DefineScriptObjectReflexives();

			addrFix = _tag.HeaderLocation.AsOffset();
		}
Ejemplo n.º 16
0
 private string GetObjectName(StructureValueCollection values, StringIDSource stringIDs)
 {
     if (values.HasString("name"))
     {
         return values.GetString("name");
     }
     if (values.HasInteger("name stringid"))
     {
         var sid = new StringID(values.GetInteger("name stringid"));
         return stringIDs.GetString(sid);
     }
     throw new InvalidOperationException("Unable to determine the name of objects in the \"" + _layoutName + "\" layout");
 }
Ejemplo n.º 17
0
 private string GetObjectName(StructureValueCollection values, StringIDSource stringIDs)
 {
     if (values.HasString("name"))
     {
         return(values.GetString("name"));
     }
     if (values.HasInteger("name stringid"))
     {
         var sid = new StringID(values.GetInteger("name stringid"));
         return(stringIDs.GetString(sid));
     }
     throw new InvalidOperationException("Unable to determine the name of objects in the \"" + _layoutName + "\" layout");
 }
Ejemplo n.º 18
0
        private ScriptObject ReadScriptObject(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea,
                                              StringIDSource stringIDs, EngineDescription buildInfo, IPointerExpander expander)
        {
            string name   = GetObjectName(values, stringIDs);
            var    result = new ScriptObject(name);

            foreach (ScriptObjectTagBlock child in _children)
            {
                result.RegisterChildren(child, child.ReadObjects(values, reader, metaArea, stringIDs, buildInfo, expander));
            }

            return(result);
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Reads all child objects of this block.
        /// </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, IPointerExpander expander)
        {
            var  count   = (int)values.GetInteger(_countEntryName);
            uint address = (uint)values.GetInteger(_addressEntryName);

            long expand = expander.Expand(address);

            StructureLayout layout = buildInfo.Layouts.GetLayout(_layoutName);

            StructureValueCollection[] entries = TagBlockReader.ReadTagBlock(reader, count, expand, layout, metaArea);
            return(entries.Select(e => ReadScriptObject(e, reader, metaArea, stringIDs, buildInfo, expander)).ToArray());
        }
Ejemplo n.º 20
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;
        }
Ejemplo n.º 21
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;
        }
Ejemplo n.º 22
0
        private void LoadStringIDs(IReader reader)
        {
            var stringTable = new FourthGenIndexedStringTable(reader);
            int buildVer    = 0;

            if (_buildInfo.Name.Contains("ZBT 70"))
            {
                buildVer = 2;
            }
            else if (_buildInfo.Name.Contains("ZBT"))
            {
                buildVer = 1;
            }

            _stringIds = new FourthGenIndexedStringIDSource(stringTable, _buildInfo.StringIDs, buildVer);
        }
Ejemplo n.º 23
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
        {
            StringTableReader stringReader = new StringTableReader();
            ScriptExpressions = LoadScriptExpressions(values, reader, metaArea, stringReader, buildInfo.GetLayout("script expression entry"));
            ScriptObjects = LoadScriptObjects(values, reader, metaArea, stringIDs, buildInfo.GetLayout("script object entry"));
            ScriptGlobals = LoadScriptGlobals(values, reader, metaArea, ScriptExpressions, buildInfo.GetLayout("script global entry"));
            Scripts = LoadScripts(values, reader, metaArea, stringIDs, ScriptExpressions, buildInfo.GetLayout("script entry"), buildInfo);

            CachedStringTable strings = LoadStrings(values, reader, stringReader, metaArea);
            foreach (IExpression expr in ScriptExpressions)
            {
                // FIXME: hax
                if (expr != null)
                    ((ThirdGenExpression)expr).ResolveStrings(strings);
            }
        }
Ejemplo n.º 24
0
 public void Write(IWriter writer, StringIDSource stringIDs, int parameterCount, uint parameterAddress, ScriptLayout layout)
 {
     if (layout == ScriptLayout.HaloReach)
     {
         writer.WriteUInt32(stringIDs.FindOrAddStringID(Name).Value);
     }
     else
     {
         writer.WriteAscii(Name, 0x20);
     }
     writer.WriteInt16(ExecutionType);
     writer.WriteInt16(ReturnType);
     writer.WriteUInt32(RootExpressionIndex.Value);
     writer.WriteInt32(parameterCount);
     writer.WriteUInt32(parameterAddress);
     writer.WriteUInt32(0);
 }
Ejemplo n.º 25
0
        private List<IScript> LoadScripts(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, ExpressionTable expressions, StructureLayout entryLayout, BuildInformation buildInfo)
        {
            int scriptCount = (int)values.GetInteger("number of scripts");
            if (scriptCount == 0)
                return new List<IScript>();

            ScriptsLocation = SegmentPointer.FromPointer(values.GetInteger("script table address"), metaArea);

            // Read all of the script entries first, then go back and create the objects
            // ThirdGenScript reads parameters from its constructor - this may or may not need cleaning up to make this more obvious
            reader.SeekTo(ScriptsLocation.AsOffset());
            List<StructureValueCollection> scriptData = new List<StructureValueCollection>();
            for (int i = 0; i < scriptCount; i++)
                scriptData.Add(StructureReader.ReadStructure(reader, entryLayout));

            List<IScript> result = new List<IScript>();
            foreach (StructureValueCollection scriptValues in scriptData)
                result.Add(new ThirdGenScript(reader, scriptValues, metaArea, stringIDs, expressions, buildInfo));
            return result;
        }
Ejemplo n.º 26
0
 public ThirdGenScenarioMeta(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, BuildInformation buildInfo)
 {
     Load(values, reader, metaArea, stringIDs, buildInfo);
 }
Ejemplo n.º 27
0
 private void Load(StructureValueCollection values, StringIDSource stringIDs)
 {
     Guid = values.GetRaw("guid");
     Name = stringIDs.GetString(new StringID(values.GetInteger("name stringid")));
 }
Ejemplo n.º 28
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();
        }
Ejemplo n.º 29
0
        private void Load(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs,
                          EngineDescription buildInfo)
        {
            Name = values.HasInteger("name index")
                                ? stringIDs.GetString(new StringID(values.GetInteger("name index")))
                                : values.GetString("name");
            ExecutionType       = (short)values.GetInteger("execution type");
            ReturnType          = (short)values.GetInteger("return type");
            RootExpressionIndex = new DatumIndex(values.GetInteger("first expression index"));
            if (Name == null)
            {
                Name = "script_" + RootExpressionIndex.Value.ToString("X8");
            }

            Parameters = LoadParameters(reader, values, metaArea, buildInfo);
        }
Ejemplo n.º 30
0
 private void Load(StructureValueCollection values, StringIDSource stringIDs)
 {
     Guid = values.GetRaw("guid");
     Name = stringIDs.GetString(new StringID(values.GetInteger("name stringid")));
 }
Ejemplo n.º 31
0
 private void LoadResourceTypes(StructureValueCollection values, IReader reader, StringIDSource stringIDs)
 {
     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 ThirdGenResourceType(e, stringIDs)).ToArray();
 }
Ejemplo n.º 32
0
 private void Load(IReader reader, StringIDSource stringIDs)
 {
     StructureValueCollection values = LoadTag(reader);
     LoadResourceTypes(values, reader, stringIDs);
 }
Ejemplo n.º 33
0
        private void LoadStringIDs(IReader reader)
		{
            var stringTable = new FourthGenIndexedStringTable(reader);
			int buildVer = 0;
			if (_buildInfo.Name.Contains("ZBT 70"))
				buildVer = 2;
			else if (_buildInfo.Name.Contains("ZBT"))
				buildVer = 1;

            _stringIds = new FourthGenIndexedStringIDSource(stringTable, _buildInfo.StringIDs, buildVer);
		}
Ejemplo n.º 34
0
 public ThirdGenScript(IReader reader, StructureValueCollection values, FileSegmentGroup metaArea, StringIDSource stringIDs, ExpressionTable expressions, BuildInformation buildInfo)
 {
     Load(reader, values, metaArea, stringIDs, expressions, buildInfo);
 }
Ejemplo n.º 35
0
        private List<IGlobalObject> LoadScriptObjects(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs, StructureLayout entryLayout)
        {
            int objectsCount = (int)values.GetInteger("number of script objects");
            if (objectsCount == 0)
                return new List<IGlobalObject>();

            ScriptObjectsLocation = SegmentPointer.FromPointer(values.GetInteger("script object table address"), metaArea);

            List<IGlobalObject> result = new List<IGlobalObject>();
            reader.SeekTo(ScriptObjectsLocation.AsOffset());
            for (int i = 0; i < objectsCount; i++)
            {
                StructureValueCollection objValues = StructureReader.ReadStructure(reader, entryLayout);
                result.Add(new ThirdGenGlobalObject(objValues, stringIDs));
            }

            return result;
        }
Ejemplo n.º 36
0
 public ThirdGenGlobalObject(StructureValueCollection values, StringIDSource stringIDs)
 {
     Name = values.HasInteger("name index") ? stringIDs.GetString(new StringID(values.GetInteger("name index"))) : values.GetString("name");
     Class = (short)values.GetInteger("type");
     PlacementIndex = (short)values.GetInteger("placement index");
 }
Ejemplo n.º 37
0
 public ThirdGenResourceType(StructureValueCollection values, StringIDSource stringIDs)
 {
     Load(values, stringIDs);
 }
Ejemplo n.º 38
0
 public FourthGenResourceType(StructureValueCollection values, StringIDSource stringIDs)
 {
     Load(values, stringIDs);
 }
Ejemplo n.º 39
0
        internal Script(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs,
			EngineDescription buildInfo)
        {
            Load(values, reader, metaArea, stringIDs, buildInfo);
        }
Ejemplo n.º 40
0
        private void Load(IReader reader, StringIDSource stringIDs)
        {
            StructureValueCollection values = LoadTag(reader);

            LoadResourceTypes(values, reader, stringIDs);
        }
Ejemplo n.º 41
0
 internal Script(StructureValueCollection values, IReader reader, FileSegmentGroup metaArea, StringIDSource stringIDs,
                 EngineDescription buildInfo)
 {
     Load(values, reader, metaArea, stringIDs, buildInfo);
 }
Ejemplo n.º 42
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 = (uint)values.GetInteger("resource type table address");

            long expand = _expander.Expand(address);

            StructureLayout layout = _buildInfo.Layouts.GetLayout("resource type element");

            StructureValueCollection[] entries = TagBlockReader.ReadTagBlock(reader, count, expand, layout, _metaArea);
            _resourceTypes = entries.Select(e => new ThirdGenResourceType(e, stringIDs)).ToArray();
        }
Ejemplo n.º 43
0
 internal ScriptGlobal(StructureValueCollection values, StringIDSource stringIDs)
 {
     Load(values, stringIDs);
 }
Ejemplo n.º 44
0
 private void LoadStringIDs(IReader reader)
 {
     var stringTable = new FourthGenIndexedStringTable(reader);
     _stringIds = new FourthGenIndexedStringIDSource(stringTable, _buildInfo.StringIDs);
 }