Esempio n. 1
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     field_22041_a = datainputstream.readInt();
     field_22042_e = datainputstream.readByte();
     field_22040_b = datainputstream.readInt();
     field_22044_c = datainputstream.readByte();
     field_22043_d = datainputstream.readInt();
 }
Esempio n. 2
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xLocation      = datainputstream.readInt();
     yLocation      = datainputstream.readShort();
     zLocation      = datainputstream.readInt();
     instrumentType = datainputstream.read();
     pitch          = datainputstream.read();
 }
Esempio n. 3
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.read();
     zPosition = datainputstream.readInt();
     type      = datainputstream.read();
     metadata  = datainputstream.read();
 }
Esempio n. 4
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     status    = datainputstream.read();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.read();
     zPosition = datainputstream.readInt();
     face      = datainputstream.read();
 }
Esempio n. 5
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId  = datainputstream.readInt();
     type      = datainputstream.readByte();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
 }
Esempio n. 6
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId  = datainputstream.readInt();
     title     = datainputstream.readUTF();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     direction = datainputstream.readInt();
 }
Esempio n. 7
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId  = datainputstream.readInt();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     yaw       = (byte)datainputstream.read();
     pitch     = (byte)datainputstream.read();
 }
Esempio n. 8
0
    private void initFontsFromData(ref DataInputStream din, Vector fontDefs)
    {
        int num = din.readInt();

        for (int index1 = 0; index1 < num; ++index1)
        {
            int index2 = din.readInt();
            this.m_stringRenderers.addElement(fontDefs.elementAt(index2));
        }
    }
Esempio n. 9
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine("Please drag a .dat file onto this app.");
            }
            FileInfo datFile = new FileInfo(args[0]);

            if (datFile.Exists && datFile.Extension.ToLower() == ".dat")
            {
                // BinaryToBinaryConverter.convert(datFile.FullName, datFile.FullName + "-decomp.dat", false);
                // ^ NO GOOD! Can't convert stuff like Knights because if it can't find the data, it errors out.

                // I have to manually decompress.
                (bool isCompressed, string _, string _) = VersionInfoScraper.GetDatInfo(datFile);

                FileInputStream readFile        = new FileInputStream(datFile.FullName);
                DataInputStream rawBinaryStream = new DataInputStream(readFile);

                // Skip the first 8 bytes (the header of Clyde files)
                rawBinaryStream.readInt();
                rawBinaryStream.readInt();

                if (isCompressed)
                {
                    System.Console.WriteLine("Decompressing...");
                    InflaterInputStream decompStream = new InflaterInputStream(rawBinaryStream);
                    List <byte>         bytes        = new List <byte>();
                    while (true)
                    {
                        int v = decompStream.read();
                        if (v == -1)
                        {
                            break;
                        }
                        bytes.Add((byte)v);
                    }
                    decompStream.close();

                    FileInfo newFile = new FileInfo(datFile.FullName + "-decompressed.dat");
                    using (FileStream str = newFile.OpenWriteNew()) {
                        str.Write(bytes.ToArray(), 0, bytes.Count);
                    }
                    System.Console.WriteLine("Done! Wrote to " + datFile.FullName);
                }
            }
            else
            {
                System.Console.WriteLine("Failed to load. One of these two pieces of information is faulty.");
                System.Console.WriteLine("Exists? " + (datFile.Exists ? "YES" : "NO") + " (expecting YES)");
                System.Console.WriteLine("Extension: " + datFile.Extension + " (expecting .dat)");
            }
            System.Console.ReadKey();
        }
Esempio n. 10
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId    = datainputstream.readInt();
     name        = datainputstream.readUTF();
     xPosition   = datainputstream.readInt();
     yPosition   = datainputstream.readInt();
     zPosition   = datainputstream.readInt();
     rotation    = datainputstream.readByte();
     pitch       = datainputstream.readByte();
     currentItem = datainputstream.readShort();
 }
Esempio n. 11
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readShort();
     zPosition = datainputstream.readInt();
     signLines = new string[4];
     for (int i = 0; i < 4; i++)
     {
         signLines[i] = datainputstream.readUTF();
     }
 }
