Example #1
0
        public override void Read(IffFile iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                io.ReadUInt32();               //pad
                var version = io.ReadUInt32(); //zero

                var TTAT = io.ReadUInt32();

                var compressionCode = io.ReadByte();
                if (compressionCode != 1)
                {
                    throw new Exception("hey what!!");
                }

                var iop = new IffFieldEncode(io);

                var total = iop.ReadInt32();
                for (int i = 0; i < total; i++)
                {
                    var guid  = (uint)iop.ReadInt32();
                    var count = iop.ReadInt32();
                    var tatts = new short[count];
                    for (int j = 0; j < count; j++)
                    {
                        tatts[j] = iop.ReadInt16();
                    }
                    TypeAttributesByGUID[guid] = tatts;
                }
            }
        }
Example #2
0
        public override void Read(IffFile iff, Stream stream)
        {
            using (var io = IoBuffer.FromStream(stream, ByteOrder.LITTLE_ENDIAN))
            {
                io.ReadUInt32(); //pad
                var version = io.ReadUInt32();

                //house 00: 33 00 00 00
                //house 03: 3E 00 00 00
                //house 79: 45 00 00 00
                //completec:49 00 00 00
                //corresponds to house version?

                var MjbO = io.ReadUInt32();

                var compressionCode = io.ReadByte();
                if (compressionCode != 1)
                {
                    throw new Exception("hey what!!");
                }

                var iop = new IffFieldEncode(io);

                /*
                 * var test1 = iop.ReadInt16();
                 * var testas = new ushort[test1*2];
                 * for (int i=0; i<test1*2; i++)
                 * {
                 *  testas[i] = iop.ReadUInt16();
                 * }*/

                var table = new List <ushort>();
                while (io.HasMore)
                {
                    var value = iop.ReadUInt16();
                    if (value == 0)
                    {
                        break;
                    }
                    table.Add(value);
                }
                IDToOBJT = table.ToArray();

                var list = new List <short>();
                while (io.HasMore)
                {
                    list.Add(iop.ReadInt16());
                }

                var offsets = SearchForObjectData(list);
                for (int i = 1; i < offsets.Count; i++)
                {
                    Console.WriteLine(offsets[i] - offsets[i - 1]);
                }

                ObjectData = new Dictionary <int, MappedObject>();
                int lastOff = 0;
                foreach (var off in offsets)
                {
                    var endOff = off + 72;
                    var size   = endOff - lastOff;
                    var data   = list.Skip(lastOff).Take(size).ToArray();

                    var bas           = size - 72;
                    var objID         = data[bas + 11]; //object id
                    var dir           = data[bas + 1];
                    var parent        = data[bas + 26];
                    var containerid   = data[bas + 2];
                    var containerslot = data[bas + 2];

                    ObjectData[objID] = new MappedObject()
                    {
                        ObjectID = objID, Direction = dir, Data = data, ParentID = parent, ContainerID = containerid, ContainerSlot = containerslot
                    };

                    lastOff = endOff;
                }
            }
        }