Beispiel #1
0
 public void Read(Stream input, STUD stud)
 {
     if (Util.DEBUG)
     {
         data = Util.CopyStream(input, (int)size);
     }
 }
Beispiel #2
0
        public Map(Stream input, bool open = false)
        {
            using (BinaryReader reader = new BinaryReader(input, Encoding.Default, open)) {
                header         = reader.Read <MapHeader>();
                input.Position = header.offset;
                records        = new IMapFormat[header.recordCount];
                commonHeaders  = new MapCommonHeader[header.recordCount];
                for (uint i = 0; i < header.recordCount; ++i)
                {
                    commonHeaders[i] = reader.Read <MapCommonHeader>();
                    long          nps = input.Position + commonHeaders[i].size - 24;
                    MANAGER_ERROR err;
                    if ((err = manager.InitializeInstance(commonHeaders[i].type, input, out records[i])) != MANAGER_ERROR.E_SUCCESS)
                    {
                        if (System.Diagnostics.Debugger.IsAttached)
                        {
                            System.Diagnostics.Debugger.Log(2, "MAP", $"Error reading Map type {commonHeaders[i]:X}\n");
                        }
                    }
                    input.Position = nps;
                }

                if (records.Length > 0 && records[0] != null && records[0].HasSTUD)
                {
                    AlignPosition(input, input.Position);
                    while (true)
                    {
                        if (input.Position >= input.Length)
                        {
                            break;
                        }
                        STUD tmp = new STUD(input, true, STUDManager.Instance, true, false);
                        if (tmp.end == -1)
                        {
                            break;
                        }
                        AlignPosition(input, tmp.end);
                        studs.Add(tmp);
                    }
                }
            }
        }
Beispiel #3
0
        public MANAGER_ERROR InitializeInstance(Type inst, Stream input, out ISTUDInstance instance, STUD stud)
        {
            if (inst == null)
            {
                instance = null;
                return(MANAGER_ERROR.E_UNKNOWN);
            }

            if (System.Diagnostics.Debugger.IsAttached)
            {
                instance = (ISTUDInstance)Activator.CreateInstance(inst);
                instance.Read(input, stud);
                return(MANAGER_ERROR.E_SUCCESS);
            }

            try {
                instance = (ISTUDInstance)Activator.CreateInstance(inst);
                instance.Read(input, stud);
            } catch (Exception ex) {
                Console.Error.WriteLine("Error with {0}", inst.FullName);
                Console.Error.WriteLine(ex.Message);
                instance = null;
                return(MANAGER_ERROR.E_FAULT);
            }

            return(MANAGER_ERROR.E_SUCCESS);
        }
Beispiel #4
0
 public MANAGER_ERROR InitializeInstance(uint id, Stream input, out ISTUDInstance instance, bool suppress, STUD stud)
 {
     return(InitializeInstance(GetInstance(id, suppress), input, out instance, stud));
 }
Beispiel #5
0
 public STUDReference(STUD stud, long index)
 {
     this.index = index;
     this.stud  = stud;
 }