Esempio n. 12
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId         = datainputstream.readInt();
     type             = datainputstream.readByte();
     xPosition        = datainputstream.readInt();
     yPosition        = datainputstream.readInt();
     zPosition        = datainputstream.readInt();
     yaw              = datainputstream.readByte();
     pitch            = datainputstream.readByte();
     receivedMetadata = DataWatcher.readWatchableObjects(datainputstream);
 }
Esempio n. 13
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId   = datainputstream.readInt();
     itemID     = datainputstream.readShort();
     count      = datainputstream.readByte();
     itemDamage = datainputstream.readShort();
     xPosition  = datainputstream.readInt();
     yPosition  = datainputstream.readInt();
     zPosition  = datainputstream.readInt();
     rotation   = datainputstream.readByte();
     pitch      = datainputstream.readByte();
     roll       = datainputstream.readByte();
 }
Esempio n. 14
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     motionX  = datainputstream.readShort();
     motionY  = datainputstream.readShort();
     motionZ  = datainputstream.readShort();
 }
        /// <summary>
        /// Handles the input <see cref="FileInfo"/> as if it's a binary .DAT file. This reads whether or not it's compressed, its version, and its implementation.
        /// </summary>
        /// <param name="clydeFile"></param>
        /// <returns></returns>
        public static (bool, string, string) GetDatInfo(FileInfo clydeFile)
        {
            // string isCompressed;
            string          version;
            FileInputStream fileIn    = new FileInputStream(clydeFile.FullName);
            DataInputStream dataInput = new DataInputStream(fileIn);

            dataInput.readInt();
            int v = dataInput.readUnsignedShort();

            if (v == 0x1000)
            {
                version = "Classic";
            }
            else if (v == 0x1001)
            {
                version = "Intermediate";
            }
            else if (v == 0x1002)
            {
                version = "VarInt (Latest)";
            }
            else
            {
                version = "Unknown Format ID!";
            }
            bool compressedFormatFlag = dataInput.readUnsignedShort() == 0x1000;

            // isCompressed = compressedFormatFlag ? "Yes" : "No";
            return(compressedFormatFlag, version, HackyGetImplementation(clydeFile, compressedFormatFlag));
        }
Esempio n. 16
0
        private static void loadNode(
            Node @object,
            ref DataInputStream @in,
            ref List <Object3D> objectList,
            ref List <Object3D> rootObjectList)
        {
            Loader.loadTransformable((Transformable)@object, ref @in, ref objectList, ref rootObjectList);
            bool enable1 = @in.readBoolean();
            bool enable2 = @in.readBoolean();
            int  num     = @in.readUnsignedByte();
            int  scope   = @in.readInt();

            if (@in.readBoolean())
            {
                @in.readUnsignedByte();
                @in.readUnsignedByte();
                List <Object3D> rootObjectList1 = (List <Object3D>)null;
                Loader.getReference(ref @in, ref objectList, ref rootObjectList1);
                rootObjectList1 = (List <Object3D>)null;
                Loader.getReference(ref @in, ref objectList, ref rootObjectList1);
            }
            @object.setRenderingEnable(enable1);
            @object.setPickingEnable(enable2);
            @object.setAlphaFactor((float)num / (float)byte.MaxValue);
            @object.setScope(scope);
        }
Esempio n. 17
0
        public override void readPacketData(DataInputStream datainputstream)
        {
            xPosition       = datainputstream.readInt();
            zPosition       = datainputstream.readInt();
            size            = datainputstream.readShort() & 0xffff;
            coordinateArray = new short[size];
            typeArray       = new byte[size];
            metadataArray   = new byte[size];
            for (int i = 0; i < size; i++)
            {
                coordinateArray[i] = datainputstream.readShort();
            }

            datainputstream.readFully(typeArray);
            datainputstream.readFully(metadataArray);
        }
Esempio n. 18
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityID   = datainputstream.readInt();
     slot       = datainputstream.readShort();
     itemID     = datainputstream.readShort();
     itemDamage = datainputstream.readShort();
 }
Esempio n. 19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureRAM read(java.io.InputStream in) throws java.io.IOException
        public static CaptureRAM read(System.IO.Stream @in)
        {
            CaptureRAM ramFragment = new CaptureRAM();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= 8)
            {
                ramFragment.address = data.readInt();
                sizeRemaining      -= 4;
                ramFragment.Length  = data.readInt();
                sizeRemaining      -= 4;

                if (sizeRemaining > data.available())
                {
                    VideoEngine.log_Renamed.warn("CaptureRAM read want=" + sizeRemaining + " available=" + data.available());
                }

                if (sizeRemaining >= ramFragment.Length)
                {
                    ByteBuffer bb = ByteBuffer.allocate(ramFragment.Length);
                    sbyte[]    b  = bb.array();
                    if (b == null)
                    {
                        throw new IOException("Buffer is not backed by an array");
                    }
                    data.readFully(b, 0, ramFragment.Length);
                    ramFragment.buffer = bb;
                    sizeRemaining     -= ramFragment.Length;

                    data.skipBytes(sizeRemaining);

                    VideoEngine.log_Renamed.info(string.Format("Loaded memory {0:x8} - {1:x8} (len {2:x8})", ramFragment.address, ramFragment.address + ramFragment.Length, ramFragment.Length));
                }
                else
                {
                    throw new IOException("Not enough bytes remaining in stream");
                }
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(ramFragment);
        }
Esempio n. 20
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     protocolVersion = datainputstream.readInt();
     username        = datainputstream.readUTF();
     password        = datainputstream.readUTF();
     mapSeed         = datainputstream.readLong();
     dimension       = datainputstream.readByte();
 }
Esempio n. 21
0
 protected internal virtual int readInt(DataInputStream dis)
 {
     if (this.swap)
     {
         return(Utilities.readLittleEndianInt(dis));
     }
     return(dis.readInt());
 }
Esempio n. 22
0
        private void readSmearInfo(string text)
        {
            DataInputStream dataInputStream = new DataInputStream(new FileInputStream(text));

            if (dataInputStream.readInt() != -1060454374)
            {
                dataInputStream.close();
                string text2 = new StringBuilder().append("Bad smear format for ").append(text).toString();

                throw new IOException(text2);
            }
            if (dataInputStream.readInt() != this.unigrams.Length)
            {
                dataInputStream.close();
                string text3 = new StringBuilder().append("Bad unigram length in ").append(text).toString();

                throw new IOException(text3);
            }
            this.bigramSmearMap   = new HashMap();
            this.unigramSmearTerm = new float[this.unigrams.Length];
            [email protected](new StringBuilder().append("Reading ").append(this.unigrams.Length).toString());
            for (int i = 0; i < this.unigrams.Length; i++)
            {
                this.unigramSmearTerm[i] = dataInputStream.readFloat();
            }
            for (int i = 0; i < this.unigrams.Length; i++)
            {
                [email protected](new StringBuilder().append("Processed ").append(i).append(" of ").append(this.loadedBigramBuffers.Length).toString());
                int         num          = dataInputStream.readInt();
                NGramBuffer bigramBuffer = this.getBigramBuffer(i);
                if (bigramBuffer.getNumberNGrams() != num)
                {
                    dataInputStream.close();
                    string text4 = new StringBuilder().append("Bad ngrams for unigram ").append(i).append(" Found ").append(num).append(" expected ").append(bigramBuffer.getNumberNGrams()).toString();

                    throw new IOException(text4);
                }
                for (int j = 0; j < num; j++)
                {
                    int wordID = bigramBuffer.getWordID(j);
                    this.putSmearTerm(i, wordID, dataInputStream.readFloat());
                }
            }
            dataInputStream.close();
        }
Esempio n. 23
0
 private int readInt(DataInputStream dataInputStream, bool flag)
 {
     this.bytesRead += 4L;
     if (flag)
     {
         return(dataInputStream.readInt());
     }
     return(Utilities.readLittleEndianInt(dataInputStream));
 }
Esempio n. 24
0
        public override void readPacketData(DataInputStream datainputstream)
        {
            xPosition = datainputstream.readInt();
            yPosition = datainputstream.read();
            zPosition = datainputstream.readInt();
            direction = datainputstream.read();
            short word0 = datainputstream.readShort();

            if (word0 >= 0)
            {
                byte  byte0 = datainputstream.readByte();
                short word1 = datainputstream.readShort();
                itemStack = new ItemStack(word0, byte0, word1);
            }
            else
            {
                itemStack = null;
            }
        }
