Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: MartinW on September 17, 2013, 05:41:44 PM

Title: Issue write/read ushort with int32
Post by: MartinW on September 17, 2013, 05:41:44 PM
I have a strange situation where if I mix uint with int, the number are scrambled when I tried to read them back. What could cause this?

uint id = 0;
int x = 0;
int y = 64;
int z = 4;

writer.Write(id);
writer.Write(x);
writer.Write(y);
writer.Write(z);

uint id= reader.ReadUInt16();
int x = reader.ReadInt32();
int y = reader.ReadInt32();
int z = reader.ReadInt32();

id : 0
x : 0
y : 4194304
z : 262144
Title: Re: Issue write/read ushort with int32
Post by: ArenMook on September 18, 2013, 01:18:56 PM
Because ReadUInt16 reads 2 bytes. UInt is 4 bytes.