1. cubeia
  2. Cubeia Styx
  3. Issues
Issue #15 resolved

Error in PacketOutputStream.saveUnsignedInt() and PacketInputStream.loadUnsignedInt()

Ernesto Perez
created an issue

There is a problem serialising and/or deserialising unsigned integers using Styx's PacketOutputStream and PacketInputStream.

Code for the test:

    public static void main(String[] args) throws Exception {
        OutputStream os = new FileOutputStream("test.txt");
        DataOutputStream dos = new DataOutputStream(os);
        PacketOutputStream pos = new PacketOutputStream(dos);


        InputStream is = new FileInputStream("test.txt");
        DataInputStream dis = new DataInputStream(is);
        byte[] ba = new byte[200];
        System.out.println(dis.read(ba) + " bytes read from the file");
        PacketInputStream pis = new PacketInputStream(ByteBuffer.wrap(ba));
        System.out.println("Resulting value: " + pis.loadUnsignedInt());

Expected value: 1234

Observed value: -46