Esempio n. 25
0
        public static bool isCepstraFileBigEndian(string filename)
        {
            File            file            = new File(filename);
            int             num             = (int)file.length();
            DataInputStream dataInputStream = new DataInputStream(new FileInputStream(filename));
            int             num2            = dataInputStream.readInt() * 4 + 4;

            dataInputStream.close();
            return(num == num2);
        }
Esempio n. 26
0
 public void readBuiltIn(DataInputStream dis, int index)
 {
     this.m_packId       = (short)-1;
     this.m_index        = (short)index;
     this.m_descStringId = (int)SimWorld.lookupSimsWorld(dis);
     this.m_icon         = SimWorld.lookupSimsWorld(dis);
     this.m_flags        = dis.readInt();
     this.m_buyPrice     = dis.readShort();
     this.m_sellPrice    = dis.readShort();
     this.m_maxInventory = dis.readByte();
 }
Esempio n. 27
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureHeader read(java.io.InputStream in) throws java.io.IOException
        public static CaptureHeader read(System.IO.Stream @in)
        {
            CaptureHeader header = new CaptureHeader();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= size)
            {
                header.packetType = data.readInt();
                sizeRemaining    -= 4;
                data.skipBytes(sizeRemaining);
                //VideoEngine.Console.WriteLine("CaptureHeader type " + header.packetType);
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(header);
        }
Esempio n. 28
0
        /// <returns> Data input for the next message. Note that it does not automatically skip over the last message if it was
        ///         not fully read, for that purpose, skipRemainingBytes() should be explicitly called after reading every
        ///         message. A null return value indicates the position where MessageOutput#finish() had written the end
        ///         marker. </returns>
        /// <exception cref="IOException"> On IO error </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public java.io.DataInput nextMessage() throws java.io.IOException
        public virtual DataInput nextMessage()
        {
            int value = dataInputStream.readInt();

            messageFlags = (int)((value & 0xC0000000L) >> 30);
            messageSize  = value & 0x3FFFFFFF;

            if (messageSize == 0)
            {
                return(null);
            }

            return(new DataInputStream(new BoundedInputStream(countingInputStream, messageSize)));
        }
Esempio n. 29
0
        public virtual int readInt(DataInputStream dis)
        {
            int num;

            if (this.swap)
            {
                num = Utilities.readLittleEndianInt(dis);
            }
            else
            {
                num = dis.readInt();
            }
            this.calculatedCheckSum = ((this.calculatedCheckSum << 20 | this.calculatedCheckSum >> 12) + (long)num & unchecked ((long)((ulong)-1)));
            return(num);
        }
Esempio n. 30
0
        /// <seealso cref= Dumper#writeArchiveMetadata(OutputStream) </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void readArchiveMetadata(java.io.InputStream stream) throws java.io.IOException
        internal virtual void ReadArchiveMetadata(Stream stream)
        {
            DataInputStream metadata = new DataInputStream(stream);                 // Unbuffered. Will not play naughty tricks with the file position.
            int             version  = metadata.readInt();

            if (version == 1)
            {
                _progressPrinter.maxFiles = metadata.readLong();
                _progressPrinter.maxBytes = metadata.readLong();
            }
            else
            {
                throw new IOException("Cannot read archive meta-data. I don't recognise this archive version: " + version + ".");
            }
        }
