예제 #1
0
        public FrontendTag NextTag(FrontendObject frontendObject, FrontendScript frontendScript)
        {
            var(id, size) = (Reader.ReadUInt16(), Reader.ReadUInt16());
            var         pos = Reader.BaseStream.Position;
            FrontendTag tag = id switch
            {
                0x6853 => new ScriptHeaderTag(frontendObject, frontendScript),
                0x6353 => new ScriptChainTag(frontendObject, frontendScript),
                0x4946 => new ScriptKeyTrackTag(frontendObject, frontendScript),
                0x6F54 => new ScriptUnknownTag(frontendObject, frontendScript),
                0x644B => new ScriptKeyNodeTag(frontendObject, frontendScript),
                0x5645 => new ScriptEventsTag(frontendObject, frontendScript),
                _ => throw new ChunkReadingException($"Unrecognized tag: 0x{id:X4}")
            };

            tag.Read(Reader, FrontendChunkBlock, frontendObject.Package, id, size);

            if (Reader.BaseStream.Position - pos != size)
            {
                throw new ChunkReadingException($"Expected {size} bytes to be read by {tag.GetType()} but {Reader.BaseStream.Position - pos} bytes were read");
            }

            return(tag);
        }
    }
예제 #2
0
        /*
         *                 ObjectReaderState readerState = new ObjectReaderState(block, this);
         *      frontendObject = chunk.Read(Package, readerState, Reader);
         *
         *      if (Reader.BaseStream.Position - block.DataOffset != block.Size)
         *      {
         *          throw new ChunkReadingException($"ERROR: Expected '{chunk.GetType()}' to read {block.Size} bytes, but it read {Reader.BaseStream.Position - block.DataOffset} bytes instead.");
         *      }
         *
         *      Package.Objects.Add(frontendObject);
         */

        public FrontendObject ReadFrontendObjectChunks(FrontendObject frontendObject, long length)
        {
            var endPos = Reader.BaseStream.Position + length;

            while (Reader.BaseStream.Position < endPos)
            {
                FrontendChunkBlock block = new FrontendChunkBlock
                {
                    Offset    = Reader.BaseStream.Position,
                    ChunkType = (FrontendChunkType)Reader.ReadUInt32(),
                    Size      = Reader.ReadInt32()
                };

                FrontendObjectChunk chunk = block.ChunkType switch
                {
                    FrontendChunkType.ObjectData => new ObjectDataChunk(frontendObject),
                    FrontendChunkType.ScriptData => new ScriptDataChunk(frontendObject),
                    FrontendChunkType.MessageResponses => new MessageResponsesDataChunk(frontendObject),
                    _ => throw new ChunkReadingException($"Unknown chunk type: 0x{((int)block.ChunkType):X8}")
                };

                ObjectReaderState readerState = new ObjectReaderState(block, this);
                frontendObject = chunk.Read(Package, readerState, Reader);

                if (Reader.BaseStream.Position - block.DataOffset != block.Size)
                {
                    throw new ChunkReadingException($"ERROR: Expected '{chunk.GetType()}' to read {block.Size} bytes, but it read {Reader.BaseStream.Position - block.DataOffset} bytes instead.");
                }
            }

            return(frontendObject);
        }
    }
예제 #3
0
 public FrontendObject(FrontendObject original) : this()
 {
     Type     = original.Type;
     NameHash = original.NameHash;
     Flags    = original.Flags;
     Package  = original.Package;
 }
예제 #4
0
        public override FrontendTag NextTag(FrontendObject frontendObject)
        {
            var(id, size) = (Reader.ReadUInt16(), Reader.ReadUInt16());
            var         pos = Reader.BaseStream.Position;
            FrontendTag tag = id switch
            {
                0x694D => new MessageResponseInfoTag(frontendObject),
                0x434D => new MessageResponseCountTag(frontendObject),
                0x6952 => new ResponseIdTag(frontendObject),
                0x7552 => new ResponseParamTag(frontendObject),
                0x7452 => new ResponseTargetTag(frontendObject),
                0x6354 => new MessageTargetCountTag(frontendObject),
                0x744D => new MessageTargetListTag(frontendObject),
                _ => throw new ChunkReadingException($"Unrecognized tag: 0x{id:X4}")
            };

            tag.Read(Reader, FrontendChunkBlock, Package, id, size);

            if (Reader.BaseStream.Position - pos != size)
            {
                throw new ChunkReadingException($"Expected {size} bytes to be read by {tag.GetType()} but {Reader.BaseStream.Position - pos} bytes were read");
            }

            return(tag);
        }
    }
