Example #1
0
        public override void Read(BinaryReader file, uint size)
        {
            //Read the 8 unknown bytes.
            Unknown1.Read(file, 4);
            Unknown2.Read(file, 4);

            //Read the resources list.
            var numresources = file.ReadVLQInt32();

            for (int i = 0; i < numresources; i++)
            {
                var temp = new CSectorDataResource(cr2w);
                temp.Read(file, 24);
                Resources.AddVariable(temp);
            }

            //Read the Objects list.
            var numobjects = file.ReadVLQInt32();

            for (int i = 0; i < numobjects; i++)
            {
                var temp = new CSectorDataObject(cr2w);
                temp.Read(file, 32);
                Objects.AddVariable(temp);
            }

            //Read the data block.
            var datasize = file.ReadVLQInt32();

            BlockData.Bytes = file.ReadBytes(datasize);
        }
Example #2
0
        public override void Read(BinaryReader file, uint size)
        {
            //Read the 8 unknown bytes.
            Unknown1.Read(file, 4);
            Unknown2.Read(file, 4);

            //Read the resources list.
            var numresources = file.ReadVLQInt32();

            for (int i = 0; i < numresources; i++)
            {
                var temp = new CSectorDataResource(cr2w);
                temp.Read(file, 24);
                Resources.AddVariable(temp);
            }

            //Read the Objects list.
            var numobjects = file.ReadVLQInt32();

            for (int i = 0; i < numobjects; i++)
            {
                var temp = new CSectorDataObject(cr2w);
                temp.Read(file, 32);
                Objects.AddVariable(temp);
            }

            // Read the data block.
            var datasize = file.ReadVLQInt32();

            BlockData.Bytes = file.ReadBytes(datasize);

            // add blockdata per object instead of in the end of the file
            // we do it after we read the array for easier writing
            for (int i = 0; i < numobjects; i++)
            {
                CSectorDataObject curobj = (CSectorDataObject)Objects.GetEditableVariables()[i];
                int curoffset            = int.Parse(curobj.offset.ToString());
                int nextoffset           = datasize;
                if (i != numobjects - 1)
                {
                    CSectorDataObject nextobj = (CSectorDataObject)Objects.GetEditableVariables()[i + 1];
                    nextoffset = int.Parse(nextobj.offset.ToString());
                }
                int length = nextoffset - curoffset;

                byte[] cutoutdata = new byte[length];
                Array.Copy(BlockData.Bytes, curoffset, cutoutdata, 0, length);

                curobj.blockdata.Bytes = cutoutdata;
            }
        }
Example #3
0
        public override void Read(BinaryReader file, uint size)
        {
            //Read the 8 unknown bytes.
            Unknown1.Read(file, 4);
            Unknown2.Read(file, 4);

            Resources.Read(file, 0);
            Objects.Read(file, 0);

            // Read the data block.
            blocksize.Read(file, 0);

            for (int i = 0; i < Objects.elements.Count; i++)
            {
                CSectorDataObject curobj = (CSectorDataObject)Objects.GetEditableVariables()[i];

                ulong curoffset = curobj.offset.val;
                byte  type      = curobj.type.val;
                if (!(type == 0x1 || type == 0x2))
                {
                    //System.Diagnostics.Debugger.Break();
                    //throw new NotImplementedException();
                }

                ulong len;
                if (i < Objects.elements.Count - 1)
                {
                    CSectorDataObject nextobj    = (CSectorDataObject)Objects.GetEditableVariables()[i + 1];
                    ulong             nextoffset = nextobj.offset.val;
                    len = nextoffset - curoffset;
                }
                else
                {
                    len = (ulong)blocksize.val - curoffset;
                }
                var blockdata = new SBlockData(cr2w);
                blockdata.Read(file, (uint)len);
                BlockData.AddVariable(blockdata);
            }
        }
Example #4
0
        public override void Read(BinaryReader file, uint size)
        {
            base.Read(file, size);

            blocksize.Read(file, 1);
            for (int i = 0; i < Objects.elements.Count; i++)
            {
                CSectorDataObject curobj = Objects[i];

                ulong curoffset = curobj.offset.val;
                byte  type      = curobj.type.val;
                if (!(type == 0x1 || type == 0x2))
                {
                    //System.Diagnostics.Debugger.Break();
                    //throw new NotImplementedException();
                }

                ulong len;
                if (i < Objects.elements.Count - 1)
                {
                    CSectorDataObject nextobj    = Objects[i + 1];
                    ulong             nextoffset = nextobj.offset.val;
                    len = nextoffset - curoffset;
                }
                else
                {
                    len = (ulong)blocksize.val - curoffset;
                }

                var blockdata = new SBlockData(cr2w, BlockData, "")
                {
                    packedObjectType = (Enums.BlockDataObjectType)curobj.type.val
                };
                blockdata.Read(file, (uint)len);
                BlockData.AddVariable(blockdata);
            }
        }