Esempio n. 31
0
        public void testDisjointBuffers()
        {
            OutputCollector collect = new OutputCollector();
            CompressionCodec codec = new ZlibCodec();
            OutStream @out = new OutStream("test", 400, codec, collect);
            PositionCollector[] positions = new PositionCollector[1024];
            DataOutput stream = new DataOutputStream(@out);
            for (int i = 0; i < 1024; ++i)
            {
                positions[i] = new PositionCollector();
                @out.getPosition(positions[i]);
                stream.writeInt(i);
            }
            @out.Flush();
            Assert.Equal("test", @out.ToString());
            Assert.Equal(1674, collect.buffer.size());
            ByteBuffer[] inBuf = new ByteBuffer[3];
            inBuf[0] = ByteBuffer.allocate(500);
            inBuf[1] = ByteBuffer.allocate(1200);
            inBuf[2] = ByteBuffer.allocate(500);
            collect.buffer.setByteBuffer(inBuf[0], 0, 483);
            collect.buffer.setByteBuffer(inBuf[1], 483, 1625 - 483);
            collect.buffer.setByteBuffer(inBuf[2], 1625, 1674 - 1625);

            for (int i = 0; i < inBuf.Length; ++i)
            {
                inBuf[i].flip();
            }
            InStream @in = InStream.create(null, "test", inBuf,
                new long[] { 0, 483, 1625 }, 1674, codec, 400);
            Assert.Equal("compressed stream test position: 0 length: 1674 range: 0" +
                         " offset: 0 limit: 0 range 0 = 0 to 483;" +
                         "  range 1 = 483 to 1142;  range 2 = 1625 to 49",
                         @in.ToString());
            DataInputStream inStream = new DataInputStream(@in);
            for (int i = 0; i < 1024; ++i)
            {
                int x = inStream.readInt();
                Assert.Equal(i, x);
            }
            Assert.Equal(0, @in.available());
            for (int i = 1023; i >= 0; --i)
            {
                @in.seek(positions[i]);
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[1], inBuf[2] },
                new long[] { 483, 1625 }, 1674, codec, 400);
            inStream = new DataInputStream(@in);
            positions[303].reset();
            @in.seek(positions[303]);
            for (int i = 303; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[0], inBuf[2] },
                new long[] { 0, 1625 }, 1674, codec, 400);
            inStream = new DataInputStream(@in);
            positions[1001].reset();
            for (int i = 0; i < 300; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
            @in.seek(positions[1001]);
            for (int i = 1001; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
        }
Esempio n. 32
0
        public void testUncompressedDisjointBuffers()
        {
            OutputCollector collect = new OutputCollector();
            OutStream @out = new OutStream("test", 400, null, collect);
            PositionCollector[] positions = new PositionCollector[1024];
            DataOutput stream = new DataOutputStream(@out);
            for (int i = 0; i < 1024; ++i)
            {
                positions[i] = new PositionCollector();
                @out.getPosition(positions[i]);
                stream.writeInt(i);
            }
            @out.Flush();
            Assert.Equal("test", @out.ToString());
            Assert.Equal(4096, collect.buffer.size());
            ByteBuffer[] inBuf = new ByteBuffer[3];
            inBuf[0] = ByteBuffer.allocate(1100);
            inBuf[1] = ByteBuffer.allocate(2200);
            inBuf[2] = ByteBuffer.allocate(1100);
            collect.buffer.setByteBuffer(inBuf[0], 0, 1024);
            collect.buffer.setByteBuffer(inBuf[1], 1024, 2048);
            collect.buffer.setByteBuffer(inBuf[2], 3072, 1024);

            for (int i = 0; i < inBuf.Length; ++i)
            {
                inBuf[i].flip();
            }
            InStream @in = InStream.create(null, "test", inBuf,
                new long[] { 0, 1024, 3072 }, 4096, null, 400);
            Assert.Equal("uncompressed stream test position: 0 length: 4096" +
                         " range: 0 offset: 0 limit: 0",
                         @in.ToString());
            DataInputStream inStream = new DataInputStream(@in);
            for (int i = 0; i < 1024; ++i)
            {
                int x = inStream.readInt();
                Assert.Equal(i, x);
            }
            Assert.Equal(0, @in.available());
            for (int i = 1023; i >= 0; --i)
            {
                @in.seek(positions[i]);
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[1], inBuf[2] },
                new long[] { 1024, 3072 }, 4096, null, 400);
            inStream = new DataInputStream(@in);
            positions[256].reset();
            @in.seek(positions[256]);
            for (int i = 256; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }

            @in = InStream.create(null, "test", new ByteBuffer[] { inBuf[0], inBuf[2] },
                new long[] { 0, 3072 }, 4096, null, 400);
            inStream = new DataInputStream(@in);
            positions[768].reset();
            for (int i = 0; i < 256; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
            @in.seek(positions[768]);
            for (int i = 768; i < 1024; ++i)
            {
                Assert.Equal(i, inStream.readInt());
            }
        }