예제 #5
0
        public void ReadObjects(long length)
        {
            var endPos = Reader.BaseStream.Position + length;

            while (Reader.BaseStream.Position < endPos)
            {
                FrontendChunkBlock block = new FrontendChunkBlock
                {
                    Offset    = Reader.BaseStream.Position,
                    ChunkType = (FrontendChunkType)Reader.ReadUInt32(),
                    Size      = Reader.ReadInt32()
                };

                //FrontendObject frontendObject = new FrontendObject
                //{
                //    Package = Package
                //};
                //FrontendObjectChunk chunk = block.ChunkType switch
                //{
                //    FrontendChunkType.ButtonMapCount => new ButtonMapCountChunk(frontendObject),
                //    FrontendChunkType.FrontendObjectContainer => new FrontendObjectContainerChunk(frontendObject),
                //    _ => throw new ChunkReadingException($"Unknown chunk type: 0x{((int)block.ChunkType):X8}")
                //};

                switch (block.ChunkType)
                {
                case FrontendChunkType.ButtonMapCount:
                    ButtonMapCountChunk buttonMapCountChunk = new ButtonMapCountChunk();
                    buttonMapCountChunk.Read(Package, block, this, Reader);
                    break;

                case FrontendChunkType.FrontendObjectContainer:
                    FrontendObject frontendObject = new FrontendObject();
                    FrontendObjectContainerChunk objectContainerChunk = new FrontendObjectContainerChunk(frontendObject);
                    frontendObject = objectContainerChunk.Read(Package, new ObjectReaderState(block, this), Reader);
                    Package.Objects.Add(frontendObject);
                    break;

                default:
                    throw new IndexOutOfRangeException();
                }

                if (Reader.BaseStream.Position - block.DataOffset != block.Size)
                {
                    throw new ChunkReadingException($"ERROR: Expected to read {block.Size} bytes, but it read {Reader.BaseStream.Position - block.DataOffset} bytes instead.");
                }
            }
        }
예제 #6
0
        public override FrontendTag NextTag(FrontendObject frontendObject)
        {
            var(id, size) = (Reader.ReadUInt16(), Reader.ReadUInt16());
            var         pos = Reader.BaseStream.Position;
            FrontendTag tag = id switch
            {
                0x744F => new ObjectTypeTag(frontendObject),
                0x684F => new ObjectHashTag(frontendObject),
                0x504F => new ObjectReferenceTag(frontendObject),
                0x6649 => new ImageInfoTag(frontendObject),
                0x4153 => new ObjectDataTag(frontendObject),
                0x4150 => new ObjectParentTag(frontendObject),
                0x6253 => new StringBufferLengthTag(frontendObject),
                0x7453 => new StringBufferTextTag(frontendObject),
                0x6A53 => new StringBufferFormattingTag(frontendObject),
                0x6C53 => new StringBufferLeadingTag(frontendObject),
                0x7753 => new StringBufferMaxWidthTag(frontendObject),
                0x4853 => new StringBufferLabelHashTag(frontendObject),
                0x314D => new MultiImageTextureTag(frontendObject),
                0x324D => new MultiImageTextureTag(frontendObject),
                0x334D => new MultiImageTextureTag(frontendObject),
                0x614D => new MultiImageTextureFlagsTag(frontendObject),
                0x624D => new MultiImageTextureFlagsTag(frontendObject),
                0x634D => new MultiImageTextureFlagsTag(frontendObject),
                _ => throw new ChunkReadingException($"Unrecognized tag: 0x{id:X4}")
            };

            tag.Read(Reader, FrontendChunkBlock, frontendObject.Package, id, size);

            if (Reader.BaseStream.Position - pos != size)
            {
                throw new ChunkReadingException($"Expected {size} bytes to be read by {tag.GetType()} but {Reader.BaseStream.Position - pos} bytes were read");
            }

            return(tag);
        }
    }
예제 #7
0
 public abstract FrontendTag NextTag(FrontendObject frontendObject);
예제 #8
0
 public override FrontendTag NextTag(FrontendObject frontendObject)
 {
     throw new NotImplementedException("Use NextTag(FrontendObject, FrontendScript) instead");
 }
예제 #9
0
 protected FrontendObjectChunk(FrontendObject frontendObject)
 {
     FrontendObject = frontendObject;
 }
예제 #10
0
 protected FrontendTag(FrontendObject frontendObject)
 {
     FrontendObject = frontendObject;
 }