Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not read the correct data #9

Open
hunter3900 opened this issue May 26, 2024 · 4 comments
Open

can not read the correct data #9

hunter3900 opened this issue May 26, 2024 · 4 comments

Comments

@hunter3900
Copy link

I use this method to read the data
self.navMesh = reader.Read32Bit(br, 6);

DtMeshSetWriter.WriteTiles : tileHeader.tileRef(281474976710656) : tileHeader.dataSize(344)

DtMeshSetReader.ReadTiles : is32Bit(True) : header.numTiles(121) : tileHeader.tileRef(0) : tileHeader.dataSize(65536)

@ikpil
Copy link
Owner

ikpil commented May 26, 2024

The tile reference appears to be 64-bit. However, in this code, it seems to be reading and writing as 32-bit. This might be causing the tile reference value to be displayed incorrectly. To resolve this issue, the code needs to be modified to correctly read and write the data as 64-bit.

@ikpil
Copy link
Owner

ikpil commented May 26, 2024

    public void Test()
    {
        const long tileRef = 281474976710656L;
        const int dataSize = 344;
        
        byte[] actual;
        
        {
            using MemoryStream ms = new MemoryStream();
            using BinaryWriter bw = new BinaryWriter(ms);

            RcIO.Write(bw, tileRef, RcByteOrder.LITTLE_ENDIAN);
            RcIO.Write(bw, dataSize, RcByteOrder.LITTLE_ENDIAN);

            bw.Flush();
            actual= ms.ToArray();
        }

        {
            using MemoryStream ms = new MemoryStream(actual);
            using BinaryReader br = new BinaryReader(ms);
            var byteBuffer = RcIO.ToByteBuffer(br);
            byteBuffer.Order(RcByteOrder.LITTLE_ENDIAN);

            Assert.That(byteBuffer.GetLong(), Is.EqualTo(tileRef));
            Assert.That(byteBuffer.GetInt(), Is.EqualTo(dataSize));
        }
    }

@hunter3900
Copy link
Author

still can not run

@ikpil
Copy link
Owner

ikpil commented May 28, 2024

Is there a way for me to check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants