private void Load(IReader reader, StructureValueCollection values, MetaAddressConverter addrConverter, IStringIDSource stringIDs, ExpressionTable expressions, BuildInformation buildInfo)
        {
            Name = stringIDs.GetString(new StringID((int)values.GetNumber("name index")));
            ExecutionType = (short)values.GetNumber("execution type");
            ReturnType = (short)values.GetNumber("return type");
            DatumIndex rootExpr = new DatumIndex(values.GetNumber("first expression index"));
            if (rootExpr.IsValid)
                RootExpression = expressions.FindExpression(rootExpr);
            if (Name == null)
                Name = "script_" + rootExpr.Value.ToString("X8");

            Parameters = LoadParameters(reader, values, addrConverter, buildInfo);
        }
        private void Load(StructureValueCollection values, IReader reader, MetaAddressConverter addrConverter, IStringIDSource stringIDs, BuildInformation buildInfo)
        {
            StringTableReader stringReader = new StringTableReader();
            ScriptExpressions = LoadScriptExpressions(values, reader, addrConverter, stringReader, buildInfo.GetLayout("script expression entry"));
            ScriptObjects = LoadScriptObjects(values, reader, addrConverter, stringIDs, buildInfo.GetLayout("script object entry"));
            ScriptGlobals = LoadScriptGlobals(values, reader, addrConverter, ScriptExpressions, buildInfo.GetLayout("script global entry"));
            Scripts = LoadScripts(values, reader, addrConverter, stringIDs, ScriptExpressions, buildInfo.GetLayout("script entry"), buildInfo);

            CachedStringTable strings = LoadStrings(values, reader, stringReader, addrConverter);
            foreach (IExpression expr in ScriptExpressions)
            {
                // FIXME: hax
                if (expr != null)
                    ((ThirdGenExpression)expr).ResolveStrings(strings);
            }
        }
 public ThirdGenScenarioMeta(StructureValueCollection values, IReader reader, MetaAddressConverter addrConverter, IStringIDSource stringIDs, BuildInformation buildInfo)
 {
     Load(values, reader, addrConverter, stringIDs, buildInfo);
 }
        private List<IScript> LoadScripts(StructureValueCollection values, IReader reader, MetaAddressConverter addrConverter, IStringIDSource stringIDs, ExpressionTable expressions, StructureLayout entryLayout, BuildInformation buildInfo)
        {
            int script = (int)values.GetNumber("number of scripts");
            ScriptsLocation = new Pointer(values.GetNumber("script table address"), addrConverter);

            // 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 < script; i++)
                scriptData.Add(StructureReader.ReadStructure(reader, entryLayout));

            List<IScript> result = new List<IScript>();
            foreach (StructureValueCollection scriptValues in scriptData)
                result.Add(new ThirdGenScript(reader, scriptValues, addrConverter, stringIDs, expressions, buildInfo));
            return result;
        }
        private List<IGlobalObject> LoadScriptObjects(StructureValueCollection values, IReader reader, MetaAddressConverter addrConverter, IStringIDSource stringIDs, StructureLayout entryLayout)
        {
            int objectsCount = (int)values.GetNumber("number of script objects");
            ScriptObjectsLocation = new Pointer(values.GetNumber("script object table address"), addrConverter);

            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;
        }
 public ThirdGenScript(IReader reader, StructureValueCollection values, MetaAddressConverter addrConverter, IStringIDSource stringIDs, ExpressionTable expressions, BuildInformation buildInfo)
 {
     Load(reader, values, addrConverter, stringIDs, expressions, buildInfo);
 }
 public ThirdGenGlobalObject(StructureValueCollection values, IStringIDSource stringIDs)
 {
     Name = stringIDs.GetString(new StringID((int)values.GetNumber("name index")));
     Class = (short)values.GetNumber("type");
     PlacementIndex = (short)values.GetNumber("placement index");
 }